Commit Graph

534 Commits

Author SHA1 Message Date
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
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
9eabca6987 Fix run_until_disconnected's call to disconnect 2019-03-22 18:20:10 +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
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
Сергей Прохоров
fef580c24b
Revert non-related change 2019-03-12 01:28:59 +01:00
Lonami Exo
1b703e905c Don't set self._state when checking if logged in
This essentially made catch_up useless after .start().
cc #1125 since this affects catch_up.
2019-03-11 09:04:08 +01:00
Lonami Exo
8884015dae Clarify some docstrings 2019-03-10 13:29:34 +01:00
Сергей Прохоров
b873aa67cc
Implement different mtproto proxy protocols; refactor obfuscated2 2019-03-10 03:26:24 +01:00
Lonami Exo
3d72c10ea5 Reduce calls to utils.is_image 2019-03-06 09:38:17 +01:00
Lonami Exo
758556cd30 Fix upload_file not seeking streams back
This would cause issues in _cache_media since utils.is_image fails
in the second pass (it respects the stream's position, and the user
may rightfully pass a stream that should be read only from one pos).
2019-03-06 09:24:50 +01:00
Lonami Exo
fcfebf75a3 Prevent pillow from closing non-exclusive fps (#1121) 2019-03-06 09:14:06 +01:00
Lonami Exo
6799295115 Fix iter_participants in non-channels 2019-03-02 21:17:36 +01:00
Lonami Exo
df534585e9 Actually fix ids= not being a list, bump 1.6.1 2019-02-28 08:31:28 +01:00
Lonami Exo
2681dc09bb Fix iter_messages with ids= not being a list 2019-02-28 08:26:37 +01:00
Lonami Exo
05d174d4ce Update documentation, errors and add TODOs 2019-02-27 19:30:12 +01:00
Lonami Exo
6b50152bb3 Use constants for chunk sizes, remove irrelevant TODO 2019-02-27 13:07:25 +01:00
Lonami Exo
d02d0e2d5e Handle negative limits gracefully in async generators
We rely on >= 0 for setting the batch size to use (which must
be valid), so it makes sense to make negative limits equal 0.

This is similar to how asyncio.sleep(negative) sleeps 0 seconds,
despite the fact that time.sleep(negative) fails.
2019-02-27 13:01:04 +01:00
Lonami Exo
d508e58d49 Remove the "private" _total parameter 2019-02-27 12:59:50 +01:00
Lonami Exo
bf71e49fcc Remove batch_size parameter from iter_messages
It was only useful for testing purposes, and no other methods
exposed this kind of parameter (but they still use it).
2019-02-27 12:57:54 +01:00
Lonami Exo
b9133567af Remove weird map chr range from aggressive iter_participants 2019-02-27 12:51:09 +01:00
Lonami Exo
c73b8eda26 Simplify filling RequestIter's buffer 2019-02-27 11:25:35 +01:00
Lonami Exo
40ded93c7c Use RequestIter in chat methods 2019-02-27 11:12:05 +01:00
Lonami Exo
968da5f72d Use RequestIter in the dialog methods 2019-02-27 10:38:50 +01:00
Lonami Exo
5b8e6531fa Add method to collect RequestIter into TotalList 2019-02-27 10:15:32 +01:00
Lonami Exo
6d6c1917bc Implement iterator over message by IDs 2019-02-27 10:04:12 +01:00
Lonami Exo
60606b9994 Don't make iter_messages a coroutine function 2019-02-27 09:49:14 +01:00
Lonami Exo
35dc46ffb0 Fix searching messages in reverse 2019-02-27 09:48:47 +01:00
Lonami Exo
e3991fadd5 Fix updating offset 2019-02-27 09:37:12 +01:00
Lonami Exo
f765f73fa3 Fix setting batch size 2019-02-27 09:32:33 +01:00
Lonami Exo
e2f44ddbea Make iter_messages use a common message iterator 2019-02-27 09:31:15 +01:00
Lonami Exo
19f38d6733 Implement iter_messages with search 2019-02-26 21:04:46 +01:00
Lonami Exo
36eb1b1009 Create a new RequestIter ABC to deal with iter methods
This should make it easier to maintain these methods, increase
reusability, and get rid of the async_generator dependency.

In the future, people could use this to more easily deal with
raw API themselves.
2019-02-26 20:26:40 +01:00
Lonami Exo
1e4a12d2f7 Clean up iter_messages with reverse=True 2019-02-26 09:42:28 +01:00
Lonami Exo
5b098a909a Cleanup converting to input media in send album 2019-02-25 18:25:49 +01:00
Lonami Exo
8e36c0002b Fix sending albums with bot file IDs 2019-02-25 18:23:39 +01:00
Lonami Exo
0934f71c02 Update to layer 95 2019-02-21 12:40:47 +01:00
Lonami Exo
96270bdc18 Fix sending PNGs without alpha channel, edit size typo 2019-02-19 17:48:27 +01:00
Lonami Exo
6db60627e6 Clearer error on send_file(chat, invalid type) 2019-02-19 16:41:51 +01:00
Lonami Exo
41bfb8ae52 Fix photo resizing not working for images with alpha channels 2019-02-14 12:12:17 +01:00
Lonami Exo
d1c755809d Except RpcMcgetFailError as call fail and sleep on server errors
This one in particular may happen when iterating over messages,
perhaps more likely to happen if the group was created in a
different data center.

A small sleep of a few seconds also greatly increases the
chances of the error going away.
2019-02-14 11:00:37 +01:00
nosanity
2e544270cd Fix login failure due to wrong argument name (#1109) 2019-02-14 16:46:57 +10:00
Lonami Exo
559a40c7ea Fix get_input_media for InputFile
It was actually using FileLocation, which had the invalid expected
type for what was being returned. Instead it should have been this
other type.

In addition, more parameters are passed so that the method can have
all the information it needs to correctly cast the type.
2019-02-13 12:33:11 +01:00
Lonami Exo
5c85f830bd Further document automatic photo resizing 2019-02-13 09:58:02 +01:00
Lonami Exo
fd24f7087e Resize photos when sending files if needed 2019-02-13 09:50:00 +01:00
Lonami Exo
47d9de98ed Raise ImportError and not ValueError when sqlite3 is missing
Excepting ValueError when creating the SQLiteSession could hide
other errors (e.g. using a newer session file on an older version
of the library). Instead, the original error is raised, as if
sqlite3 was being imported within its __init__ method.
2019-02-13 08:52:54 +01:00
Lonami Exo
4899788d92 Expose phone and phone_code_hash in sign_up 2019-02-12 11:44:36 +01:00
Lonami Exo
bf11bbd8a6 Support sending bytes/stream as photos (improved _get_extension)
Letting _get_extension work for photos even when the only information
available is a stream or a few bytes allows sending arbitrary bytes
as photos, if force_document was not set to True explicitly.
2019-02-12 11:33:06 +01:00
Lonami Exo
1007e19172 Fix get_peer_id not working with InputPeerSelf 2019-02-11 10:40:35 +01:00
Dmitry D. Chernov
3b4d00564d Detail docstring about the 'proxy' parameter in TelegramClient 2019-02-11 18:54:35 +10:00
Dmitry D. Chernov
45d0ba9e2f Initial implementation of MTProxy support (#1107) 2019-02-11 00:16:46 +01:00
Dmitry D. Chernov
9a98d41a2c Improve TakeoutClient proxy and takeout functionality (#1106) 2019-02-10 11:10:41 +01:00
Dmitry D. Chernov
274fa72a8c Correctly proxy __class__ in TakeoutClient for #1103 (#1105) 2019-02-07 16:51:16 +01:00
Lonami Exo
abd26af0ad Update misleading error message 2019-02-07 10:16:03 +01:00
Dmitry D. Chernov
c8f16a4e89 Fix a couple of inconsistencies in the public interface (#1102)
* Create `_NOT_A_REQUEST` when needed. Currently, modifications    
  in the raised exception would be "global".    
* `retries` parameters were actually attempts. This has been fixed    
  to actually be the amount of retries, so 0 now means don't retry.    
* Helper function to deal with retries instead of using a range with    
  different styles every time.
2019-02-06 19:41:45 +01:00
Lonami Exo
c2c8a3caeb Saner timeouts for conversation (#1099) 2019-01-31 11:11:20 +01:00
Lonami Exo
8492300780 Fix search in private chats when from_user was not given 2019-01-31 11:11:20 +01:00
Lonami Exo
10cd61d2f9 Add missing timezone info in important places
Things like SQLAlchemy work correctly only for timezone-aware datetimes.
The returned TLObjects all have them, but those that are manually created
were missing them, so serializing the state into SQLAlchemy sessions failed.
2019-01-24 11:16:40 +01:00
Kirill
747caf1652 Support Path-like values for thumb in _file_to_media (#1095) 2019-01-22 18:52:53 +01:00
Lonami Exo
bb5c1f24c6 Update to layer 93 2019-01-21 20:09:13 +01:00
Lonami Exo
8f44364c6c Add supports_streaming to send_file and update docs/errors 2019-01-21 19:47:17 +01:00
Lonami Exo
b0883148f5 Document more RPC errors
These two occur when replying to an inline query with a photo and
InputBotInlineMessageMediaAuto empty message, and passing URLs to
PNGs that may not be accessible (i.e. 403 from pixiv).
2019-01-17 16:51:50 +01:00
Lonami Exo
09e58c4e53 Add more missing loggers parameters #1089 2019-01-15 11:09:08 +01:00
Lonami Exo
51f0bf5d84 Fully support email in edit_2fa 2019-01-14 13:57:07 +01:00
Lonami Exo
5ac88f764d Fix and update links in the documentation 2019-01-12 13:06:14 +01:00
Lonami Exo
fbf7f75b00 Fix send_message with buttons not always returning ReplyMarkup 2019-01-12 12:53:21 +01:00
Lonami Exo
ae4d4ba3ef Fix-up missing loggers from f271316 2019-01-12 12:15:29 +01:00
Tulir Asokan
f271316d7d Make logger fully configurable (#1087) 2019-01-11 15:52:30 +01:00
Lonami Exo
ca2c8687c8 Expect UserEmpty on get_input_entity 2019-01-08 10:58:58 +01:00
Lonami Exo
0a147d5b95 Add new takeout method 2019-01-05 17:18:40 +01:00
Lonami Exo
1544577757 Don't raise inside __del__ (#1073) 2019-01-04 11:26:57 +01:00
Lonami Exo
8c0250f775 Locally check dialog's offset date (#1043)
Telegram ignores the parameter if it's alone.
2019-01-03 22:35:07 +01:00
Lonami Exo
c51a17bf9a Actually make AdminLogEvent work
Ideally this would have been tested before release one commit ago.
2019-01-03 22:25:50 +01:00
Lonami Exo
eda8d0dbc8 Support configuring the reply markup through buttons 2019-01-03 19:03:47 +01:00
Lonami Exo
4ccabaf422 Add friendly method to get admin log (#952) 2019-01-03 13:09:59 +01:00
Lonami Exo
f1157b8fd1 Return downloaded bytes when file=bytes 2018-12-27 19:05:52 +01:00
Lonami Exo
fc46e1ec20 Workaround file references by using empty byte strings for cache
They seem to work for now, so until there is a need to update it,
cache will just rely on empty byte strings for the file_reference.
2018-12-25 17:02:33 +01:00
Lonami Exo
b66c1e6084 Revert "Get rid of now broken cache"
This reverts commit f73ae42a03.
2018-12-25 16:50:11 +01:00
Lonami Exo
a6c3c382b4 Except MessageIdsEmptyError when getting messages by ID
This error may occur even when the IDs are not actually empty.
2018-12-25 12:17:24 +01:00
Lonami Exo
f73ae42a03 Get rid of now broken cache 2018-12-25 11:44:10 +01:00
Aaron Gallagher
b0e0bc3701 Extend new_algo.salt1 to fix edit_2fa (#1072)
The salt1 that is sent to the server requires an additional 32 bytes
of random data. It's easy to miss this requirement from reading the 
tdesktop source, because this extension is done in a function called
`ValidateNewCloudPasswordAlgo`.

https://github.com/telegramdesktop/tdesktop/blob/2e5a0e056cdb40d61d487c6062bffe1a835f
6ddd/Telegram/SourceFiles/core/core_cloud_password.cpp#L210-L211
2018-12-24 21:16:09 +01:00
Lonami Exo
f16ed8235c Add new is_bot method to check if the logged-in user is a bot 2018-12-24 17:32:34 +01:00
Lonami Exo
ab557a8cef Use getUsers/getChannels with hash 0 on get_input_entity 2018-12-24 17:32:16 +01:00
Lonami Exo
46fea3fc93 Implement clearing password in edit_2fa 2018-12-24 16:30:45 +01:00
Lonami Exo
a623006ea0 Update 2fa code to layer 91 2018-12-24 14:10:15 +01:00
Lonami Exo
2aa089f29c Prevent KeyError in forward_messages 2018-12-20 20:33:25 +01:00
Kyle2142
d3feaeedb2 Prevent caption=None from crashing (#1071) 2018-12-20 10:50:16 +01:00
Lonami Exo
7100b75598 Update to layer 89
This breaks edit_2fa
2018-12-18 16:37:07 +01:00
Lonami Exo
7ee7b43547 Be explicit that phone numbers only work if in your contacts 2018-12-15 12:04:36 +01:00
Lonami Exo
f9fc433c0f Better catch_up behaviour when invalid states are present 2018-12-06 16:07:11 +01:00
Lonami Exo
424079aa12 Fix pts initialized as -1 not being considered 2018-12-04 21:07:18 +01:00
Lonami Exo
9a6f4d35f2 Fix crash on get_messages(ids=InputMessageReplyTo) 2018-11-29 14:19:56 +01:00
Lonami Exo
09b16f96fc Better behaviour for send_read_acknowledge 2018-11-24 20:53:28 +01:00
painor
7e168cb4fb Remove invalid mentions from message entities (#1049) 2018-11-24 19:39:05 +01:00
Lonami Exo
d6ec883cd9 Ignore iter_messages from_user unless it's a User 2018-11-19 08:55:49 +01:00
Lonami Exo
8ed3ddba31 Clarify iter_participants filter parameter in the docs 2018-11-19 08:38:31 +01:00
Lonami Exo
cdbd1f6193 Fix valid auth_key never being saved after switching DC 2018-11-03 18:53:26 +01:00
painor
45999001be Added retry_delay parameter for auto-reconnection (#1031) 2018-10-28 10:55:58 +01:00
Lonami Exo
24970a875a Fix raising PasswordHashInvalid missing request arg too 2018-10-27 09:40:30 +02:00
Lonami Exo
2863eb8cc9 Fix raising local FloodWait missing request argument 2018-10-27 09:39:00 +02:00
Lonami Exo
2c61c50671 Save session on connect and fix some typos
The session is saved upon connecting with the hope to make
sure that the authorization key gets saved to disk before
the next run.
2018-10-24 16:39:59 +02:00
Lonami Exo
4562ba9ccf Fix auth_key not actually being saved
This would make the user have to login every time.
2018-10-22 20:58:07 +02:00
Lonami Exo
740a715acd Handle empty code when starting 2018-10-21 16:05:31 +02:00
Lonami Exo
0755421fc2 Fix update loop should not disconnect causing race condition
When starting the client, on phone migrations, it would
disconnect twice right after connecting which would
trigger a not-connected error.
2018-10-21 16:02:13 +02:00
Lonami Exo
396ec908dd Fix _borrow_exported_sender connection 2018-10-20 17:11:40 +02:00
Lonami Exo
a2bae8374e Fix .get_entity('me') not working from c31635c (#1024) 2018-10-19 16:57:46 +02:00
Lonami Exo
945b34b103 Set MTProtoSender.auth_key on its creation 2018-10-19 13:56:11 +02:00
Lonami Exo
419fe6dca3 Raise RuntimeError on with blocks that need async 2018-10-17 11:30:07 +02:00
Lonami Exo
9cbc088b76 Make disconnect synchronous
This also fixes a bug when auto-reconnecting in MTProtoSender.
2018-10-16 11:56:17 +02:00
Lonami Exo
34cefed9ff Except BotMethodInvalidError on getContacts 2018-10-15 18:42:35 +02:00
Lonami Exo
0094eb391e Support exclusive conversations by default 2018-10-12 22:17:07 +02:00
Lonami Exo
cf6686ff42 Revert async sessions from 3dd8b7c (breaks sync properties)
Such as ChatGetter.input_chat and SenderGetter.input_sender
which rely on the fact that access to the session file will
be synchronous.
2018-10-12 22:00:02 +02:00
Lonami Exo
e677a6bb05 Fix is_user_authorized after log_out 2018-10-12 19:57:16 +02:00
Lonami Exo
32c884d543 Revert d392939 and use empty tuple as a sentinel value 2018-10-08 11:33:56 +02:00
Lonami Exo
8c14259728 Update documentation with new sections 2018-10-06 20:20:11 +02:00
Lonami Exo
fb9660afe0 Add missing awaits 2018-10-06 12:39:07 +02:00
Lonami Exo
67be6418b6 Remove callback parameter from custom.Button
Its behaviour was strange. Removing and adding an event
handler every time a message is sent is not a good idea
and it would just do more harm than good.
2018-10-05 20:54:50 +02:00
josephbiko
3dd8b7c6d1 Support async def in sessions (#1013) 2018-10-05 20:25:49 +02:00
Lonami Exo
d392939018 Create a default module to use as a sentinel value
This looks better in the documentation than utils.Default,
cleans the utils with specific stuff like this, and users
may use it more easily.
2018-10-05 14:20:50 +02:00
Lonami Exo
aa3f26263c Fix timeout not accepting timedelta 2018-10-05 14:06:15 +02:00
Lonami Exo
ebde3be820 Add support for proxy again 2018-10-05 13:26:44 +02:00
Lonami Exo
db83709c6b Support connection timeout 2018-10-05 13:26:44 +02:00
Lonami Exo
cf7e5d5592 Set auth_key on connection 2018-10-05 13:26:44 +02:00
Lonami Exo
21ffa2f26b Fix DC migration and seqno 2018-10-05 13:26:44 +02:00
Lonami Exo
9402b4a26d Create a new layer to lift encryption off the MTProtoSender 2018-10-05 13:26:44 +02:00
Lonami Exo
5daad2aaab Actually use the new connection class 2018-10-05 13:26:44 +02:00
Lonami Exo
ec0aa65fe1 An user -> a user 2018-09-22 19:18:42 +02:00
Lonami Exo
d5d3733fd4 Create events.register and siblings for "handler templates"
This can be thought of as a different approach to Flask's blueprints.
2018-09-22 12:51:58 +02:00
Lonami Exo
cb6f980277 Better autocast to InputPeerDialog and documentation 2018-09-22 10:56:37 +02:00
Lonami Exo
9275a9fcbb Fix several typos and misleading docs (#987, #990) 2018-09-19 17:51:18 +02:00
Lonami Exo
db8bea3968 Fix getting messages by ID for private chats 2018-09-16 15:45:38 +02:00
Lonami Exo
080585da49 Support coroutine callbacks in start() 2018-09-09 16:17:20 +02:00
Lonami Exo
ae085f30a8 Save update state upon disconnect 2018-09-04 11:58:55 +02:00
Lonami Exo
bbeb8f4ba3 Clarify and fix some docstrings 2018-09-04 11:27:10 +02:00
Lonami Exo
8a9650f131 Fix-up previous commit 0bb0d0b missing parameter 2018-08-27 10:58:06 +02:00
Lonami Exo
576ac666d9 Fix resolving events while disconnected 2018-08-27 01:20:01 +02:00
Lonami Exo
5ca1edb228 Return the correct entity from .get_entity(username)
The precedence of the or operator made the check succeed always
out of pure luck, since `''.lower()` would never be the chosen
username, but a present username is truthy.

This presumably worked because Telegram only returns one result
from the call, or puts the right entity the first one.
2018-08-26 12:00:17 +02:00
s3mple
29d122e810 Fix-up previous commit f17d7e9 (#967) 2018-08-24 19:50:55 +02:00
s3mple
f17d7e9c5e New exception class for multiple errors (#965) 2018-08-24 18:25:58 +02:00
s3mple
aa9bc9080f Support custom symbol set for aggressive get_participants 2018-08-21 17:15:35 +02:00
Lonami Exo
d3a6822fc9 Properly resolve events 2018-08-21 12:18:12 +02:00
Lonami Exo
47190d7d55 Fix event loop not being passed into many asyncio calls 2018-08-21 11:31:14 +02:00
Lonami Exo
d474458136 Simplify event resolving logic
Although this commit introduces a race condition since an
event may only be half-resolved. A lock is thus needed,
but it depends on an event-loop to which we don't have
access in the class-level.
2018-08-21 11:08:08 +02:00
Lonami Exo
9f237cc928 Simplify event building logic
This will also fix some bugs where the event type being accessed
would not be available, since it is now built on-demand, without
the need to keep track for the count of each event type.
2018-08-21 10:27:12 +02:00
Lonami Exo
dda1f0b1dd Stop copying reply when resending Message, fix file replies 2018-08-19 11:49:36 +02:00
Lonami Exo
7efa53fedf Update to v1.2 2018-08-14 18:48:56 +02:00
Lonami Exo
653686996a Revisit catch_up (#808) 2018-08-13 12:32:12 +02:00
Lonami Exo
e3bf6e3330 Document reply markup limits 2018-08-07 12:46:05 +02:00
Lonami Exo
9195bccb41 Fix sending files from disk after 6d1bc22 (#941 and #943) 2018-08-06 18:03:42 +02:00
Lonami Exo
48113851a8 Fix built Conversation events don't have the client 2018-08-05 02:01:06 +02:00
Lonami Exo
ca40a9c282 Add Conversation.wait_event 2018-08-05 01:55:41 +02:00
Nikolay Tretyak
d0c566bbdb Fix iter_participants is failing when _total is None (#936) 2018-08-04 11:30:24 +02:00
Lonami Exo
785ef7676f Create a basic custom.Conversation 2018-08-03 17:51:56 +02:00
Lonami Exo
60c61181d9 Return custom.InlineResults instead of a simple list 2018-08-02 23:31:51 +02:00
Lonami Exo
7cce7aa3e4 Return helpers.TotalList instances on client.get_ methods 2018-08-02 23:00:10 +02:00
Lonami Exo
7a7923b317 Fallback to MemorySession if sqlite3 is not available 2018-08-02 15:17:44 +02:00
Lonami Exo
328f737ef7 Support custom.MessageButton as buttons reply markup 2018-08-02 13:17:59 +02:00
Lonami Exo
80a5e709cb Support .download_media with bot API file_id 2018-08-01 13:40:07 +02:00
Lonami Exo
e359b428c3 Merge branch 'inlineresult' 2018-08-01 01:06:59 +02:00
Lonami Exo
7a2d7d98ad Implement client.inline_query() 2018-08-01 01:06:47 +02:00
Lonami Exo
76c7217000 Support downloading web documents 2018-08-01 00:37:25 +02:00
Lonami Exo
6d1bc227aa Support bot API file_id on send_file 2018-07-31 23:35:22 +02:00
Lonami Exo
f0a26d7c76 Implement global search (closes #920) 2018-07-29 23:16:22 +02:00
Lonami Exo
f2c8663266 Fix copy pasted docs and snake_case files 2018-07-28 11:28:02 +02:00
Lonami Exo
26f121060d Always support aggressive in iter_participants (#904) 2018-07-25 12:40:49 +02:00
Lonami Exo
6c51c35ccf Fix _iter_ids not expecting InputChannel 2018-07-24 18:20:34 +02:00
Lonami Exo
1c0d595205 Replace custom.Message creation with ._finish_init 2018-07-22 19:20:55 +02:00
Lonami Exo
e4963237dc Fix-up a332d29 should not be exported on invalid DC 2018-07-22 01:08:03 +02:00
Lonami Exo
a332d29c4c Fix-up 5a9a00e to handle exporting senders to the same DC 2018-07-22 00:40:39 +02:00
Lonami Exo
46b2d910d7 Fix logging of functools.partial() callbacks 2018-07-21 17:52:42 +02:00
Lonami Exo
3bdfd4b32c Make build_reply_markup public 2018-07-21 13:55:26 +02:00
Lonami Exo
7750c9ff2f Make sure to not add callbacks from buttons= twice 2018-07-21 13:24:32 +02:00
Lonami Exo
24758b82ec Don't make a request at all if it will trigger flood wait 2018-07-21 12:25:20 +02:00
Lonami Exo
a9cc35e604 Avoid triggering FileMigrateError when possible 2018-07-21 11:59:44 +02:00
Lonami Exo
5a9a00e7ae Assume exported auths last forever
This implies that export senders will NOT be deleted from
memory once all borrows are returned, thus their auth_key
remains as well. When borrowing them if they existed they
will be connect()ed if it's the first borrow.

This probably fixes #901.
2018-07-21 11:24:20 +02:00
Lonami Exo
2d7c8908eb Create events.InlineQuery 2018-07-15 11:31:24 +02:00
Lonami Exo
22c8fd7378 Fix Updates object being dispatched to user handlers 2018-07-12 09:45:29 +02:00
Lonami Exo
1d0fd6801d Build events only once per update 2018-07-11 11:22:43 +02:00
Lonami Exo
81f31e09c8 Keep track of how many events for each type were added 2018-07-11 10:50:19 +02:00
Lonami Exo
e902304360 Expose silent parameter when sending messages 2018-07-11 10:16:21 +02:00
Lonami Exo
a3d6baf408 Actually add callbacks registered through Button 2018-07-10 19:50:18 +02:00
Lonami Exo
ea07cf8d12 Add buttons parameter to client.edit_message 2018-07-10 17:59:13 +02:00
Lonami Exo
531a02a2a1 Support buttons when sending a file too 2018-07-10 17:59:13 +02:00
Lonami Exo
8c28be04bc Create a custom.Button class and support send_message(buttons=...) 2018-07-10 17:59:13 +02:00
Lonami Exo
a50d013ee6 Support interactively signing in as a bot 2018-07-10 17:59:13 +02:00
Lonami
ac5f8da50c
Fix update.pts may be None 2018-07-10 16:59:40 +02:00
josephbiko
e6981e7676 Remove empty except (#887) 2018-07-09 20:54:43 +02:00
Lonami Exo
e0513e10df Remove debug print 2018-07-08 15:24:33 +02:00
Lonami Exo
d02cb84abe Fix end of sync with block warning on disconnect 2018-07-08 00:05:09 +02:00
Lonami Exo
54bffb30d8 Fix send_message('me', Message) 2018-07-08 00:05:09 +02:00
Lonami Exo
cb3846cb7f Add client.get_peer_id 2018-07-07 12:45:50 +02:00
Lonami Exo
bb4ed4019f Revert forward_messages requiring named from_peer arg 2018-07-07 12:14:50 +02:00
Lonami Exo
bd878acbde Support InputNotifyPeer autocast 2018-07-07 12:14:03 +02:00
Lonami Exo
dfda61a1b5 Correct thumb parameter documentation 2018-07-07 12:01:42 +02:00
Harry
dfcf414111 Fix hachoir don't close files by itself (#875) 2018-06-29 16:45:18 +02:00
Lonami Exo
baedd10110 Update to layer 82 2018-06-29 13:23:56 +02:00
Lonami Exo
3c2ff45b0b Support dispatching updates in a sequential order 2018-06-29 10:45:04 +02:00
Lonami Exo
0f737a86af Revert sign_in needing named code argument 2018-06-29 09:57:57 +02:00
Lonami Exo
dbca38c6f5 Allow iterating over messages in reverse 2018-06-28 21:15:29 +02:00
Lonami Exo
ac6dbb8a5c Fix is_connected accessing unexisting property 2018-06-28 16:04:12 +02:00
Lonami Exo
ac2b10f2a5 Stop using loop's time() function 2018-06-28 15:12:18 +02:00
Lonami Exo
491302bb32 Fix parallel downloads when using exported senders 2018-06-28 14:10:36 +02:00
Lonami Exo
a6782ac6ea Send getState upon successful reconnection 2018-06-27 19:40:32 +02:00
Lonami Exo
c0412e4410 Fix run_until_disconnected disconnect with telethon.sync 2018-06-27 19:39:47 +02:00
Inokenty
f014c040a3 Keyword arg instead positional for sign_in (#869) 2018-06-27 17:23:46 +02:00
Lonami Exo
a46a45d060 Don't disconnect on del if already disconnected/loop closed 2018-06-27 13:57:17 +02:00
Lonami Exo
72835dfb44 Update to v1.0 2018-06-27 13:41:20 +02:00
Lonami Exo
58aadce5ba Fix-up 2b090f8 not actually resaving new auth_keys 2018-06-27 10:15:59 +02:00
Lonami Exo
8c5bbdf7eb Check from_user client-side for PMs in iter_messages 2018-06-26 16:48:03 +02:00
Lonami Exo
09ea8ffe0b Fix send_file completely ignoring input parameters 2018-06-26 16:39:43 +02:00
Lonami Exo
2bd0c6c525 Support URLs on send_file 2018-06-26 16:39:22 +02:00
Lonami Exo
2b090f8888 Fix connect not saving different authkeys 2018-06-26 16:20:30 +02:00
Lonami Exo
9159e2a720 Remove report_errors/flood_sleep_threshold from the session 2018-06-26 16:09:16 +02:00
Lonami Exo
6152e33454 Fix sync run_until_disconnected not liking Ctrl+C 2018-06-26 15:48:38 +02:00
Lonami Exo
f6bfcad49e Don't close session file on _switch_dc disconnect 2018-06-26 13:37:34 +02:00
Lonami Exo
3556d5ed79 Fix-up 9971145 still accessing unexisting properties 2018-06-26 13:15:25 +02:00
Lonami Exo
9971145721 Assert properties exist on disconnect 2018-06-26 12:03:31 +02:00
Lonami Exo
32786d16fd Support using the client in with blocks 2018-06-26 11:26:01 +02:00
Lonami Exo
d4b508bf48 Fix __del__ with sync magic 2018-06-26 11:23:51 +02:00
Lonami Exo
75dc4809f5 Remove all deprecated methods 2018-06-26 11:10:11 +02:00
Lonami Exo
a43c6c2b68 Work around Python 3.5.2 bug causing 100% CPU load on script's end 2018-06-26 11:10:11 +02:00
Lonami Exo
044e6e8a85 Await updates task to finish upon disconnect 2018-06-26 11:10:11 +02:00
Lonami Exo
9c6d2894fc Allow start when the loop is not running 2018-06-25 13:42:29 +02:00
Lonami Exo
db5cb74bdd Allow run_until_disconnected when the loop is running 2018-06-25 13:32:31 +02:00
Lonami Exo
d4479a0a4e Save the session file less often 2018-06-24 12:21:58 +02:00
Lonami Exo
51da48ddd2 Support custom parse_mode to use MessageEntityMentionName 2018-06-22 16:18:23 +02:00
Lonami Exo
3d3698562b Cleanly handle KeyboardInterrupt in run_until_disconnected 2018-06-22 13:26:24 +02:00
Lonami Exo
3973755333 Support .name attr in utils.is_type/client.upload_file
This means open()'ed files will have their name used properly,
and that you can set b.name = 'somename.jpg' to io.BytesIO()
objects to have them uploaded as images.
2018-06-21 16:31:03 +02:00
Lonami Exo
d8af64e3b9 Clarify/fix get[_input]_entity docstrings 2018-06-21 11:08:14 +02:00
Lonami Exo
cfa5cd0db2 Fix is_user_authorized always returning True 2018-06-21 09:32:09 +02:00
Lonami Exo
d6818f25f5 Fix rare iter_dialogs infinite loop 2018-06-20 21:12:47 +02:00
Lonami Exo
9c0a22ddd7 Fix Python 3.5 compatibility 2018-06-20 20:18:16 +02:00
Lonami Exo
a1477a84bf Update in-memory updates.State 2018-06-20 19:58:01 +02:00
Lonami Exo
a0eb824e87 Support ignore_migrated in iter_dialogs 2018-06-20 12:03:42 +02:00
Lonami Exo
c85ba4accc Revisit documentation, cross-references and unnecessary indents 2018-06-20 11:06:03 +02:00
Lonami Exo
4e9a84c3b5 Remove underscore from module names 2018-06-18 21:02:42 +02:00
Lonami Exo
262018959f Process entities from sent requests/updates 2018-06-18 20:44:20 +02:00
Lonami Exo
463847ad50 Revisit and remove a few TODOs 2018-06-18 18:46:06 +02:00
Lonami Exo
ebfe8ebf40 Configurable per-client request/connection retries 2018-06-18 18:13:00 +02:00
Lonami Exo
51d8ea0fa8 Shield disconnected Future in the MTProtoSender instead 2018-06-18 15:55:24 +02:00
Lonami Exo
efc48ee3b0 Shield self.disconnected and log RpcCallFail 2018-06-18 14:28:30 +02:00
Lonami Exo
3c1d7d2da2 Fix MessageEmpty when searching for messages 2018-06-18 13:48:50 +02:00
Lonami Exo
374f5e2aab Periodically send ping/getState 2018-06-18 13:22:25 +02:00
Dan Elkouby
d5b349e031 Implement a mechanism to notify of connection failures (#852) 2018-06-17 19:29:41 +02:00
Lonami Exo
d9d586171f Fix MTProtoSender should not send content-related queries 2018-06-17 16:23:22 +02:00
Lonami Exo
aaa7ec757b Support start() retrying on PasswordHashInvalidError 2018-06-17 14:07:45 +02:00
Lonami Exo
b65cbd8647 Validate to_id when iterating over messages by ID 2018-06-17 11:57:11 +02:00
Lonami Exo
226c35ff8f Pump up default timeout from 5 to 10s 2018-06-17 11:46:56 +02:00
Lonami Exo
7cfecfaf21 Support pathlib.Path on download/upload 2018-06-16 17:01:20 +02:00
Lonami Exo
cbd5594dba Use the correct clock time when sleeping on iter_messages 2018-06-15 17:09:16 +02:00
Lonami Exo
509fba8bcc Fix-up isinstance/is_user_authorized from 06cdf1f 2018-06-15 13:01:16 +02:00
Lonami Exo
31c94ec184 Add a lock for resolving events 2018-06-15 10:11:43 +02:00
Lonami Exo
091b03c635 Use create_task instead ensure_future 2018-06-14 23:33:56 +02:00
Lonami Exo
06cdf1fdb0 Raise on phone/network migrate if authorized 2018-06-14 23:16:00 +02:00
Lonami Exo
c788e17c22 Fix _handle_update not expanding Updates 2018-06-14 22:51:57 +02:00
Lonami Exo
0f14f3b16a Support custom event loops 2018-06-14 19:35:12 +02:00
Lonami Exo
908dfa148b Revisit codebase to add missing async/await 2018-06-14 17:09:20 +02:00
Lonami Exo
3ce8b17193 Dispatch updates to event handlers 2018-06-13 16:20:15 +02:00
Lonami Exo
a91109c9fa Retry send_code_request on AuthRestartError 2018-06-13 10:55:37 +02:00
Lonami Exo
3324090c96 Fix non-asyncio sleep 2018-06-13 09:59:30 +02:00
Lonami Exo
3f16c92eb3 Subclass TLRequest for content-related objects 2018-06-12 20:14:21 +02:00
Lonami Exo
f9cd220ddd Implement _get_exported_sender 2018-06-11 20:05:10 +02:00
Lonami Exo
f86f52d960 Fix async_generator's and missing awaits 2018-06-10 22:00:55 +02:00
Lonami Exo
8be6adeab4 Make use of the async_generator module 2018-06-10 21:50:28 +02:00
Lonami Exo
15ef302428 Implement _switch_dc/fix missing first request 2018-06-10 21:30:31 +02:00
Lonami Exo
1bde72d375 Make the TelegramClient aggregate all client methods 2018-06-10 19:05:36 +02:00
Lonami Exo
fb8b052754 Separate update requests from the TelegramClient 2018-06-10 13:58:21 +02:00
Lonami Exo
ac2e59b472 Separate auth requests from the TelegramClient 2018-06-10 12:57:36 +02:00
Lonami Exo
4ff0756ffc Separate download requests from the TelegramClient 2018-06-10 12:04:23 +02:00
Lonami Exo
317b7053a0 Separate parse message methods from uploads 2018-06-10 11:33:20 +02:00
Lonami Exo
83a024656c Rename client.files as client.uploads 2018-06-09 22:14:51 +02:00
Lonami Exo
ad29f2f5b7 Separate chat requests from the TelegramClient 2018-06-09 22:13:18 +02:00
Lonami Exo
1e91e5a83c Separate dialogs methods from the TelegramClient 2018-06-09 22:09:02 +02:00
Lonami Exo
4bd20f1ce2 Separate file and message methods from TelegramClient 2018-06-09 22:05:06 +02:00
Lonami Exo
bb9b9796e0 Separate user methods from the base client 2018-06-09 21:22:54 +02:00
Lonami Exo
4b147f0153 Move clients to a new package 2018-06-09 21:11:35 +02:00