Commit Graph

131 Commits

Author SHA1 Message Date
Lonami Exo
8190a92aae Add workaround for SQLiteSession needing save after init 2022-05-30 12:59:04 +02:00
Lonami Exo
dfc6d448ed Expose catch_up in client constructor and default it to False 2022-05-20 14:55:47 +02:00
Lonami Exo
09b9cd8193 Fix initial session state load 2022-05-16 19:01:05 +02:00
Lonami Exo
898eb5b82f Call GetState on login to init MessageBox 2022-05-16 10:05:07 +02:00
Lonami Exo
3c7f53802f Fix saving of update state 2022-05-16 09:36:57 +02:00
Lonami Exo
a5c3df2743 Attempt to load and save MessageBox state 2022-05-13 17:40:03 +02:00
Lonami Exo
db09a92bc5 Make use of the new MessageBox 2022-05-13 13:17:16 +02:00
Lonami Exo
b5bfe5d9a1 Remove StateCache 2022-05-13 12:43:50 +02:00
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
penn5
e546ae2f85
Allow per-request flood sleep threshold selection (#3123) 2021-08-06 08:13:34 +02:00
Lonami Exo
3f185aada2 Ignore IPv6 setting if there's no matching DC
May close #3075 (assuming this is what was happening).
It's better to return some DC rather than crashing.
2021-06-19 18:32:23 +02:00
Lonami Exo
63f24d2282 Add new known RPC errors and update docs 2021-05-30 18:00:27 +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
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
1cd11391c4 Unconditionally disconnect exported senders on user disconnect
Borrowed senders are not disconnected immediately, but after a while.
If a borrow was used recently but the user requested the main client
to disconnect, those borrows "shouldn't" disconnect because they were
used recently. However, if the user requests a disconnect, they mean
that EVERYTHING should be disconnected, even if the borrows are recent.

This actually gets rid of warnings about send/recv tasks being destroyed,
which partially addresses #1634. That issue may still have more causes
though.
2020-12-11 16:30:12 +01:00
vegeta1k95
ab3c5acf9a
Add client.set_proxy() (#1632) 2020-11-14 14:01:59 +01:00
Serhii Dylda
633986cfa6 Replace PySocks with python-socks for Python >= 3.6
See discussion at (https://github.com/LonamiWebs/Telethon/pull/1623)

Small fixes for `local_addr` argument.
2020-11-09 19:59:54 +01:00
Stefan
d2756cf68f
Add support for local_ip address binding (#1587) 2020-10-07 10:03:19 +02:00
Tulir Asokan
8ce7e776c1 Add option to raise last error instead of generic ValueError (#1571) 2020-10-01 12:23:10 +02:00
Tanya Degurechaff
1afb5b95e3
Update init params to match those of tdesktop (#1549) 2020-09-10 14:52:25 +02:00
conetra
958698bba7
Remove square bracket around IPv6 addresses (#1517) 2020-08-08 13:16:01 +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
ab594ed0cb Remove unused imports and variables 2020-07-04 13:29:43 +02:00
KnorpelSenf
0f8119c400
Fix typo in docs (#1493) 2020-06-24 14:30:41 +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
d0f937bcb6 Don't disconnect borrowed senders immediately (#1364) 2020-04-05 12:34:33 +02:00
Lonami
ac8009af4a
Fix default DC ID value 2020-02-02 10:01:15 +01:00
NotAFile
9121478a2e fix first type found by tests :) 2019-12-08 00:30:25 +01:00
Lonami Exo
b8aa639f3c Check for event loop method, not type (#1337) 2019-12-06 10:23:15 +01:00
Lonami Exo
99d4001db6 Warn users with ProactorEventLoop about proxy issues (#1337) 2019-12-05 11:27:47 +01:00
Lonami Exo
3a56c8b0f4 Correctly handle flood_sleep_threshold=None and large values
The docstring said large values would be converted to 1 day,
but they were not. With this change None and large values are
handled correctly.

Prevents https://github.com/tulir/mautrix-telegram/issues/380.
2019-11-18 12:51:18 +01:00
YouTwitFace
b862f215c5 Ignore channel-only permissions in megagroups (#1292) 2019-10-11 18:04:41 +02:00
Andrebcd4
40aa46e72a Sleep automatically on slow mode error too (#1279) 2019-09-24 11:37:41 +02:00
Lonami Exo
e1905d0d7a Avoid using telethon.sync in the examples 2019-08-13 23:33:39 +02:00
Lonami Exo
e24dd3ad75 Prevent double-connect causing double-reads later
Which leads to "RuntimeError: readexactly() called while another
coroutine is already waiting for incoming data" being raised,
and causing everything to break or halt.
2019-08-11 19:05:11 +02:00
Lonami Exo
8e36bb4c4d Link Python keywords with Python's documentation 2019-07-06 12:11:00 +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
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
7d0efcf50f Save pts and date only if there is something to save 2019-05-05 22:13:02 +02:00
Lonami Exo
945d438696 Properly await all spawned background tasks 2019-05-04 21:02:07 +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
a151d24951 Fix StateCache accessing None to_id and add logging (#1160) 2019-04-22 12:24:45 +02:00
Lonami Exo
c1880c9191 Fix pts from channels is different (#1160) 2019-04-21 13:56:14 +02:00
bugchecker
0b6d766f0c Fix loading initial pts/date could be None (#1153) 2019-04-14 10:38:26 +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