Skip to content

Commit 8f0b8ba

Browse files
committed
Merge develop -> asyncio
2 parents c163f16 + 792068d commit 8f0b8ba

28 files changed

Lines changed: 212 additions & 526 deletions

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def get_title_list(s: str) -> list:
264264
send_recovery_code
265265
recover_password
266266
accept_terms_of_service
267+
log_out
267268
""",
268269
advanced="""
269270
Advanced

pyrogram/client/client.py

Lines changed: 126 additions & 401 deletions
Large diffs are not rendered by default.

pyrogram/client/ext/base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class StopTransmission(StopAsyncIteration):
5050

5151
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/joinchat/)([\w-]+)$")
5252
DIALOGS_AT_ONCE = 100
53-
UPDATES_WORKERS = 1
53+
UPDATES_WORKERS = 4
5454
DOWNLOAD_WORKERS = 4
5555
OFFLINE_SLEEP = 900
5656
WORKERS = 4

pyrogram/client/ext/dispatcher.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
UserStatusHandler, RawUpdateHandler, InlineQueryHandler, PollHandler
3535
)
3636

37-
log = logging.getLogger(__name__)
38-
3937

4038
class Dispatcher:
4139
NEW_MESSAGE_UPDATES = (
@@ -111,7 +109,7 @@ async def start(self):
111109
asyncio.ensure_future(self.update_worker(self.locks_list[-1]))
112110
)
113111

114-
log.info("Started {} UpdateWorkerTasks".format(self.workers))
112+
logging.info("Started {} UpdateWorkerTasks".format(self.workers))
115113

116114
async def stop(self):
117115
for i in range(self.workers):
@@ -123,7 +121,7 @@ async def stop(self):
123121
self.update_worker_tasks.clear()
124122
self.groups.clear()
125123

126-
log.info("Stopped {} UpdateWorkerTasks".format(self.workers))
124+
logging.info("Stopped {} UpdateWorkerTasks".format(self.workers))
127125

128126
def add_handler(self, handler, group: int):
129127
async def fn():
@@ -185,7 +183,7 @@ async def update_worker(self, lock):
185183
if handler.check(parsed_update):
186184
args = (parsed_update,)
187185
except Exception as e:
188-
log.error(e, exc_info=True)
186+
logging.error(e, exc_info=True)
189187
continue
190188

191189
elif isinstance(handler, RawUpdateHandler):
@@ -201,10 +199,10 @@ async def update_worker(self, lock):
201199
except pyrogram.ContinuePropagation:
202200
continue
203201
except Exception as e:
204-
log.error(e, exc_info=True)
202+
logging.error(e, exc_info=True)
205203

206204
break
207205
except pyrogram.StopPropagation:
208206
pass
209207
except Exception as e:
210-
log.error(e, exc_info=True)
208+
logging.error(e, exc_info=True)

pyrogram/client/ext/syncer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import logging
2121
import time
2222

23-
log = logging.getLogger(__name__)
24-
2523

2624
class Syncer:
2725
INTERVAL = 20
@@ -83,9 +81,9 @@ def sync(cls, client):
8381
start = time.time()
8482
client.storage.save()
8583
except Exception as e:
86-
log.critical(e, exc_info=True)
84+
logging.critical(e, exc_info=True)
8785
else:
88-
log.info('Synced "{}" in {:.6} ms'.format(
86+
logging.info('Synced "{}" in {:.6} ms'.format(
8987
client.storage.name,
9088
(time.time() - start) * 1000
9189
))

pyrogram/client/methods/chats/get_chat_members.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
from ...ext import BaseClient
2828

29-
log = logging.getLogger(__name__)
30-
3129

3230
class Filters:
3331
ALL = "all"
@@ -154,7 +152,7 @@ async def get_chat_members(
154152

155153
return pyrogram.List(pyrogram.ChatMember._parse(self, member, users) for member in members)
156154
except FloodWait as e:
157-
log.warning("Sleeping for {}s".format(e.x))
155+
logging.warning("Sleeping for {}s".format(e.x))
158156
await asyncio.sleep(e.x)
159157
else:
160158
raise ValueError("The chat_id \"{}\" belongs to a user".format(chat_id))

pyrogram/client/methods/chats/get_dialogs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
from ...ext import BaseClient, utils
2828

29-
log = logging.getLogger(__name__)
30-
3129

3230
class GetDialogs(BaseClient):
3331
async def get_dialogs(
@@ -83,7 +81,7 @@ async def get_dialogs(
8381
)
8482
)
8583
except FloodWait as e:
86-
log.warning("Sleeping for {}s".format(e.x))
84+
logging.warning("Sleeping for {}s".format(e.x))
8785
await asyncio.sleep(e.x)
8886
else:
8987
break
@@ -112,6 +110,6 @@ async def get_dialogs(
112110
if not isinstance(dialog, types.Dialog):
113111
continue
114112

115-
parsed_dialogs.append(pyrogram.Dialog._parse(self, dialog, messages, users, chats))
113+
parsed_dialogs.append(pyrogram.Dialogging._parse(self, dialog, messages, users, chats))
116114

117115
return pyrogram.List(parsed_dialogs)

pyrogram/client/methods/contacts/get_contacts.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
from pyrogram.errors import FloodWait
2626
from ...ext import BaseClient
2727

28-
log = logging.getLogger(__name__)
29-
3028

3129
class GetContacts(BaseClient):
3230
async def get_contacts(self) -> List["pyrogram.User"]:
@@ -45,7 +43,7 @@ async def get_contacts(self) -> List["pyrogram.User"]:
4543
try:
4644
contacts = await self.send(functions.contacts.GetContacts(hash=0))
4745
except FloodWait as e:
48-
log.warning("get_contacts flood: waiting {} seconds".format(e.x))
46+
logging.warning("get_contacts flood: waiting {} seconds".format(e.x))
4947
await asyncio.sleep(e.x)
5048
else:
5149
return pyrogram.List(pyrogram.User._parse(self, user) for user in contacts.users)

pyrogram/client/methods/messages/get_history.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
from ...ext import BaseClient
2929

30-
log = logging.getLogger(__name__)
31-
3230

3331
class GetHistory(BaseClient):
3432
async def get_history(
@@ -104,7 +102,7 @@ async def get_history(
104102
)
105103
)
106104
except FloodWait as e:
107-
log.warning("Sleeping for {}s".format(e.x))
105+
logging.warning("Sleeping for {}s".format(e.x))
108106
await asyncio.sleep(e.x)
109107
else:
110108
break

pyrogram/client/methods/messages/get_history_count.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
import logging
2019
from typing import Union
2120

2221
from pyrogram.api import types, functions
2322
from pyrogram.client.ext import BaseClient
2423

25-
log = logging.getLogger(__name__)
26-
2724

2825
class GetHistoryCount(BaseClient):
2926
async def get_history_count(

0 commit comments

Comments
 (0)