mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
PyroFork: Add custom storage support
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
c2a506fca0
commit
acb08eb990
1 changed files with 8 additions and 2 deletions
|
|
@ -50,7 +50,7 @@ from pyrogram.errors import (
|
|||
from pyrogram.handlers.handler import Handler
|
||||
from pyrogram.methods import Methods
|
||||
from pyrogram.session import Auth, Session
|
||||
from pyrogram.storage import FileStorage, MemoryStorage, MongoStorage
|
||||
from pyrogram.storage import FileStorage, MemoryStorage, MongoStorage, Storage
|
||||
from pyrogram.types import User, TermsOfService
|
||||
from pyrogram.utils import ainput
|
||||
from .dispatcher import Dispatcher
|
||||
|
|
@ -130,6 +130,9 @@ class Client(Methods):
|
|||
Mongodb config as dict, e.g.: *dict(connection=async_pymongo.AsyncClient("mongodb://..."), remove_peers=False)*.
|
||||
Only applicable for new sessions.
|
||||
|
||||
storage (:obj:`~pyrogram.storage.Storage`, *optional*):
|
||||
Custom session storage.
|
||||
|
||||
phone_number (``str``, *optional*):
|
||||
Pass the phone number as string (with the Country Code prefix included) to avoid entering it manually.
|
||||
Only applicable for new sessions.
|
||||
|
|
@ -225,6 +228,7 @@ class Client(Methods):
|
|||
session_string: str = None,
|
||||
in_memory: bool = None,
|
||||
mongodb: dict = None,
|
||||
storage: Storage = None,
|
||||
phone_number: str = None,
|
||||
phone_code: str = None,
|
||||
password: str = None,
|
||||
|
|
@ -270,7 +274,9 @@ class Client(Methods):
|
|||
|
||||
self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")
|
||||
|
||||
if self.session_string:
|
||||
if storage:
|
||||
self.storage = storage
|
||||
elif self.session_string:
|
||||
self.storage = MemoryStorage(self.name, self.session_string)
|
||||
elif self.in_memory:
|
||||
self.storage = MemoryStorage(self.name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue