Commit Graph

2062 Commits

Author SHA1 Message Date
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
db3e7656e0 Handle AssertionError when cancelling tasks
Fixes #1478.
2020-06-06 13:54:19 +02:00
Lonami Exo
3f74f83964 Move qrlogin with the rest of custom types 2020-06-06 13:47:56 +02:00
penn5
8557effe13
Fix docs in InlineQuery (#1425) 2020-06-06 13:47:46 +02:00
Lonami Exo
c904b7ccd8 Add a friendly method for QR login
Closes #1471.
2020-06-05 21:58:59 +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
Lonami Exo
8330635a72 Bump to v1.14.0 2020-05-26 09:31:36 +02:00
Lonami Exo
a46ce053f1 Fix another crash for return value when sending albums 2020-05-24 19:01:05 +02:00
Lonami Exo
88e7f0da65 Fix return value when fwding msgs if some are missing
It was supposed to return None for the spots were it failed to fwd
a message, but instead only those that were present were returned,
because we were iterating over the wrong object (dict and not list).
2020-05-24 18:41:30 +02:00
Lonami Exo
29eb90e503 Fix get_pinned_message in Chat
Closes #1458.
2020-05-17 09:35:44 +02:00
JuniorJPDJ
634bc3a8bd
Allow event's func to be async (#1461)
Fixes #1344.
2020-05-16 09:58:37 +02:00
penn5
c45f2e7c39
Handle flood waits of 0 seconds more gracefully (#1460) 2020-05-13 18:50:56 +02:00
Lonami Exo
393da7e57a Expose missing embed_links param in edit_permissions 2020-05-09 17:35:26 +02:00
Lonami Exo
4393ec0b83 Support dice autocast and update docs on send_file for dice 2020-05-05 09:28:37 +02:00
Lonami Exo
c43e2a0a3a Return produced service message with pin_message
Fixes #1394.
2020-04-29 10:29:14 +02:00
Lonami Exo
74bced75b4 Check if the conversation was cancelled on send methods
Fixes #1411.
2020-04-28 21:02:27 +02:00
Lonami Exo
7ea4686d6c Handle FloodWaitError in client.download_media
Fixes #1426. Not entirely happy with the new indirection layer,
but the original __call__ method is already a mess anyway and
the additional cost of an extra call should be neglible compared
to the actual IO.
2020-04-28 20:49:57 +02:00
Lonami Exo
7f3aa43ad4 Rely on types.UpdateChatPinnedMessage for chat unpins
Fixes #1405, probably.
2020-04-27 21:16:45 +02:00
Lonami Exo
71ed1564cb Add a new .dice property to Message 2020-04-27 20:43:09 +02:00
Lonami Exo
bfa46f47ed Register application/x-tgsticker to mimetypes 2020-04-26 13:42:16 +02:00
Lonami Exo
eb58e60dd1 Fix string formatting on events.Raw with bad input param 2020-04-26 13:42:16 +02:00
TishSerg
a16c60c886
Fix action 'song' should alias 'audio' (#1444) 2020-04-26 11:00:00 +02:00
Lonami Exo
c487340f8e Bump to v1.13.0 2020-04-25 16:28:13 +02:00
Lonami Exo
c37dc69592 Fix downloading thumb was using name inferred for video 2020-04-23 21:01:29 +02:00
Lonami Exo
0c8a90f2a3 Fix delete_messages(None, ...) not working 2020-04-23 20:40:23 +02:00
Lonami Exo
67a9718f9e Bump to v1.12.0 2020-04-20 15:12:00 +02:00
Lonami Exo
01cf4967a5 Clarify send_read_acknowledge behaviour and add new error 2020-04-13 15:03:13 +02:00
ov7a
79fb1a54cb
Switch to blocking connect when using proxy (#1432)
Until a better fix is found, this should help proxy users.
2020-04-12 14:28:40 +02:00
Lonami Exo
d0f937bcb6 Don't disconnect borrowed senders immediately (#1364) 2020-04-05 12:34:33 +02:00
Arne Beer
3729fde572
Fix editing of inline messages in some cases (#1427) 2020-04-03 18:37:46 +02:00
Dmitry D. Chernov
0ec612d71a utils: Style fix and simplify a bit the VALID_USERNAME_RE 2020-03-31 19:18:57 +10:00
YouTwitFace
1669d80082
Remove call to _cache_media (#1419)
Fixes #1418
2020-03-29 10:15:53 +02:00
Lonami Exo
3ab9986fc7 Slightly better flow in _file_to_media 2020-03-14 12:16:52 +01:00
Lonami Exo
ccfd7a1015 Don't ignore thumb in send_file(input file)
Fixes #1404
2020-03-14 12:12:40 +01:00
Lonami Exo
68438f4621 Don't store refs to files in cache
File cache has been unused since file_reference were introduced,
there's no point saving them to cache if they're never queried.

Fixes #1400.
2020-03-11 10:07:21 +01:00
Lonami Exo
e3d8109110 Fix a doc typo and update projects using the lib 2020-03-11 10:02:19 +01:00
painor
0e0052888f
Expose key and iv parameter in downloads/uploads (#1397) 2020-03-04 16:12:34 +01:00
Lonami Exo
1ec38aa5b2 Update and clarify some docs
cc #1388, #1396
2020-02-28 11:50:16 +01:00
Lonami Exo
e451abbf20 Avoid another MemoryError 2020-02-28 10:42:23 +01:00
Lonami Exo
e9c5e719f1 Minor docs update, bump v1.11.3 2020-02-24 13:15:56 +01:00
Lonami Exo
9a86447b6e Fix get(_input)_users in ChatAction with no service msg 2020-02-24 13:07:13 +01:00
Pascal Jürgens
0814a20ec4
Fix macOS version parsing (again), bump v1.11.2
#1393
2020-02-21 20:37:24 +01:00
Lonami Exo
8aa15174ab Fix check in macOS (#1369), bump v1.11.1 2020-02-21 12:48:43 +01:00
Lonami Exo
f21abcd529 Update to v1.11 2020-02-20 20:57:17 +01:00
Lonami Exo
1e94fe25fa Log requests that trigger struct.error
The exception hardly provides any valuable information.
This will hopefully help troubleshooting why the error happens.
2020-02-20 13:40:08 +01:00
Lonami Exo
7ffb87170b Update some URLs
Some were out of date, some were examples pointing to a personal
link, which were replaced with generic examples.
2020-02-20 11:50:15 +01:00
Lonami Exo
3d32e16235 Fix within surrogate detection 2020-02-20 10:53:28 +01:00
Lonami Exo
3a6c955c90 Add examples to all events 2020-02-20 10:18:26 +01:00
Lonami Exo
9f73c35621 Fix unparsing of entities that are together 2020-02-20 09:43:37 +01:00
Tulir Asokan
95dc775344
Fix errors found by new tests (#1389) 2020-02-14 18:35:42 +01:00
Lonami
ac8009af4a
Fix default DC ID value 2020-02-02 10:01:15 +01:00
Lonami Exo
5f8032584b Fix _get_response_message for sendMedia(live location) 2020-02-01 15:32:52 +01:00
Lonami Exo
22e645e22f Update to layer 109 2020-01-23 13:43:20 +01:00
Lonami Exo
acb8518911 Fix send_message not forwarding some args to send_file 2020-01-22 14:21:09 +01:00
Lonami Exo
a2fc7dca79 Handle users=None properly in ChatAction 2020-01-21 10:39:51 +01:00
Lonami Exo
da9505fa3c Add some missing words in the docs 2020-01-19 13:25:58 +01:00
Pascal Jürgens
72dc8052b3 Fix crypto imports on macOS Catalina (#1369) 2020-01-17 12:24:59 +01:00
Alexhol
76cc076d61 Fix send_file not considering videos for albums (#1371) 2020-01-17 11:12:20 +01:00
Lonami Exo
78ee787310 Fix utils._get_extension not working in pathlib objects
This was found while testing #1371.
2020-01-17 11:11:10 +01:00
Lonami Exo
d09f6a50b0 Add extra security checks during authkey gen 2020-01-14 12:12:55 +01:00
Lonami
76cf208619
Document where factorization.py comes from 2020-01-09 12:51:41 +01:00
Lonami Exo
76fa7918a5 Fix get_entity(chat) (#1367) 2020-01-08 12:07:58 +01:00
Lonami Exo
3c253734ac Clear old docs and fix formatting in ConnectionError messages 2020-01-07 12:20:01 +01:00
Lonami Exo
d68d70362b Handle PeerIdInvalidError in delete_dialog 2020-01-07 12:14:19 +01:00
Lonami Exo
582a61192a Fix MemoryError on get_input_media(game)
Because an integer was being passed where a TLObject was expected,
so the serialization with bytes() was actually requesting that many
bytes as opposed to properly converting the expected object.
2020-01-04 17:52:31 +01: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
d196c89825 Fix unparsing malformed entities, bump v1.10.10 2019-12-30 10:19:29 +01:00
Lonami Exo
be8838b5f8 Fix wrong call to determine entity type 2019-12-30 10:56:20 +01:00
Lonami Exo
a142b7de5e Handle invalid upload of text fd more gracefully 2019-12-27 12:05:27 +01:00
Lonami Exo
bdb74ac235 Support async fd on download/upload (#1334) 2019-12-27 12:04:08 +01:00
Lonami Exo
bea4225d28 Don't reply to message on text button click (#1351)
Official clients don't do it, so we probably shouldn't either.
2019-12-27 10:56:26 +01:00
Lonami Exo
1bd02d64c5 Handle RuntimeError on helpers._cancel and improve logging 2019-12-27 10:46:01 +01:00
Lonami Exo
94ff5a8641 Handle ChannelForbidden on leaving ChatAction 2019-12-27 10:21:37 +01:00
Lonami Exo
29ff3708c4 Handle UpdateMessagePoll in _get_response_message (#1355) 2019-12-26 22:00:41 +01:00
Lonami Exo
c3188ff0fa Handle empty list properly in buttons 2019-12-23 14:49:40 +01:00
Lonami Exo
fa736f81af Handle all entity types on isinstance checks
Only the uses of `isinstance` against `InputPeer*` types were
reviewed. Notably, `utils` is exempt on this because it needs
to deal with everything on a case-by-case basis.

Since the addition of `*FromMessage` peers, any manual `isinstance`
checks to determine the type were prone to breaking or being
forgotten to be updated, so a common `helpers._entity_type()`
method was made to share this logic.

Since the conversion to `Peer` would be too expensive, a simpler
check against the name is made, which should be fast and cheap.
2019-12-23 13:52:07 +01:00
Lonami Exo
627e176f8e Handle *FromMessage peers in utils' casts 2019-12-23 13:47:55 +01:00
Lonami Exo
ecb27f33f7 Lower log severity on error during disconnect 2019-12-23 11:54:56 +01:00
Lonami Exo
f3111f93b2 Fix unparsing text with malformed message entities 2019-12-19 15:48:59 +01:00
Lonami
ccbc1c669c
Merge pull request #1343 from NotAFile/add-tests
Add example unit test and config for testing
2019-12-14 13:19:49 +01:00
Lonami Exo
7e6f12daa6 Fix ChatAction join/leave in channels, bump v1.10.9 2019-12-11 12:42:51 +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
03f0533139 Fix global search with filter/from_user 2019-12-05 16:19:46 +01:00
Lonami Exo
99d4001db6 Warn users with ProactorEventLoop about proxy issues (#1337) 2019-12-05 11:27:47 +01:00
Lonami Exo
b985dcd248 Fix 3.8 syntax warning and erroneous documentation
Closes #1340 (syntax warning)
Closes #1341 (outdated docs)
2019-12-05 11:14:02 +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
Mengyang Li
149b26fb51 Allow force_document in edit_message (#1335) 2019-11-23 11:00:51 +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
Lonami Exo
6817e19923 Fix return value of send_file(album) of the same media 2019-11-10 14:59:01 +01:00
Lonami Exo
57dd0827f4 Slight improvement on ChatAction's docs 2019-11-10 14:59:01 +01:00
painor
38b929b973 Fix several typos (#1328) 2019-11-10 11:29:43 +01:00
painor
4a1310dc21 Fix RSA key unpacking on missing fingerprint (#1324) 2019-11-05 08:54:10 +01:00
painor
4839d8bf59 Fix pin_message not accepting Message objects (#1322) 2019-11-04 09:46:17 +01:00
penn5
3d1ce845be Don't parse Button's text on click (#1315) 2019-11-01 11:47:44 +01:00
Lonami Exo
a1aaa96120 Fix iter_download would not determine file_size alone 2019-10-31 19:38:49 +01:00
Lonami Exo
a67c94787b Make getting PhotoSize byte count more reusable internally 2019-10-31 19:38:27 +01:00
Lonami Exo
7e346180d7 Fix import ssl may fail under some Python installs
It's only required for certain proxy configurations, so we
don't want it to raise ImportError while the user imports
our library.
2019-10-31 19:20:18 +01:00
Lonami Exo
6850903d17 Fix get_edit not always returning awaitable, bump v1.10.8 2019-10-31 10:44:33 +01:00
Lonami Exo
0a3d164806 Fix handling of early edits in Conversation
The incoming messages were never updated, so of course their
edit_date wasn't either. This would cause the library to be
stuck until it timed out, because the event had already
arrived before we waited for it. As an example:

    await conv.send_message('foo')
    await sleep(1)  # bot has plenty of time to respond+edit
    await conv.get_edit()
2019-10-31 10:44:33 +01:00
YouTwitFace
4a8b19b0be Remove @ya from valid usernames (#1306) 2019-10-28 18:12:47 +01:00
Lonami Exo
baacecadc5 Document some errors, bump v1.10.7 2019-10-27 18:50:21 +01:00
Manuel1510
0a8103b6e8 Replace messages.getPeerDialogs with channels.getFullChannel (#1305) 2019-10-27 18:48:41 +01:00
Lonami Exo
5dcc30dcc6 Handle connection errors during auth key generation
This should help with spurious server-side disconnects during
auth_key generation, which happen most commonly on user DC
migrations.
2019-10-24 13:48:29 +02:00
Lonami Exo
08b78f0c47 Unify retry loops in mtprotosender._connect
Now the retry count is not twice its value.
2019-10-24 13:40:09 +02:00
Lonami Exo
3039915ce9 Factor out parts from mtprotosender._connect
This will help unifying the retry loop and reconnecting
if the server disconnects us during auth key generation
which will be done in a follow-up commit.
2019-10-24 13:36:32 +02:00
Lonami Exo
ca2537941c Fix sending albums in conversations 2019-10-22 20:35:08 +02:00
YouTwitFace
b862f215c5 Ignore channel-only permissions in megagroups (#1292) 2019-10-11 18:04:41 +02:00
Lonami Exo
09f27f0dd7 Update Telegram's RSA keys 2019-10-03 20:52:25 +02:00
Tanner Collin
72dd36bc17 Allow edit_admin on yourself (#1285) 2019-09-29 09:19:44 +02:00
Lonami
07b0583069
Bump to v1.10.6 2019-09-28 09:44:01 +02:00
penn5
88d8424474 Fix kick_participant in channels (#1284)
Presumably some server-side change made insta-unbanning no longer work.
2019-09-28 09:38:41 +02:00
Lonami Exo
5e6ff67d01 Make allow_cache do nothing for now, bump v1.10.5 (#1272) 2019-09-27 15:12:17 +02:00
Lonami Exo
7de01a5f94 Fix resending code with empty phone hash (fix #1283) 2019-09-27 10:41:01 +02:00
Lonami
6da8d1a0ec
Less confusing error for getting marked ID of PeerChannel(0)
Fixes #1282.
2019-09-24 19:01:46 +02:00
Lonami Exo
d1ddfd09b6 Update missing links in the documentation summary 2019-09-24 16:19:56 +02:00
Andrebcd4
40aa46e72a Sleep automatically on slow mode error too (#1279) 2019-09-24 11:37:41 +02:00
Lonami Exo
4f6e5c5f5a Remove another debug print, bump v1.10.4 2019-09-21 18:21:09 +02:00
penn5
8d5a7c6ffb Remove debugging print (#1276) 2019-09-21 17:54:45 +02:00
Lonami
75ca28df49
Parse t.me/@<user> URLs as valid usernames 2019-09-16 11:36:35 +02:00
Lonami Exo
c1774276c2 Fix handling of ChannelForbidden in input peer, bump v1.10.3 2019-09-12 22:30:47 +02:00
Lonami Exo
9c06f29aaf Don't cache entities with min flag set, bump v1.10.2
Since layer 102, there are two access_hash. One with the min flag,
and one without it. This was causing channel invalid errors.

access_hash with min flag set can only be used to fetch files such
as profile pictures.

access_hash with min flag unset can be used under all circumstances.

Previously, the library did not distinguish between these, so it was
caching the hash that could hardly be used for anything.

With this change, only the "full" access_hash is stored, which will
work for any methods.

See also: https://core.telegram.org/api/min
2019-09-12 19:19:46 +02:00
Lonami Exo
5c72e1286e Let delete_dialog work for bot accounts without erroring 2019-09-10 21:38:46 +02:00
Lonami Exo
47956ddbca Fix events.Album and minor docs nit, bump to v1.10.1 2019-09-09 19:21:03 +02:00
Lonami Exo
8ded667a6b Update to v1.10 2019-09-08 11:33:19 +02:00
Lonami Exo
6e9d799103 Actually fix message.document for webpages (57049d follow-up) 2019-09-08 11:06:54 +02:00
Lonami Exo
67183ff9e8 Improve method signatures in the docs 2019-09-08 10:56:35 +02:00
Lonami Exo
dab237e758 Support sending scheduled messages 2019-09-06 13:45:31 +02:00
Lonami Exo
9dd73cd494 Update to layer 105 2019-09-06 13:10:27 +02:00
Lonami Exo
57049de23a Fix message.document for webpages 2019-09-06 13:09:07 +02:00
Lonami Exo
d5faf5e8aa Support getting more than 100 messages by ID 2019-08-26 12:16:46 +02:00
painor
61bc8f7fa3 Fix-up #1259 missing import (#1261) 2019-08-25 21:29:17 +02:00
painor
bd7ab23a8f Support async progress_callback in upload_file (#1259) 2019-08-19 21:11:13 +02:00
Lonami Exo
42874de2b2 Fix start() and sign_up() flow for layer 104 2019-08-16 19:19:42 +02:00
Lonami Exo
00b0319397 Update to layer 104 2019-08-14 00:03:24 +02:00
Lonami Exo
e1905d0d7a Avoid using telethon.sync in the examples 2019-08-13 23:33:39 +02:00
Lonami Exo
61c0e63bbe Avoid unnecessary await in Conversation 2019-08-13 18:11:02 +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
48a70308b5
Update docstring for send_read_acknowledge 2019-08-11 10:23:45 +02:00
Lonami Exo
969a36c2a8 Update docs for silent parameter
Since it now also works in private chats to "not disturb friends"
(see https://telegram.org/blog/silent-messages-slow-mode).
2019-08-10 09:06:05 +02:00
Lonami Exo
f5de2cd9a0 Fix logging bug on disconnect 2019-08-08 09:32:18 +02:00
Lonami Exo
c0e4d6c8b6 Slightly simplify BinaryReader
There was no need for the BufferedReader, since everything
is already in memory. Further, the stream parameter was never
used, so it was also unnecessary. The check for None when
reading length was also unnecessary, since we could just pass
-1 to begin with.
2019-08-07 10:33:46 +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
b1eed82b7f Fix use of newer file IDs and add two new errors 2019-08-06 23:25:58 +02:00
Lonami Exo
b719a2a432 Remove unwanted html.unescape() call 2019-08-04 10:09:23 +02:00
Lonami Exo
8a933afc5d Support iterating over specific drafts more easily 2019-08-01 20:15:32 +02:00
Lonami Exo
d3221a508a Add kick_participant 2019-08-01 19:21:01 +02:00
binares
2b277dd558 Fix (de)serialization of negative timestamps (#1241) 2019-08-01 18:47:38 +02:00
Lonami Exo
2ace4fde41 Fix Forward had its client set to None (#1247) 2019-07-31 11:04:08 +02:00