diff --git a/telethon/client/chats.py b/telethon/client/chats.py index ee2aa56b..02188e73 100644 --- a/telethon/client/chats.py +++ b/telethon/client/chats.py @@ -138,7 +138,6 @@ class ChatMethods(UserMethods): return elif isinstance(entity, types.InputPeerChat): - # TODO We *could* apply the `filter` here ourselves full = await self( functions.messages.GetFullChatRequest(entity.chat_id)) if not isinstance( diff --git a/telethon/client/dialogs.py b/telethon/client/dialogs.py index c7b9c6d7..1adb9ba2 100644 --- a/telethon/client/dialogs.py +++ b/telethon/client/dialogs.py @@ -111,7 +111,7 @@ class DialogMethods(UserMethods): return dialogs @async_generator - async def iter_drafts(self): # TODO: Ability to provide a `filter` + async def iter_drafts(self): """ Iterator over all open draft messages. diff --git a/telethon/client/telegrambaseclient.py b/telethon/client/telegrambaseclient.py index 7bc73b5c..0d0f3c88 100644 --- a/telethon/client/telegrambaseclient.py +++ b/telethon/client/telegrambaseclient.py @@ -219,13 +219,6 @@ class TelegramBaseClient(abc.ABC): self._last_ping = datetime.now() self._ping_delay = timedelta(minutes=1) - # Also have another delay for GetStateRequest. - # - # If the connection is kept alive for long without invoking any - # high level request the server simply stops sending updates. - # TODO maybe we can have ._last_request instead if any req works? - self._last_state = datetime.now() - self._state_delay = timedelta(hours=1) self._state = None self._updates_handle = None self._last_request = time.time() @@ -295,8 +288,6 @@ class TelegramBaseClient(abc.ABC): Disconnects from Telegram. """ await self._sender.disconnect() - # TODO What to do with the update state? Does it belong here? - # self.session.set_update_state(0, self.updates.get_update_state(0)) self.session.close() async def _switch_dc(self, new_dc): diff --git a/telethon/network/mtprotosender.py b/telethon/network/mtprotosender.py index a6b503b8..0a92063e 100644 --- a/telethon/network/mtprotosender.py +++ b/telethon/network/mtprotosender.py @@ -25,11 +25,6 @@ __log__ = logging.getLogger(__name__) _reconnect_sentinel = object() -# TODO Create some kind of "ReconnectionPolicy" that allows specifying -# what should be done in case of some errors, with some sane defaults. -# For instance, should all messages be set with an error upon network -# loss? Should we try reconnecting forever? A certain amount of times? -# A timeout? What about recoverable errors, like connection reset? class MTProtoSender: """ MTProto Mobile Protocol sender @@ -386,10 +381,6 @@ class MTProtoSender: Besides `connect`, only this method ever receives data. """ while self._user_connected and not self._reconnecting: - # TODO Are there more exceptions besides timeout? - # Disconnecting or switching off WiFi only resulted in - # timeouts, and once the network was back it continued - # on its own after a short delay. try: __log__.debug('Receiving items from the network...') body = await self._connection.recv() diff --git a/telethon/tl/core/gzippacked.py b/telethon/tl/core/gzippacked.py index 7b146363..4683ed6e 100644 --- a/telethon/tl/core/gzippacked.py +++ b/telethon/tl/core/gzippacked.py @@ -20,7 +20,6 @@ class GzipPacked(TLObject): Note that this only applies to content related requests. """ data = bytes(request) - # TODO This threshold could be configurable if isinstance(request, TLRequest) and len(data) > 512: gzipped = bytes(GzipPacked(data)) return gzipped if len(gzipped) < len(data) else data @@ -28,7 +27,6 @@ class GzipPacked(TLObject): return data def __bytes__(self): - # TODO Maybe compress level could be an option return struct.pack('.css, local path - type_to_constructors = {} - type_to_functions = {} + type_to_constructors = defaultdict(list) + type_to_functions = defaultdict(list) for tlobject in tlobjects: d = type_to_functions if tlobject.is_function else type_to_constructors - if tlobject.result in d: - d[tlobject.result].append(tlobject) - else: - d[tlobject.result] = [tlobject] + d[tlobject.result].append(tlobject) for t, cs in type_to_constructors.items(): type_to_constructors[t] = list(sorted(cs, key=lambda c: c.name)) @@ -412,7 +407,6 @@ def _write_html_pages(tlobjects, errors, layer, input_res, output_dir): docs.write_text('You can import these from ' 'telethon.errors.') - # TODO Bit hacky, make everything like this? (prepending '../') depth = '../' * (2 if tlobject.namespace else 1) docs.add_script(src='prependPath = "{}";'.format(depth)) docs.add_script(relative_src=paths['search.js'])