mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-17 05:08:02 +00:00
Merge branch 'master' into min
This commit is contained in:
commit
17f7141278
@ -46,7 +46,6 @@ from pyrogram.api.errors import (
|
|||||||
VolumeLocNotFound, UserMigrate)
|
VolumeLocNotFound, UserMigrate)
|
||||||
from pyrogram.api.types import (
|
from pyrogram.api.types import (
|
||||||
User, Chat, Channel,
|
User, Chat, Channel,
|
||||||
PeerUser, PeerChannel,
|
|
||||||
InputPeerEmpty, InputPeerSelf,
|
InputPeerEmpty, InputPeerSelf,
|
||||||
InputPeerUser, InputPeerChat, InputPeerChannel
|
InputPeerUser, InputPeerChat, InputPeerChannel
|
||||||
)
|
)
|
||||||
@ -154,7 +153,7 @@ class Client:
|
|||||||
self.auth_key = None
|
self.auth_key = None
|
||||||
self.user_id = None
|
self.user_id = None
|
||||||
|
|
||||||
self.rnd_id = None
|
self.rnd_id = MsgId
|
||||||
|
|
||||||
self.peers_by_id = {}
|
self.peers_by_id = {}
|
||||||
self.peers_by_username = {}
|
self.peers_by_username = {}
|
||||||
@ -167,6 +166,7 @@ class Client:
|
|||||||
|
|
||||||
self.session = None
|
self.session = None
|
||||||
|
|
||||||
|
self.is_started = None
|
||||||
self.is_idle = None
|
self.is_idle = None
|
||||||
|
|
||||||
self.updates_queue = Queue()
|
self.updates_queue = Queue()
|
||||||
@ -195,6 +195,7 @@ class Client:
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.session.start()
|
self.session.start()
|
||||||
|
self.is_started = True
|
||||||
|
|
||||||
if self.user_id is None:
|
if self.user_id is None:
|
||||||
if self.token is None:
|
if self.token is None:
|
||||||
@ -210,8 +211,6 @@ class Client:
|
|||||||
else:
|
else:
|
||||||
self.send(functions.updates.GetState())
|
self.send(functions.updates.GetState())
|
||||||
|
|
||||||
self.rnd_id = MsgId
|
|
||||||
|
|
||||||
for i in range(self.UPDATES_WORKERS):
|
for i in range(self.UPDATES_WORKERS):
|
||||||
Thread(target=self.updates_worker, name="UpdatesWorker#{}".format(i + 1)).start()
|
Thread(target=self.updates_worker, name="UpdatesWorker#{}".format(i + 1)).start()
|
||||||
|
|
||||||
@ -227,6 +226,7 @@ class Client:
|
|||||||
"""Use this method to manually stop the Client.
|
"""Use this method to manually stop the Client.
|
||||||
Requires no parameters.
|
Requires no parameters.
|
||||||
"""
|
"""
|
||||||
|
self.is_started = False
|
||||||
self.session.stop()
|
self.session.stop()
|
||||||
|
|
||||||
for _ in range(self.UPDATES_WORKERS):
|
for _ in range(self.UPDATES_WORKERS):
|
||||||
@ -773,12 +773,15 @@ class Client:
|
|||||||
Raises:
|
Raises:
|
||||||
:class:`pyrogram.Error`
|
:class:`pyrogram.Error`
|
||||||
"""
|
"""
|
||||||
r = self.session.send(data)
|
if self.is_started:
|
||||||
|
r = self.session.send(data)
|
||||||
|
|
||||||
self.fetch_peers(getattr(r, "users", []))
|
self.fetch_peers(getattr(r, "users", []))
|
||||||
self.fetch_peers(getattr(r, "chats", []))
|
self.fetch_peers(getattr(r, "chats", []))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
else:
|
||||||
|
raise ConnectionError("client '{}' is not started".format(self.session_name))
|
||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
parser = ConfigParser()
|
parser = ConfigParser()
|
||||||
|
Loading…
Reference in New Issue
Block a user