mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-25 00:34:19 +03:00
Revisit and remove a few TODOs
This commit is contained in:
parent
ebfe8ebf40
commit
463847ad50
|
@ -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(
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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('<I', GzipPacked.CONSTRUCTOR_ID) + \
|
||||
TLObject.serialize_bytes(gzip.compress(self.data))
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ class UpdateState:
|
|||
for u in update.updates:
|
||||
u._entities = entities
|
||||
self._updates.put(u)
|
||||
# TODO Handle "tl.UpdatesTooLong"
|
||||
else:
|
||||
update._entities = {}
|
||||
self._updates.put(update)
|
||||
|
|
|
@ -80,7 +80,6 @@ def _find_title(html_file):
|
|||
def _build_menu(docs, filename, root, relative_main_index):
|
||||
"""Builds the menu using the given DocumentWriter up to 'filename',
|
||||
which must be a file (it cannot be a directory)"""
|
||||
# TODO Maybe this could be part of DocsWriter itself, "build path menu"
|
||||
filename = _get_relative_path(filename, root)
|
||||
docs.add_menu('API', relative_main_index)
|
||||
|
||||
|
@ -238,7 +237,6 @@ def _write_html_pages(tlobjects, errors, layer, input_res, output_dir):
|
|||
# Save 'Type: [Constructors]' for use in both:
|
||||
# * Seeing the return type or constructors belonging to the same type.
|
||||
# * Generating the types documentation, showing available constructors.
|
||||
# TODO Tried using 'defaultdict(list)' with strange results, make it work.
|
||||
original_paths = {
|
||||
'css': 'css',
|
||||
'arrow': 'img/arrow.svg',
|
||||
|
@ -254,14 +252,11 @@ def _write_html_pages(tlobjects, errors, layer, input_res, output_dir):
|
|||
for k, v in original_paths.items()}
|
||||
|
||||
original_paths['default_css'] = 'light' # docs.<name>.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 '
|
||||
'<code>telethon.errors</code>.')
|
||||
|
||||
# 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'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user