Commit Graph

1276 Commits

Author SHA1 Message Date
Lonami Exo
ea07cf8d12 Add buttons parameter to client.edit_message 2018-07-10 17:59:13 +02:00
Lonami Exo
05e8e60291 Create events.CallbackQuery 2018-07-10 17:59:13 +02:00
Lonami Exo
8eecd9c226 Reuse code to get chat and sender 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
4328663c78 Support timedelta as datetimes 2018-07-09 13:36:52 +02:00
Lonami Exo
1437b69829 Update to v1.0.4 2018-07-09 12:32:47 +02:00
Lonami Exo
1b22d0eb12 Add missing await 2018-07-08 23:44:56 +02:00
Lonami Exo
7b6e65a7a5 Re-export ConnectionHttp from the network package 2018-07-08 17:48:38 +02:00
Lonami
128053750d
Implement HTTP(S) mode (closes #112) (#883) 2018-07-08 17:45:49 +02:00
Lonami Exo
e0513e10df Remove debug print 2018-07-08 15:24:33 +02:00
Lonami Exo
3a9cce8720 Add missing async/await to events' documentation 2018-07-08 15:11:10 +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
3b3b148a43 Revert add_mark parameter on utils.get_peer_id
And a fix for -1000 IDs that wasn't being accounted for.
2018-07-07 12:44:21 +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
Lonami Exo
393e1966c7 Avoid exceeding maximum container size
This issue would likely be triggered when automatically
merging multiple requests into a single one while having
their size exceed 1044456 bytes like SaveFilePartRequest.

This commit avoids such issue by keeping track of the
current size, and if it exceeds the limit, avoid merge.
2018-07-07 11:58:48 +02:00
Lonami Exo
33ce702ab9 Pre-pack outgoing TLMessage
This has several benefits:
- The message can be resent without re-calling bytes(),
  which for some requests may be expensive.
- Converting requests to bytes early lets us detect
  errors early, such as OverflowError on bad requests.
- Containers can't exceed 1044456 bytes so knowing their
  length is important. This can now be done in O(1).

But also several drawbacks:
- If the object is modified the bytes won't reflect this.
  This isn't an issue because it's only done for in msgs.
- Incoming messages can no longer be reconverted into
  bytes but this was never needed anyway.
2018-07-07 11:46:21 +02:00
Lonami Exo
b237947af1 Update to v1.0.3 2018-07-04 15:41:11 +02:00
Lonami Exo
44630542d0 Fix MessageAction not allowing access to media
This caused some issues with events.MessageEdited because
some MessageAction can trigger these edit updates such as
scoring in a game.
2018-07-03 14:13:44 +02:00
Lonami Exo
43afdb9d77 Fix-up 53fbfb2 for InputPeerChat or others 2018-07-03 14:05:42 +02:00
Lonami Exo
53fbfb215f Fix Telegram may omit entities' access hash in updates 2018-07-02 18:43:42 +02:00
Lonami Exo
53c660d0dc Don't remove reader if fd == -1 2018-06-30 13:26:28 +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
dd0eb7a90e Explicitly open files as 'r' instead of leaving it out 2018-06-29 11:34:57 +02:00
Lonami Exo
d64eb7ea2b Avoid cyclic imports on older Python versions 2018-06-29 11:04:42 +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
0f5f6cc050 Fix opposite condition 2018-06-28 15:50:26 +02:00
Lonami Exo
cedf90eb57 Update to v1.0.2 2018-06-28 15:37:30 +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
fb40e7b508 Update mtprotoplainsender.py asserts 2018-06-28 09:48:03 +02:00
Lonami Exo
3154575ab6 Update to v1.0.1 2018-06-27 19:55:37 +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
Lonami Exo
ad01bda503 Fix custom.Message.buttons being None in channels (#870)
The implications behind this were bigger than expected. The sender
of the message is not actually needed for anything in the bot. The
bot itself may be needed, but only for KeyboardButtonSwitchInline.
2018-06-27 19:25:14 +02:00
Lonami Exo
18f06f1a25 Fix bad notification due to wrong system clock never ending 2018-06-27 19:04:33 +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
4be248932d Fix non-ending awaits due to requests not being resent on reconnect 2018-06-27 10:26:26 +02:00
Lonami Exo
58aadce5ba Fix-up 2b090f8 not actually resaving new auth_keys 2018-06-27 10:15:59 +02:00
Lonami Exo
e604960a1d Include TAKEOUT_INIT_DELAY_X in the available errors 2018-06-27 09:46:14 +02:00
Lonami Exo
75865cbaa8 Syncify async generators too 2018-06-27 09:34:35 +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
chrizrobert
1eb4af33df Fix get_entities_text with cls (#866) 2018-06-26 15:58:55 +02:00
Lonami Exo
dbb81173fa Add an assistant bot example 2018-06-26 15:48:56 +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
96e8b0b840 Remove get_fwd_sender 2018-06-26 12:38:58 +02:00
Lonami Exo
9971145721 Assert properties exist on disconnect 2018-06-26 12:03:31 +02:00
Lonami Exo
19900a373a More useful messages from authenticator.py 2018-06-26 11:32:09 +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
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