Commit Graph

2158 Commits

Author SHA1 Message Date
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
Lonami Exo
de85c34462 Handle connection error when fetching difference in updates 2019-07-23 21:12:08 +02:00
Lonami Exo
5a225d1668 Fix a dialog's message could be wrong in rare cases 2019-07-23 12:44:19 +02:00
Lonami Exo
eb44c6634b Add Dialog to auto cast to peer 2019-07-23 12:44:06 +02:00
Lonami Exo
5498d14e54 Fix default edit_permissions and clarify documentation 2019-07-23 10:14:31 +02:00
Lonami Exo
ae620db0c5 Better document MESSAGE_ID_INVALID 2019-07-20 11:15:29 +02:00
Lonami Exo
cbcbda5276 Minor documentation and type hint updates 2019-07-17 12:37:16 +02:00
Lonami Exo
4bf85d9e8e Add new Button.auth (#1235) 2019-07-17 12:25:29 +02:00
Lonami Exo
649e9a7b0c Check for empty message after applying parse mode 2019-07-17 12:06:23 +02:00
Lonami Exo
cca50ef842 Improve flood wait log message 2019-07-17 12:04:53 +02:00
Lonami Exo
ec093f90e7 Fix InputKeyboardButtonUrlAuth was not considered inline 2019-07-16 18:47:28 +02:00
Lonami Exo
944fb10733 Add missing return self on action/download ctx managers 2019-07-13 21:21:29 +02:00
painor
ae1c1b3912 Improve permission-related errors (#1231) 2019-07-10 23:19:50 +02:00
painor
2adc746143 Fix CallbackQuery pattern= (#1230) 2019-07-10 17:37:36 +02:00
st7105
c4c263a85b Use flush() only if it exists (#1227) 2019-07-09 11:40:05 +02:00
Lonami Exo
7a78aebb12 Update to v1.9.0 2019-07-06 19:38:18 +02:00
Lonami Exo
97e4d83593 Rename and clarify docs for edit_permissions 2019-07-06 19:31:33 +02:00
Lonami Exo
05b770a93f Fix directly nested markdown entities 2019-07-06 12:55:44 +02:00
Lonami Exo
8e36bb4c4d Link Python keywords with Python's documentation 2019-07-06 12:11:00 +02:00
painor
42d5c0fe6d Add pattern parameter to events.CallbackQuery (#1212) 2019-07-05 21:03:07 +02:00
Lonami Exo
2d0fc8356f Fix markdown parsing for pre blocks and entity after entity 2019-07-05 20:31:43 +02:00
Lonami Exo
be65c63f16 Add missing re-exports in telethon.sync 2019-07-05 16:51:08 +02:00
painor
2d2afc5280 Add edit_admin and edit_restrictions (#1210) 2019-07-05 10:48:21 +02:00
Lonami
0d9e639f4f
Support asynchronous progress_callback's 2019-07-04 15:34:51 +02:00
Lonami Exo
3f19f6fd50 Return None in UserUpdate if information is unknown 2019-07-04 10:34:48 +02:00
Lonami Exo
99b15b916c Turn UserUpdate attributes into properties
This aids discoverability, makes them lazily-loaded,
and in general is more consistent and easier to extend.
2019-07-04 10:17:40 +02:00
Lonami Exo
7285b156f4 Create events.Album (#1216) 2019-06-30 16:34:34 +02:00
Lonami Exo
e8327da189 Fix some methods in Message were not checking for client 2019-06-30 16:34:34 +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
8c771a842f Fix Python 3.5.2 type hinting (#1177) 2019-06-28 21:26:08 +02:00
Lonami Exo
9322c37a94 Document iteration order 2019-06-28 20:44:06 +02:00
Lonami Exo
84c4fcdec6 Fix entities weren't being passed to Draft 2019-06-28 20:34:30 +02:00
Lonami Exo
81e628b9f7 Fix explicit reverse=True with ids= not working 2019-06-28 20:27:36 +02:00
Lonami Exo
4f1edeb750 Let File.ext work even with unknown mime types 2019-06-26 11:31:15 +02:00
Lonami Exo
80c9c5dad3 Avoid memory cycle in Forward 2019-06-26 11:16:17 +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
4e80e21ba1 Update markdown parser to support nested entities 2019-06-24 13:48:29 +02:00
Tulir Asokan
8b28f4ffbf Add support for unparsing nested entities into HTML (#1209) 2019-06-24 12:28:14 +02:00
Lonami Exo
962949008f Add new message entities to markdown/html parsers 2019-06-23 21:35:33 +02:00
Lonami Exo
3c68208c41 Update to layer 102 2019-06-23 21:23:40 +02:00
Lonami Exo
83789aaa42 Return None from ChatGetter when there isn't enough info 2019-06-19 11:46:03 +02:00
Lonami Exo
35ba9848d9 Fix get_extension missing even more photo cases 2019-06-16 11:15:52 +02:00
Lonami
86cdb7c1f8
Remove accidentally-committed debug print 2019-06-15 23:14:59 +02:00
Lonami Exo
8d28d1145a Actually fix invalid state in Conversation (1354bf6 followup) 2019-06-15 21:36:06 +02:00
Lonami Exo
40d32cee95 Assert that dispatched updates are Updates 2019-06-15 21:15:57 +02:00
Lonami Exo
5877459907 Create Message.mark_read() 2019-06-15 19:41:31 +02:00
Lonami Exo
1a056899d7 Fix caption when using send_file for albums / mixed documents 2019-06-15 16:59:16 +02:00
Lonami Exo
fd37e44854 Fix is_image not considering MessageMedia objects
This was causing albums with MessageMedia objects to fail.
2019-06-15 16:42:26 +02:00
Terrance
634d8a7898 Refactor libssl import path workarounds (#1202)
This amends the logic introduced for #1167 to only run when a plain
import of the library fails, thus avoiding the slow path traversal
needed to find the underlying library file.
2019-06-15 13:42:31 +02:00
Lonami Exo
51de0bd2da Update documentation with intersphinx and better summaries 2019-06-11 11:09:22 +02:00
Lonami Exo
31a26c0a0a Fix iter_dialogs missing dialogs once and for all 2019-06-11 10:04:36 +02:00
Lonami Exo
b8a38baaf6 Expose ignore_pinned in iter_dialogs 2019-06-11 09:55:13 +02:00
Lonami Exo
770c2c504d Add new methods to encode and decode waveforms 2019-06-04 21:36:38 +02:00
Lonami Exo
065719c8d8 conversation.cancel() now raises cancelled on future calls (#1183) 2019-06-03 19:44:43 +02:00
Lonami Exo
4c3e467d25 Add a method to cancel_all conversations (#1183) 2019-06-03 19:41:22 +02:00
Lonami Exo
690a40be77 Better behaviour for conversation.cancel() (#1183) 2019-06-03 19:29:08 +02:00
Lonami
9d6150da37
Fix downloading contacts to path (#1197) 2019-06-03 15:44:43 +02:00
Lonami Exo
e47f3ec1d6 Clarify some aspects of the documentation 2019-06-01 16:28:20 +02:00
Lonami Exo
30a0e39060 Update to v1.8.0 2019-05-30 21:31:07 +02:00
Lonami Exo
5832ab2f31 Create new client.pin_message method 2019-05-30 17:15:50 +02:00
Lonami Exo
9ea686ab14 Create new client.iter_profile_photos method 2019-05-30 16:51:19 +02:00
Lonami Exo
0d64fd98f7 Create new client.delete_dialog method 2019-05-30 13:58:05 +02:00
Lonami Exo
e4158acd08 Update to layer 100 2019-05-30 13:23:47 +02:00
Lonami Exo
9f72bd8ca3 Fix manual raising of RPC errors 2019-05-27 18:18:38 +02:00
Lonami Exo
1354bf68a8 Factor out clearing items from pending in conversations
This should prevent bugs and ease reasoning, since
now everything is removed from a single place.
2019-05-27 14:23:42 +02:00
Lonami Exo
0b41454b01 Fix conversation setting result on cancelled futures
On timeout, they are cancelled. On a new message
arriving, we pop and set the result unconditionally.

    conv.send_message('Talk to me please')
    conv.get_response()
    try: conv.get_response(timeout=0.1)
    except asyncio.TimeoutError: pass
    conv.send_message('One more time...')
    conv.get_response()  # errors unless above is commented
2019-05-27 14:10:38 +02:00
Lonami Exo
e5485f3d54 Document raw methods with friendly variants 2019-05-26 21:15:43 +02:00
Lonami Exo
4ebf825c43 Clarify documentation on connection and receiving updates 2019-05-23 12:11:58 +02:00
Lonami Exo
6e5f90730e Fix reversed(client.iter_messages(offset_date=...)) 2019-05-22 12:20:02 +02:00
Lonami Exo
80f19bd1f0 Point to the new domains 2019-05-22 11:29:46 +02:00
Lonami Exo
c3d1d7a64c Rename client.archive as client.edit_folder 2019-05-22 11:20:56 +02:00
Lonami Exo
cf152403ee Use iter_download on download_file 2019-05-21 16:40:11 +02:00
Lonami Exo
0b0f8f4285 Create a method to iterate downloads 2019-05-21 16:16:32 +02:00
Lonami Exo
a9ff328e38 Fix iter_participants search on small group chats 2019-05-20 14:02:51 +02:00
Lonami Exo
465f38c1c6 Fix message.text behaviour with no parse mode 2019-05-20 12:00:52 +02:00
Lonami Exo
383ab9b0b2 Fix message.text not checking if parse_mode was set 2019-05-20 11:57:11 +02:00
Lonami Exo
7c1c040d50 Update docstrings to have consistent style 2019-05-20 11:57:11 +02:00
Hasan
4b74d16438 Fix file_id error checking (#1189) 2019-05-19 22:18:35 +02:00
Lonami Exo
e5f1b2afa3 Update logging calls to use proper formatting 2019-05-17 12:30:13 +02:00
Lonami Exo
a4c2e45d6d Handle more key errors on forward message 2019-05-17 12:30:13 +02:00
Lonami Exo
bcfc3e7550 Remove invalid error inits and move bad msg error 2019-05-15 13:58:19 +02:00
Terrance
0946a7902f Fix super() initialisation call for EventCommon (#1182) 2019-05-12 23:29:01 +02:00
Lonami Exo
9730894a07 Call Chat/Sender Getter init methods 2019-05-12 14:00:12 +02:00
Lonami Exo
fefd6f0e6d Fix use of tg://join?invite= channels 2019-05-12 13:44:09 +02:00
Lonami Exo
5754ad589f Fix type hints for Python 3.5.2 (#1177) 2019-05-12 13:08:07 +02:00
Lonami Exo
4ca3517e22 Fix some type hints 2019-05-11 20:12:57 +02:00
Lonami Exo
c1be0bd2e8 Fix disconnection without a previous connection 2019-05-11 16:53:11 +02:00
Lonami Exo
278f0e9e98 Don't raise errors during disconnect 2019-05-10 18:54:10 +02:00
Lonami Exo
313caf440e Add friendly methods for archiving dialogs 2019-05-10 18:12:16 +02:00
Lonami Exo
1828dca0b9 Support filtering by folder on iter_dialogs 2019-05-10 15:45:24 +02:00
Lonami Exo
a7443612f6 Fix download of PhotoStrippedSize to bytes 2019-05-09 18:56:54 +02:00
Lonami Exo
fbce902cf8 Fix minor documentation issue regarding pre tags 2019-05-09 14:13:43 +02:00
Lonami Exo
7f88238d8f Update external links to the documentation 2019-05-09 14:09:22 +02:00
Lonami Exo
0a3d6106f0 Completely overhaul the documentation 2019-05-09 12:50:09 +02:00
Lonami Exo
10251f9782 Create a new Message.file property (#1168) 2019-05-08 18:41:40 +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
c6691dc6a8 Update the reference with even more types and other docs 2019-05-07 21:25:55 +02:00
Lonami Exo
8bd9dd66ab Re-export the main modules and types from sync
For convenience. People can now easily replace:
from telethon import TelegramClient, events

with
from telethon.sync import TelegramClient, events
2019-05-07 10:47:25 +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
744f5f50fe Fix saving of StringSession 2019-05-06 08:55:24 +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
5ed7bf7815 Fix timeout error not being excepted on Button.click 2019-05-05 19:57:09 +02:00
Lonami Exo
19398d75be Add support for hexadecimal invite links 2019-05-05 11:56:04 +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
f5e611e4d2 Fix SenderGetter was excepting the wrong type 2019-05-04 19:30:33 +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
adc9b4c9f1 Fix SenderGetter should not define abstract methods
Or at least it shouldn't if subclasses are likely to not
implement them, which causes an error if left un-implemented.
2019-05-04 17:59:21 +02:00
Lonami Exo
05fcbfd7b7 Add missing Union in hints.py 2019-05-04 12:39:48 +02:00
Lonami Exo
89c993f567 Add missing hints.py file for the previous commit 2019-05-04 10:21:21 +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
c0e506e568 Add missing await on send_code_request 2019-05-03 21:38:41 +02:00
Lonami Exo
1e17ef1c98 Apply several lints 2019-05-03 21:38:41 +02:00
Lonami
52be689926
Only upgrade database if version < current
Should deal more gracefully when using new
session files in older versions of the library.
2019-05-02 23:20:39 +02:00
Lonami Exo
cb56c54351 Use the entity cache in sender getter 2019-05-02 18:51:10 +02:00
Lonami Exo
1a00de6494 Add missing checks in the message for is client None 2019-05-02 18:44:28 +02:00
Lonami Exo
b58c0d3071 Stop relying on __doc__ in EntityCache
This breaks when running with python -OO (optimized) which
removes the documentation but is crucial. Instead and thanks
to fce5cfea, we can now rely on the type hints instead.
2019-05-02 10:20:49 +02:00
Lonami Exo
3a1496c205 Reuse code for _get_entity_pair
Less error-prone, improved the function flow for all callers,
and removed some duplicate work.
2019-05-01 17:52:32 +02:00
Lonami Exo
6d004601d0 Inline the old _load_entities code 2019-05-01 17:07:12 +02:00
Lonami Exo
e84c9847c5 Use sets instead of isinstance in StateCache too
Similar reasoning to the change for EntityCache, sets are faster
than attribute lookups (into types.) and isinstance (another global
lookup). Updating the state is also very common, so it should be
as fast as possible.
2019-05-01 16:37:54 +02:00
Lonami Exo
9a400748f7 Fix InlineBuilder only working with local files 2019-05-01 16:02:21 +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
c12c65f728 Let utils.get_peer handle DialogPeer
This is important since some updates have a peer of
that type instead of just the normal Peer instance.
2019-05-01 12:49:36 +02:00
Lonami Exo
1dc6d226b7 Best-effort attempt at finding libssl (#1167) 2019-04-30 16:22:19 +02:00
Lonami Exo
1ead9757d3 Fix Conversation not allowing getting responses after ID 0 2019-04-29 08:54:10 +02:00
Lonami Exo
599a5ac3ff Fix using events.Raw after 1b6b4a5 2019-04-29 08:54:10 +02:00
Lonami
1805dc48ec
Fix-up 3ea1c9f no longer handling ssl being None 2019-04-28 14:13:29 +02:00
Lonami
3ea1c9f04b
Handle rare case when failing to load libssl (#1167) 2019-04-28 10:44:22 +02:00
Lonami Exo
1666976646 Fix-up stripped_photo_to_jpg from the previous commit 2019-04-25 20:37:48 +02:00
YoilyL
b0e96b2821 Fix stripped image downloads (#1165) 2019-04-25 20:31:52 +02:00
Lonami Exo
19664cd9cf Call self._writer.wait_closed() on disconnect
https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamWriter.wait_closed
2019-04-25 09:56:30 +02:00
Lonami Exo
01eb49d3a4 Update to v1.7.1 2019-04-24 12:46:48 +02:00
Lonami Exo
9fc719cb24 Update download_media with a new way to save thumbs (#1164) 2019-04-24 12:38:03 +02:00
Lonami Exo
21aec00e46 Fix downloading photos with download_file (#1164) 2019-04-24 12:37:19 +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
56595e4a9c Treat all error codes as positive
This means that -500 errors will now behave like 500 errors
correctly so the -500 "No workers running" will properly be
caught and the library will retry requests by default.
2019-04-23 11:28:09 +02:00
Lonami Exo
665c844c9d Update to v1.7 2019-04-22 20:05:45 +02:00
Lonami Exo
bb23bc0fd2 Finish update to layer 98 2019-04-22 19:05:25 +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
8868ce14e8 Update to layer 98 2019-04-22 16:51:05 +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
yegor
8edbfbdced Fix dd mode in MTProxies (#1157) 2019-04-19 22:09:22 +02:00
Lonami Exo
a7b4794585 Fix telethon.sync not syncifying takeout client 2019-04-19 13:58:37 +02:00
Lonami Exo
68bf9f76f6 Fix forward_messages for a single message when using IDs 2019-04-17 08:51:21 +02:00
Lonami
4c1555cc5f
Fix iter_dialogs missing many dialogs 2019-04-16 13:00:18 +02:00
bugchecker
0b6d766f0c Fix loading initial pts/date could be None (#1153) 2019-04-14 10:38:26 +02:00
Lonami Exo
6d83b16503 Fix CallbackQuery ignoring func 2019-04-13 16:42:53 +02:00
Lonami Exo
bd6c03e5f9 Rename grouped to as_album in forward_messages
Public comments regarding this change can be found at:
cf3a4bc658
2019-04-13 11:02:54 +02:00
Lonami Exo
20b8250037 Fix-up new sync __enter__ not handling the client directly 2019-04-13 10:55:51 +02:00
Lonami Exo
9090ede5db Reduce __enter__/__exit__ boilerplate for sync ctx managers 2019-04-13 10:53:33 +02:00
Lonami Exo
badefcec48 Add new action method to easily send chat actions like typing 2019-04-13 10:37:23 +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
73742633bd Smarter grouping behaviour when forwarding messages 2019-04-11 15:18:15 +02:00
Lonami Exo
cf3a4bc658 Expose grouped parameter in forward_messages (default True) 2019-04-11 12:47:14 +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
bec0fa414e Add missing files for the previous commit 2019-04-09 16:55:33 +04:00
Lonami Exo
b32d8307ec Fix sending albums not returning the sent messages (#1151) 2019-04-09 16:48:58 +04:00
Lonami Exo
9598e1877c Fix _get_response_message when integers are given #1151 2019-04-09 16:31:50 +04:00
Lonami Exo
2fb560624d Fix seeking on strings from c0828f5 when uploading files 2019-04-09 09:29:06 +04:00
Lonami Exo
29b21209bf Force fetch sender/chat if only min information was given 2019-04-05 21:28:31 +04:00
Lonami Exo
5e5fe5876a Fix mimetype for mp3 files
It was incorrectly audio/mp3, when audio/mpeg is the correct one.
This was causing sending mp3 voice notes to not work.
2019-04-04 10:10:54 +02:00
Lonami Exo
ff8349ff3f Prevent download_profile_photo from downloading arbitrary files
First of all, because it shouldn't be doing that. Second, it was
buggy and was passing the tuple returned by get_input_location to
download_file which doesn't accept tuples (instead it should be
passed the photo object so that download_file could return dc_id
and input file location itself).
2019-04-03 09:51:33 +02:00
Lonami Exo
22fcdeef7f Better get_input_entity code flow
Plenty of unnecessary exceptions were being raised and caught when
the input parameters were already correct. Furthermore, since
8abc7ade22, the in-disk cache was no
longer being used (so using usernames always reached out to memory).
2019-04-03 09:41:36 +02:00
Lonami
f95933c246
Fix downloading contacts (#1147) 2019-04-02 14:33:41 +02:00
Lonami Exo
41e4d0f788 Let forward_messages work with messages from different chats
Previously it would take the first chat it found and use the IDs
of all messages, even if they belonged to different chats, resulting
in unexpected messages to be forwarded.

Another solution would be to check that all the chats are the same,
but this solves the issue more nicely and makes it more powerful.
2019-04-02 10:46:37 +02:00
Lonami Exo
a9ab3e1211 Update forward_messages to use _get_response_message 2019-04-02 10:44:42 +02:00
Lonami Exo
c0828f590f Fix resize if needed not seeking back for image = bytes 2019-04-02 08:59:35 +02:00
Lonami Exo
85be48f42b Document misleading message.out value for events.MessageEdited 2019-04-02 08:39:19 +02:00
Lonami Exo
38900c5079 Fix CallbackQuery.edit for normal queries (0b4d649) 2019-04-02 08:37:24 +02:00
Lonami Exo
3398bee77a Handle disconnection errors more gracefully in background tasks 2019-04-01 08:46:07 +02:00
Lonami Exo
34a8140ff0 Fix MessageRead had blacklist_chat=None and not False
This was causing the checks against chats to fail. In addition
to that, before setting the attribute, it is now casted to bool
to prevent more issues like this in the future (or if users
use non-boolean values).
2019-03-31 12:15:48 +02:00
Lonami Exo
c95467ea3e Fix ._chat_peer could be None in Event.filter() 2019-03-31 12:15:48 +02:00
bugchecker
7225b7a40f Fix RequestIter.__anext__ without __ainit__ (#1142) 2019-03-29 18:32:00 +01:00
Lonami Exo
5377169db2 Call catch_up on reconnect (WIP for #1125) 2019-03-28 12:32:02 +01:00
Lonami Exo
ad963fd23e Don't clear pending_ack on disconnect
Upon reconnecting, we must make sure to send all `pending_ack`,
or Telegram may resend some responses (e.g. causing duplicated
updates).
2019-03-28 12:16:15 +01:00
Lonami Exo
a59f53d592 Load entities for new via_bot property and forward 2019-03-28 11:07:41 +01:00
Lonami Exo
39d9531483 Implement _load_entities for all events
Follow-up of c902428af1
This means that now input_chat (and even chat_id) and
similar can be safely used, without needing get_input
2019-03-28 10:47:15 +01:00
Lonami Exo
5554b414e1 Propagate the last error on reconnect, not always ConnectionError 2019-03-28 10:11:33 +01:00
Lonami Exo
7523869875 Except IOError and not ConnectionError
PySocks' errors do not subclass ConnectionError so the library
was unnecessarily logging them as unexpected, when any IOError
was actually expected.
2019-03-28 09:54:35 +01:00
Lonami Exo
c902428af1 getDifference if the event's chat was not found (WIP) 2019-03-27 16:21:17 +01:00
Lonami Exo
8abc7ade22 Use the new in-memory entity cache
This should avoid a disk access every time an input entity
is needed, which is very often. Another step for #1141.
2019-03-26 11:39:25 +01:00
Lonami Exo
4d35e8c80f Create a new in-memory cache for entities (#1141) 2019-03-26 11:27:52 +01:00
Lonami Exo
facf3ae582 Fix-up user_id for UserUpdate 2019-03-26 09:18:18 +01:00
Lonami Exo
0239852cc7 Fix UserUpdate in chats 2019-03-26 09:14:55 +01:00
Lonami Exo
9db9db1ade Fix UserUpdate not working for typing updates
The code to deal with the right chat action was there,
but the updates that could trigger that code path were
never checked.
2019-03-26 08:57:16 +01:00
Lonami Exo
e71638abf1 Document that now incoming private messages can be revoked 2019-03-25 08:46:44 +01:00
Lonami Exo
0b4d64947b Fix CallbackQuery.edit for messages via inline queries 2019-03-23 19:25:45 +01:00
Lonami Exo
f6fe580eb7 Safer auto reconnect to prevent double connect 2019-03-22 19:01:40 +01:00
Lonami Exo
9eabca6987 Fix run_until_disconnected's call to disconnect 2019-03-22 18:20:10 +01:00
Lonami Exo
436fb64289 Prevent double autoreconnect like #1112 2019-03-22 16:21:18 +01:00
Lonami Exo
347db79979 run_until_disconnected() should disconnect() on finally 2019-03-21 12:25:19 +01:00
Lonami Exo
04ba2e1fc7 Revert disconnect() to be async again (#1133)
It's the only way to properly clean all background tasks,
which the library makes heavy use for in MTProto/Connection
send and receive loops.

Some parts of the code even relied on the fact that it was
asynchronous (it used to return a future so you could await
it and not be breaking).

It's automatically syncified to reduce the damage of being
a breaking change.
2019-03-21 12:21:00 +01:00
Lonami Exo
8f302bcdb0 Don't disconnect() on __del__ (#1133)
Destructors are not guaranteed to run. Despite having good
intentions (saving entities even if the user forgets), it
should be the user's responsability to cleanly close the
client under any circumstances.
2019-03-21 11:40:57 +01:00
Lonami Exo
2e4476a754 Workaround #1134 by early checking if proxy closes connection 2019-03-21 11:22:09 +01:00
Lonami Exo
f6c4ab6f41 Workaround #1124 (Telegram ignoring offset_date) 2019-03-18 17:36:06 +01:00
Lonami Exo
7c48857d0c Update docs for send_file/timeouts and add new known error 2019-03-18 17:34:48 +01:00
Lonami
05e5becd78
Merge pull request #1126 from seriyps/mtproto-proxy-other-protocols
Implement different MTProto proxy protocols
2019-03-13 18:26:19 +01:00
Lonami Exo
598b9f25e1 Fix DialogsIter not passing the client to the built objects 2019-03-13 09:12:44 +01:00
Lonami Exo
9d5344e90d Fix-up file to media calls from edit (from 3d72c10) 2019-03-12 22:18:57 +01:00
Сергей Прохоров
43505e0aad
Use issubclass instead of direct class comparison 2019-03-12 20:25:33 +01:00
Сергей Прохоров
fef580c24b
Revert non-related change 2019-03-12 01:28:59 +01:00