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
f295ea668a
Make sync.syncify a public function for user types
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
fc834f60fb
Fix custom.Dialog passing the wrong instance to custom.Draft
2018-06-25 21:24:46 +02:00
Lonami Exo
d65f8ecc0d
Document the magic sync module
2018-06-25 21:14:58 +02:00
Lonami Exo
551b0044ce
Reuse more code using sqlite's cursor
2018-06-25 20:11:48 +02:00
Lonami Exo
313bead615
Close sqlite's cursor after usage
2018-06-25 19:49:33 +02:00
Lonami Exo
4da50ba3a0
Add a syncify magic module to use asyncio as sync
2018-06-25 14:24:56 +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
c1046c2acc
Fix "user joined" being "user added itself"
2018-06-25 13:21:23 +02:00
Lonami Exo
59f6b75391
Stop showing "data left after" warning
2018-06-25 12:54:33 +02:00
Lonami Exo
410518aa65
Stop using await with properties
2018-06-25 11:38:56 +02:00
Lonami Exo
0d09f9d8c1
Create a custom.Forward class
2018-06-25 11:34:10 +02:00
Lonami Exo
efc9f4c414
Get rid of all remaining async properties
2018-06-25 11:03:20 +02:00
Lonami Exo
ae47fd37b0
Update to v1.0-rc1
2018-06-24 15:51:24 +02:00
Lonami Exo
266d44dd86
Fix EventsCommon still having async properties
2018-06-24 13:05:58 +02:00
Lonami Exo
d4479a0a4e
Save the session file less often
2018-06-24 12:21:58 +02:00
Lonami Exo
184424957d
Create a separate method to start reconnections
2018-06-24 10:44:31 +02:00
Lonami Exo
0d0e78e10b
Use the right chat peer in private messages
2018-06-23 15:10:07 +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
1a1d9d346c
Fix most private messages being outgoing since 56ddaae
...
56ddaae
checked to_id and from_id to compare if they were equal,
and if they were, mark the event as outgoing for convenience in
your private chat (saved messages).
However when reconstructing the Message from UpdateShortMessage
to_id didn't mimic 100% Telegram's behaviour (the chat to which
the message is sent is "different" depending on who sent the
messages). This bug is what actually caused most messages to
be outgoing, even though 56ddaae's logic is correct.
2018-06-22 10:25:20 +02:00
Lonami Exo
8d98c04932
Fix awaits on input_chat property
2018-06-22 10:05:29 +02:00
Lonami Exo
f733f8e565
Rewrite the first part of the docs for asyncio
2018-06-21 21:54:54 +02:00
Lonami Exo
5e322a6ca9
Remove async properties from custom.Message
...
Awaiting on a property was strange and only really made sense
in events.NewMessage. Methods like client.get_messages() and
similar return entire custom.Message which won't need to touch
the network, and requiring the await was a poor UX.
2018-06-21 21:15:48 +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
5c602d4ba7
Add __str__ to RpcResult/GzipPacked
2018-06-21 09:58:12 +02:00
Lonami Exo
a99fce471a
Fix cancelling a None handle on first connection+error
2018-06-21 09:48:11 +02:00
Lonami Exo
cfa5cd0db2
Fix is_user_authorized always returning True
2018-06-21 09:32:09 +02:00
Lonami Exo
8d5c052fce
Fix TypeError when accessing unexisting sender
2018-06-21 09:26:31 +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
9e3f6483e8
Fix pattern= and move pattern_match to events.NewMessage
2018-06-20 20:03:44 +02:00
Lonami Exo
a1477a84bf
Update in-memory updates.State
2018-06-20 19:58:01 +02:00
Lonami Exo
4ab5c7d92d
Fix reconnect sentinel when not reconnecting in send_loop
...
It would cause issues with the debug logs, since it assumes it's
a TLMessage, which have an .obj attribute. Second, the send_loop
is also smarter regarding reconnects (since OSError often occur
due to not being connected at all, namely ConnectionResetError).
2018-06-20 18:19:57 +02:00
Lonami Exo
c8ee0bdca9
Fix socket may be None when closing twice
2018-06-20 17:59:11 +02:00
Lonami Exo
a0eb824e87
Support ignore_migrated in iter_dialogs
2018-06-20 12:03:42 +02:00
Lonami Exo
c893eaaa84
Allow filtering new messages by sender/forwards
2018-06-20 11:58:44 +02:00
Lonami Exo
ad1ab64415
Save last ack to resend in case of bad salt
2018-06-20 11:12:04 +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
fbf3bf119c
Separate errors needing regex from those which don't
2018-06-18 19:09:45 +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
09ea1179ca
Except msg_id KeyError on bad salt/msg
2018-06-18 17:20:31 +02:00
Lonami Exo
3648f7c756
Log outgoing message types and incoming message IDs
2018-06-18 17:14:04 +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
ee7a44d447
Return an empty list from get_entities_text if no entities
2018-06-18 13:54:09 +02:00
Lonami Exo
3c1d7d2da2
Fix MessageEmpty when searching for messages
2018-06-18 13:48:50 +02:00
Lonami Exo
7641ba2d32
Fix sleep on the wrong indent and handle CancelledError
...
This was causing a huge slow-down every time a request was
received delaying all the subsequent incoming messages too
2018-06-18 13:29:12 +02:00
Lonami Exo
374f5e2aab
Periodically send ping/getState
2018-06-18 13:22:25 +02:00
Lonami Exo
94d6c339c4
Add more logging in the MTProtoSender
2018-06-18 11:29:54 +02:00
Lonami Exo
e36aff51dd
Raise ConnectionError when sending without connection
...
Otherwise the program could potentially block on await client(...)
since this has no timeout (unless asyncio.wait_for() was used) and
would give no further hint that the program was halted there.
2018-06-17 20:25:22 +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
145d4b7105
Remove socket fd from the loop reader upon closing
2018-06-17 15:48:26 +02:00
Lonami Exo
aaa7ec757b
Support start() retrying on PasswordHashInvalidError
2018-06-17 14:07:45 +02:00
Lonami Exo
4d1272f1d2
Fix __ is invalid in usernames (cc @Kyle2142)
2018-06-17 12:08:55 +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
d18ee9ecc5
Handle (re)connection errors more gracefully
2018-06-17 11:41:35 +02:00
Lonami Exo
8086772506
Make sure not to include sentinel in containers
2018-06-16 18:40:08 +02:00
Lonami Exo
bb2cacd525
Fix automatic reconnection by unblocking the send queue
2018-06-16 18:34:36 +02:00
Lonami Exo
56ddaaee6f
Make non-fwded messages sent to yourself outgoing
2018-06-16 17:35:24 +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
b7286be3b0
Get the "correct" chat in private incoming messages
2018-06-15 12:46:41 +02:00
Lonami Exo
31c94ec184
Add a lock for resolving events
2018-06-15 10:11:43 +02:00
Dan Elkouby
df15ee421c
Except connection timeouts in MTProtoSender
2018-06-15 10:58:29 +03:00
Lonami Exo
24d2074e0c
Set _input_chat on custom.Message creation/fixup input_chat
2018-06-14 23:40:44 +02:00
Lonami Exo
091b03c635
Use create_task instead ensure_future
2018-06-14 23:33:56 +02:00
Lonami Exo
f95400ea7e
Try again to get input_chat on EventsCommon
2018-06-14 23:26:04 +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
179af9894f
Add missing parenthesis around await
2018-06-14 22:25:03 +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
1247d050ab
Remove unused fields from the Sessions
...
Most of the stuff didn't actually need to be saved and only
belong to the MTProtoState which is not a separate class from
the sessions.
2018-06-14 17:04:15 +02:00
Lonami
bb3a564500
Merge pull request #843 from LonamiWebs/core-rewrite
...
Core rewrite
2018-06-14 16:25:28 +02:00
Lonami Exo
5bb2f50232
Handle Msg state/resend/all (from 7c0af2c
by @andr-04)
2018-06-14 16:23:16 +02:00
Lonami Exo
4a9eb5b085
Handle OSError on MTProtoSender
2018-06-14 16:16:11 +02:00
Lonami Exo
df1dfdf8ea
Remove some redundant except
2018-06-14 16:13:46 +02:00
Lonami Exo
c9ea1bafc0
Apply @andr-04 asyncio commits to TcpClient
2018-06-14 16:08:23 +02:00
Lonami Exo
3ce8b17193
Dispatch updates to event handlers
2018-06-13 16:20:15 +02:00
Lonami Exo
898ce34c65
Set __all__ on telethon.__init__.py
2018-06-13 11:50:36 +02:00
Lonami Exo
a91109c9fa
Retry send_code_request on AuthRestartError
2018-06-13 10:55:37 +02:00
Lonami Exo
8a787e90c2
Remove send/recv locks
...
There is only one method sending and one method receiving,
so it doesn't make sense to lock-protect those operations.
2018-06-13 10:04:27 +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
d1afc70963
Fix setting Pong results
2018-06-12 19:46:37 +02:00
Lonami Exo
d4dc147459
Handle DraftMessageEmpty ( closes #844 )
2018-06-12 19:25:13 +02:00
Lonami Exo
2a90de2b08
Fix broadcast being named post for is_group property
2018-06-12 12:31:37 +02:00
Lonami Exo
f9cd220ddd
Implement _get_exported_sender
2018-06-11 20:05:10 +02:00
Lonami Exo
64dd957189
Fix None first_query and TcpClient.disconnect()
2018-06-11 19:51:01 +02:00
Lonami Exo
f581db294a
Better custom.MessageButton.click() docs
2018-06-11 10:25:57 +02:00
Lonami Exo
aa6d3430ae
Properly handle bot timeouts when clicking buttons
2018-06-11 10:20:22 +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
4a491e45ce
Fix broken debug call
2018-06-10 21:02:22 +02:00
Lonami Exo
d462b04a9c
Add async/await on tl.custom
2018-06-10 20:29:57 +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
Lonami Exo
d76b27058f
Warn on invoke and clean TelegramClient
2018-06-09 21:10:23 +02:00
Lonami Exo
3e151a1b7a
Make TelegramBareClient able to invoke requests
2018-06-09 21:03:48 +02:00
Lonami Exo
7e68274f26
Keep consistent structure and remove done TODO
2018-06-09 15:42:10 +02:00
Lonami Exo
acd6025731
Use put_nowait and avoid double await
2018-06-09 15:26:13 +02:00
Lonami Exo
485ce5ca3b
Ignore padding on server messages instead warning
...
There's 12..1024 padding for the MTProto 2.0 protocol, and
the length of the message can be used to determine how much
must be read on rpc_results. However this random padding
can be safely ignored.
2018-06-09 14:23:42 +02:00
Lonami Exo
be279ce3f5
Make TLMessage always have a valid TLObject
...
This simplifies the flow instead of having separate request/body
attributes, and also means that BinaryReader.tgread_object() can
be used without so many special cases.
2018-06-09 13:48:27 +02:00
Lonami Exo
f7e8907c6f
Create RpcResult class and generalise core special cases
...
This results in a cleaner MTProtoSender, which now can always
read a TLObject with a guaranteed item, if the message is OK.
2018-06-09 13:13:55 +02:00
Lonami Exo
1e66cea9b7
Reuse some more code from MTProtoState
2018-06-09 11:36:59 +02:00
Lonami Exo
adfe861e9f
Create a self-contained MTProtoState
...
This frees us from using entire Session objects in something
that's supposed to just send and receive items from the net.
2018-06-09 11:34:01 +02:00
Lonami Exo
cc5753137c
Clean-up TelegramBareClient - unnecessary?
2018-06-08 21:52:59 +02:00
Lonami Exo
a63580c350
Private methods are not public API
2018-06-08 21:18:15 +02:00
Lonami Exo
6766c4eea9
Make heavy use of logging
2018-06-08 21:13:14 +02:00
Lonami Exo
e36517845a
Retry on connection/security errors
2018-06-08 20:50:53 +02:00
Lonami Exo
92b606a3e8
Automatically reconnect on connection reset
2018-06-08 20:42:39 +02:00
Lonami Exo
5c917fb425
Except timeout error and retry
2018-06-07 18:01:18 +02:00
Lonami Exo
f72ddbdd5a
Implement retry and fail cases in authenticator
2018-06-07 17:25:02 +02:00
Lonami Exo
df895a94ab
Create auth_key if not present
2018-06-07 16:32:12 +02:00
Lonami Exo
a940e2e9a2
Process entities and add a handler for updates
2018-06-07 14:32:22 +02:00
Lonami Exo
c7e4ae8672
Send acks
2018-06-07 14:16:47 +02:00
Lonami Exo
805bf00dee
Support sending multiple requests at once
2018-06-07 14:04:04 +02:00
Lonami Exo
884dbe2d1f
Use a custom Queue to simplify the _send_loop
2018-06-07 13:51:19 +02:00
Lonami Exo
382355a22f
Collapse multiple requests into a single container
2018-06-07 13:33:32 +02:00
Lonami Exo
a3687b8bb5
Complete all methods under MTProtoSender and document them
2018-06-07 12:29:43 +02:00
Lonami Exo
0418f7e375
Fix get_entities_text and allow filtering by type
2018-06-07 10:46:32 +02:00
Lonami Exo
56b09c0c9d
Properly set future results
2018-06-07 10:30:20 +02:00
Lonami Exo
9477c75fce
Fix basic requests sending and receiving
2018-06-06 21:42:48 +02:00
Lonami Exo
e469258ab9
Create a new MTProtoSender structure and its foundation
...
This means that the TcpClient and the Connection (currently only
ConnectionTcpFull) will no longer be concerned about handling
errors, but the MTProtoSender will.
The foundation of the library will now be based on asyncio.
2018-06-06 20:41:01 +02:00
Lonami Exo
ed5c44a260
Support deleting more than 100 messages at once
2018-06-05 21:27:49 +02:00
Lonami Exo
30ad06f29a
Fix events.Raw not having ._set_client
2018-06-04 18:36:23 +02:00
Vaschuk Maxim
3db104c7bc
to_bytes() named argument 'length' removed for PyPy ( #834 )
2018-06-04 12:34:52 +02:00
Lonami Exo
2e43fb3217
More nasty hacks to fix events.NewMessage attrs
2018-06-03 17:09:36 +02:00