Commit Graph
104 Commits
Author SHA1 Message Date
Tulir Asokan d2de0f3aca Make sessions async
SQLiteSession is not updated, don't try to use it
2022-05-12 10:36:10 +02:00
Lonami Exo 2cb6cd5dad Change the way no_updates mode is enabled
See discussion on https://github.com/LonamiWebs/Telethon/commit/49713b2.

The problem with the automatic approach is that some scripts may do
some "fancier" things with the way they register updates, so it was
prone to failure (a handler could be added but since the last request
was without updates, nothing would be received).

This new approach is a bit more annoying to opt-into but also more
explicit.
2021-08-29 12:14:03 +02:00
alexkoay 196cef66fd Fix typehint for callback in UpdateMethods (#3119) 2021-08-03 18:33:46 +02:00
Lonami Exo 0997e3fa9f Remove _log_exc workaround and NullHandler
It was added back in bfc408b probably due to a misunderstanding of
https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library.

The default behaviour of logging WARNING and above is good and
desirable (hiding unhandled exceptions in update handlers by default
was a big, accidental mistake). NullHandler is used to *prevent*
this good default, so it shouldn't be used in the first place.
2021-02-02 20:47:02 +01:00
Lonami Exo b88ec4b814 Print unhandled errors to stderr if logging is not configured
This should mitigate "the code doesn't work but there are no errors"
situations. Users not wanting this behaviour can configure logging
with a high-enough level that won't print anything, or set a filter.
2021-01-30 13:47:28 +01:00
Lonami Exo de7cf03ba7 Stop storing asyncio loop in TelegramClient
The loop parameter was ignored because it shouldn't be used, but
the fact it still stored the current loop on creation messes up
with asyncio.run.
2021-01-18 22:59:19 +01:00
Lonami Exo becfe2ce7a Start reconnect if a second ping is sent without a pong for the first
May help with #1564.
2020-12-11 17:18:25 +01:00
vegeta1k95 39e899294f Fix unhandled ValueError inside _dispatch_update() task (#1615) 2020-11-04 09:58:20 +01:00
vegeta1k95 d0faaa2ead Fix internal get_me() was not expecting network errors (#1594) 2020-10-11 09:33:05 +02:00
Lonami Exo cb92a40156 Add additional asserts to debug issue with peer empty channels 2020-10-05 13:58:04 +02:00
Lonami Exo 4321153b06 Correctly emulate old to_id behaviour 2020-10-02 10:23:04 +02:00
apepenkov 2a114917f1 Fix AlbumHack in combination with events.Raw (#1555) 2020-09-10 16:25:44 +02:00
Lonami Exo 1c3e7dda01 Avoid explicitly passing the loop to asyncio
This behaviour is deprecated and will be removed in future versions
of Python. Technically, it could be considered a bug (invalid usage
causing different behaviour from the expected one), and in practice
it should not break much code (because .get_event_loop() would likely
be the same event loop anyway).
2020-07-25 18:39:35 +02:00
Lonami Exo 4b933069f1 Add hacks to properly handle events.Album from other DCs
Fixes #1479.
2020-06-06 21:01:02 +02:00
Lonami Exo faf7263d8f Handle RPC errors on auto-get_difference
Closes #1428.
2020-06-06 14:04:14 +02:00
Lonami Exo bfa995d52b Don't crash when receiving updates prior to login
Fixes #1467, and enables #1471.
2020-06-05 21:17:09 +02:00
JuniorJPDJ 634bc3a8bd Allow event's func to be async (#1461)
Fixes #1344.
2020-05-16 09:58:37 +02:00
Lonami Exo d0f937bcb6 Don't disconnect borrowed senders immediately (#1364) 2020-04-05 12:34:33 +02:00
Lonami Exo 364afd61e1 Execute get_me() on reconnect
This should let Telegram know we still want updates.
Ideally, we would catch up, but that requires more work.
2020-01-04 17:22:53 +01:00
Lonami Exo cd37478e31 Don't send pings unless the connection is made
This will hopefully avoid batching tens of ping requests which
we don't care about their results.
2019-12-02 18:36:20 +01:00
Manuel1510 0a8103b6e8 Replace messages.getPeerDialogs with channels.getFullChannel (#1305) 2019-10-27 18:48:41 +01:00
Lonami Exo e1905d0d7a Avoid using telethon.sync in the examples 2019-08-13 23:33:39 +02:00
Lonami Exo 45d82f2a85 Fix issues with to/from ID in private chats with multiple clients
This should address #1218.
2019-08-07 00:46:19 +02:00
Lonami Exo de85c34462 Handle connection error when fetching difference in updates 2019-07-23 21:12:08 +02:00
Lonami Exo a7a7c4add2 Pass all Updates when building events 2019-06-30 16:34:34 +02:00
Lonami Exo aa2b3daccc Factor out setting entities to events 2019-06-30 16:34:34 +02:00
Lonami Exo b6b4ea669d Remove messy subclassing in the TelegramClient
Since it was easy to cause MRO inconsistencies, and it's
not really needed now that self is type hinted as the client.
2019-06-24 17:48:46 +02:00
Lonami Exo 4c3e467d25 Add a method to cancel_all conversations (#1183) 2019-06-03 19:41:22 +02:00
Lonami Exo 4ebf825c43 Clarify documentation on connection and receiving updates 2019-05-23 12:11:58 +02:00
Lonami Exo 7c1c040d50 Update docstrings to have consistent style 2019-05-20 11:57:11 +02:00
Lonami Exo 0a3d6106f0 Completely overhaul the documentation 2019-05-09 12:50:09 +02:00
Lonami Exo cfd6d3ce04 Fix catch-up when no pts is known 2019-05-08 18:15:57 +02:00
Lonami Exo d92d989569 Quote type hints
Otherwise, sphinx completely butchers the documentation.
2019-05-08 17:16:09 +02:00
Lonami Exo 61613ab6ac Create a new page with a summary of the method reference 2019-05-06 11:38:26 +02:00
Lonami Exo 945d438696 Properly await all spawned background tasks 2019-05-04 21:02:07 +02:00
Lonami Exo 532bd1c916 Fetch difference only if it is worth it 2019-05-04 19:48:36 +02:00
Lonami Exo 716ab2f96d Fix getting difference for channels and for the first time 2019-05-04 19:29:47 +02:00
Lonami Exo cd4b915522 Add type hints to all public methods in the client 2019-05-03 21:38:41 +02:00
Lonami Exo 6d004601d0 Inline the old _load_entities code 2019-05-01 17:07:12 +02:00
Lonami Exo 22124b5ced Refactor code to fetch missing entities once again
This is another attempt at reducing CPU usage similar to:
    1b6b4a57d9

In addition it simplifies some of the code and opens up new
ideas for the state cache as well.
2019-05-01 14:02:27 +02:00
Lonami Exo 599a5ac3ff Fix using events.Raw after 1b6b4a5 2019-04-29 08:54:10 +02:00
Lonami Exo 1b6b4a57d9 Attempt at reducing CPU usage after c902428
This attempt removes the forced `await` call, which could
be causing that extra usage. Some more boilerplate is needed.
2019-04-23 20:17:43 +02:00
Lonami Exo 4e783728f9 Don't catch up on reconnect and fix typo
The feature is not ready yet.
2019-04-22 16:56:32 +02:00
Lonami Exo a151d24951 Fix StateCache accessing None to_id and add logging (#1160) 2019-04-22 12:24:45 +02:00
Lonami Exo fee0923dd1 Get difference for missing entities in channels too 2019-04-21 21:24:34 +02:00
Lonami Exo c1880c9191 Fix pts from channels is different (#1160) 2019-04-21 13:56:14 +02:00
Lonami Exo fadc343821 Fix catch_up pts loading and remember pts per update 2019-04-13 09:12:59 +02:00
Lonami Exo 9965cda968 Save pts and date in a tuple for immutability
This way it is easy and cheap to copy the two required values
to all incoming updates in case we need to getDifference since
the previous pts/date to fetch entities.

This is still a work in progress.
2019-04-10 21:10:34 +04:00
Lonami Exo 3398bee77a Handle disconnection errors more gracefully in background tasks 2019-04-01 08:46:07 +02:00
Lonami Exo 5377169db2 Call catch_up on reconnect (WIP for #1125) 2019-03-28 12:32:02 +01:00