Skip to content

Persistent Session Storage for Pyrogram (MongoDB)

Notifications You must be signed in to change notification settings

Mayuri-Chan/pyromongo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyromongo

INTRODUCTION

Persistent Session Storage for Pyrogram with MongoDB

async_pymongo (Recommended)

from pyrogram.client import Client
from pyromongo import MongoStorage
from async_pymongo import AsyncClient

client = Client(..)
mongo = AsyncClient("mongodb+srv://..")
client.storage = MongoStorage(mongo["pyrogram"], remove_peers=False) # use remove_peers=True to remove all peers on logout


client.run()

Motor

from pyrogram.client import Client
from pyromongo import MongoStorage
from motor.motor_asyncio import AsyncIOMotorClient

client = Client(..)
mongo = AsyncIOMotorClient("mongodb+srv://..")
client.storage = MongoStorage(mongo["pyrogram"], remove_peers=False) # use remove_peers=True to remove all peers on logout


client.run()

Note:

❌ It will not work with the pyrogram context manager.

async def main():
    async with Client(..) as client:
        client.storage = MongoStorage(..)

# It will only store peers

INSTALLATION:

pip install git+https://github.com/animeshxd/pyromongo

Install dnspython for mongo+srv://.. URIs

pip install dnspython
 
# for Termux use dnspython fork
apt install resolv-conf
pip install git+https://github.com/animeshxd/dnspython

Check other required dependencies for motor https://motor.readthedocs.io/en/stable/installation.html#dependencies

About

Persistent Session Storage for Pyrogram (MongoDB)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%