add in-memory session storage, refactor session storages, remove mixin · fakegit/pyrogram@5dc33c6 · GitHub
Skip to content

Commit 5dc33c6

Browse files
committed
add in-memory session storage, refactor session storages, remove mixin
1 parent 9c4e9e1 commit 5dc33c6

11 files changed

Lines changed: 267 additions & 188 deletions

File tree

pyrogram/client/client.py

Lines changed: 58 additions & 54 deletions

pyrogram/client/ext/base_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
from pyrogram import __version__
2525
from ..style import Markdown, HTML
2626
from ...session.internals import MsgId
27-
from ..session_storage import SessionStorageMixin, BaseSessionStorage
27+
from ..session_storage import SessionStorage
2828

2929

30-
class BaseClient(SessionStorageMixin):
30+
class BaseClient:
3131
class StopTransmission(StopIteration):
3232
pass
3333

@@ -68,14 +68,14 @@ class StopTransmission(StopIteration):
6868
13: "video_note"
6969
}
7070

71-
def __init__(self, session_storage: BaseSessionStorage):
71+
def __init__(self, session_storage: SessionStorage):
7272
self.session_storage = session_storage
7373

7474
self.rnd_id = MsgId
7575
self.channels_pts = {}
7676

77-
self.markdown = Markdown(self.peers_by_id)
78-
self.html = HTML(self.peers_by_id)
77+
self.markdown = Markdown(self.session_storage.peers_by_id)
78+
self.html = HTML(self.session_storage.peers_by_id)
7979

8080
self.session = None
8181
self.media_sessions = {}

pyrogram/client/ext/syncer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def worker(cls):
8181

8282
@classmethod
8383
def sync(cls, client):
84-
client.date = int(time.time())
84+
client.session_storage.date = int(time.time())
8585
try:
86-
client.session_storage.save_session(sync=True)
86+
client.session_storage.save(sync=True)
8787
except Exception as e:
8888
log.critical(e, exc_info=True)
8989
else:

pyrogram/client/methods/contacts/get_contacts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ def get_contacts(self):
4444
log.warning("get_contacts flood: waiting {} seconds".format(e.x))
4545
time.sleep(e.x)
4646
else:
47-
log.info("Total contacts: {}".format(len(self.peers_by_phone)))
47+
log.info("Total contacts: {}".format(len(self.session_storage.peers_by_phone)))
4848
return [pyrogram.User._parse(self, user) for user in contacts.users]

pyrogram/client/session_storage/__init__.py

Lines changed: 4 additions & 2 deletions

0 commit comments

Comments
 (0)