Commit Graph

829 Commits

Author SHA1 Message Date
Lonami Exo
057c6a0b12 Support getting more than 10k members on .get_participants()
Discussed on #580, original PR made on #639.
2018-02-28 13:24:44 +01:00
Lonami Exo
229cd78df0 Fix markdown's URL regex not acceping newlines 2018-02-27 14:10:02 +01:00
Lonami Exo
d5832e4f3b Fix time offset failing if system time was ahead of time
While the offset was working, the last message ID was never reset,
so it would always pick an higher message ID (safety check), which
completely defeated the purpose of negative time offsets. Should
close #496.
2018-02-27 11:43:42 +01:00
Joscha Götzer
0b662f3b04 Support stopping propagation of events (#622) 2018-02-27 11:30:42 +01:00
Lucas Yuji Suguinoshita Aciole
29f10f2771 Fix named arguments after kwargs (#646)
In Python3, you're unable to send named parameters after **kwargs

* Use single quotes
2018-02-27 10:05:27 +01:00
Lonami Exo
8d1b6629cb Sending open()'ed files would make their name the entire path 2018-02-26 14:14:44 +01:00
Lonami Exo
5a54e2279f Avoid relying on .__iter__ to tell iterators apart
.send_file() would fail with stream objects (those from open())
since they are iterable, and asserting that they weren't bytes
or str was not enough.
2018-02-26 14:12:21 +01:00
Lonami Exo
6f16aeb553 Add logging calls on the TcpClient 2018-02-26 13:41:07 +01:00
Lonami Exo
9604161c91 Fix incoming private messages not working with whitelists
For some reason this was only happening with bots and not
actual private messages. The fix doesn't seem to affect
previous behaviour with actual users in private messages.
2018-02-26 12:15:53 +01:00
Lonami Exo
3b0ab7794b Get name attribute from streams instead always 'unnamed' 2018-02-25 20:35:55 +01:00
Lonami Exo
623c1bd7d1 Add missing parameters to TelegramClient.send_voice_note 2018-02-25 20:34:40 +01:00
Lonami Exo
098602ca13 Let events.Raw.resolve() be a no-op 2018-02-25 10:36:53 +01:00
Lonami Exo
cfc5ecfded Fix tiny bug regarding .get_me(input_peer=True) crashing events 2018-02-25 10:35:39 +01:00
Lonami Exo
9ef75e5070 Allow specifying no event type to default to events.Raw 2018-02-24 18:25:22 +01:00
Lonami Exo
e5aecca79c Update to v0.17.4 2018-02-24 18:08:14 +01:00
Lonami Exo
3301bf3ff6 Fix voice notes default filename being "None - None.oga" 2018-02-24 17:42:32 +01:00
Kyle2142
f9cec54c39 Add .get_participants() convenience method (#639)
Closes #363 and #380.
2018-02-23 21:20:32 +01:00
Lonami Exo
a353679796 Fix downloading from another DC using wrong auth the first time 2018-02-23 13:13:39 +01:00
Lonami Exo
005a8f0a7f Fix .send_file() not respecting MessageMedia captions 2018-02-23 12:10:07 +01:00
Lonami Exo
cda5e59e86 Make .send_message() accept another Message as input 2018-02-23 12:07:57 +01:00
Lonami Exo
448a04a7c5 Stop using InputPeerSelf() on events and special case edit()
Used to fail on the chat with your own (where messages are
"incoming" instead outgoing). Now the ID of the chat and
sender are compared to achieve the same effect. Fixes #632.
2018-02-22 21:01:18 +01:00
Lonami Exo
f13a7e4afd Allow getting the input peer for yourself and cache it
Warm-up for #632, which needs this information accessible.
2018-02-22 20:37:56 +01:00
Lonami Exo
359cdcd772 Handle more parsing username cases (closes #630) 2018-02-22 10:27:12 +01:00
Lonami Exo
7f35ed59c6 Fix infinite recursion on .get_entity by exact name 2018-02-20 17:30:01 +01:00
Dmitry Bukhta
0731a1d698 Raise ProxyConnectionError instead looping forever (#621)
We shouldn't try reconnecting when using a proxy if what's
unavailable is the proxy server (and not Telegram servers).
2018-02-20 17:05:02 +01:00
Jannik
ea0da8fc0e Add pattern argument on the NewMessage event (#620) 2018-02-20 15:55:02 +01:00
Lonami Exo
4050d1ca00 Support getting entities by exact name/title match 2018-02-19 21:05:39 +01:00
Lonami Exo
c31635cc34 Further validate the username on parse_username 2018-02-19 21:03:33 +01:00
Lonami Exo
39621ceae9 Use req_pq_multi instead req_pq when creating an auth_key 2018-02-19 20:31:47 +01:00
Lonami Exo
bf086f3e80 Fix UpdateDeleteMessages doesn't have .channel_id (#619) 2018-02-19 20:23:52 +01:00
Lonami Exo
1eeedc613b Fix sending byte strings as files not working 2018-02-19 15:29:32 +01:00
Lonami Exo
b136074340 Update to v0.17.3 2018-02-19 15:29:02 +01:00
Lonami Exo
89df481ae4 Make MessageChanged.Event inherit NewMessage.Event 2018-02-18 14:07:13 +01:00
Lonami Exo
b93e1b5f50 Add add_event_handler and deprecate add_update_handler 2018-02-18 13:29:05 +01:00
Lonami Exo
1179c9e21b Fix start not asking for password if needed 2018-02-18 12:17:02 +01:00
Lonami Exo
33fd6895d3 Use hachoir to determine audio and video metadata if possible
Closes #611
2018-02-17 13:01:12 +01:00
Lonami Exo
2bfe86cda1 Fix bot_token could not be specified alone on .start() 2018-02-17 12:32:30 +01:00
Lonami Exo
d581589313 Add missing UpdateShortChatMessage case on events.NewMessage 2018-02-17 11:40:38 +01:00
Lonami Exo
6d993af338 Move events chats and blacklist_chats into the base, reuse code 2018-02-17 11:29:16 +01:00
Lonami Exo
8718cf0e7e Reuse turning chats into a set of IDs and handle self case 2018-02-17 10:41:43 +01:00
Lonami Exo
83d9d1d78e Fix markdown parser not inverting delimiters dict 2018-02-16 20:30:19 +01:00
Lonami Exo
030f292203 Dump libssl bindings in favour of the new optional cryptg module 2018-02-16 18:24:44 +01:00
Lonami Exo
c11aefa95b Fix message entities being ignored by edit_message 2018-02-16 13:42:12 +01:00
Lonami Exo
8194288797 Update to v0.17.2 2018-02-15 22:43:07 +01:00
Lonami Exo
75d99fbb53 Fix HTML entity parsing failing when needing surrogates 2018-02-15 11:52:46 +01:00
Lonami Exo
178643d3a1 Periodically send getState even without disconnect (341fb38)
After some more tests, even if the server doesn't drop the
connection, it might also just stop sending updates at all.
2018-02-15 11:41:32 +01:00
Lonami Exo
196275e9c8 Add edit and delete shorthand methods to events.NewMessage 2018-02-15 11:35:12 +01:00
Lonami Exo
62c057a058 Add edit_message convenience method and refactor to accomodate it 2018-02-15 11:19:34 +01:00
Lonami Exo
80f918956a Revert "official apps must be obfuscated" (29471f3)
It didn't really make any sense and @danog keeps changing it.
2018-02-15 10:02:12 +01:00
Dmitry D. Chernov
55bcc29ae0 Errors: Fix passing 'self' to the constructors of the superclasses
This is necessary only if the superclass name is specified explicitly instead of super() call.
2018-02-14 17:09:22 +10:00
Lonami Exo
08b9d7c4ef Add more logic to better retrieve input_sender on events 2018-02-13 10:24:35 +01:00
Lonami Exo
c83638ed0e Add further logging calls to better spot lost requests 2018-02-12 13:40:00 +01:00
Lonami Exo
9abeefac7f Send video files as video by default instead as document (#601) 2018-02-12 10:33:51 +01:00
Lonami Exo
0633e204c2 Fix whitelisting multiple chats on events not working 2018-02-11 10:30:45 +01:00
Lonami Exo
eca1e8ec87 Default to markdown parse mode on send_message
This is consistent with official clients and also provide
the expected result when replying to NewMessage events.
2018-02-10 10:45:55 +01:00
Lonami Exo
7d8d86c5f1 Support inline mentions (bot API style or username/phone) 2018-02-10 10:30:31 +01:00
Lonami Exo
6240677831 Fix sign up method not accepting integer codes 2018-02-09 19:39:20 +01:00
Lonami Exo
6261affaa1 Update to v0.17.1 2018-02-09 17:16:28 +01:00
Lonami Exo
14389a0ef2 Better document the events module 2018-02-09 15:56:42 +01:00
Lonami Exo
5167754368 Fix input_sender events' property not using cached value 2018-02-09 13:10:02 +01:00
Lonami Exo
f5eda72329 Add a new Raw Event 2018-02-09 13:08:09 +01:00
Lonami Exo
8786a52257 Add a new MessageChanged Event 2018-02-09 13:05:34 +01:00
Lonami Exo
ffe826b35f Add a new UserUpdate Event 2018-02-09 12:45:40 +01:00
Lonami Exo
379c775558 Add a new ChatAction Event 2018-02-09 11:37:17 +01:00
Lonami Exo
510bbf0fc8 Create a more reusable Event base class 2018-02-09 11:36:41 +01:00
Lonami Exo
91ba50174a Provide easier access to media through NewMessage event 2018-02-08 19:43:15 +01:00
Lonami Exo
c79fbe451f Fix NewMessage event not dropping MessageService 2018-02-07 14:06:36 +01:00
Lonami Exo
2e0a8d6bce Add respond and reply methods to the NewMessage event 2018-02-07 13:55:41 +01:00
Lonami Exo
dc43757cff Don't access NewMessage properties when building the event 2018-02-07 13:55:25 +01:00
Lonami Exo
9c09233b4f Make NewMessage's input chat/sender actual Input* if possible 2018-02-07 13:45:17 +01:00
Lonami Exo
ef837b1a53 Add a NewMessage event to handle incoming messages 2018-02-07 10:42:40 +01:00
Lonami Exo
5ec984dd82 Allow adding events with the client.on decorator 2018-02-07 10:41:58 +01:00
Lonami Exo
06bc761a5b Update to v0.17 2018-02-03 16:03:17 +01:00
Lonami Exo
fd08d53253 Trust the server will not send duplicates
This change was also suggested by the test on the previous commit.
2018-02-03 15:42:43 +01:00
Lonami Exo
341fb38136 Invoke getState after the server kicks us idling for updates
For some reason, the server seems to kick us after 1024 items from
the network are received. Tested with the following code, 1022
updates were received, after BadServerSalt, NewSessionCreated and
MsgsAck:

    client = TelegramClient(..., spawn_read_thread=False)
    client.connect(_sync_updates=False)
    sender = client._sender
    client = None
    while True:
        try:
            sender.receive(None)
        except TimeoutError:
            pass
        except ConnectionResetError:
            sender.connect()

If one were to run this code after being kicked no further items
will be retrieved and it will always timeout. Invoking a ping has
no effect either. Invoking some "high level" request like getState
seems to do the trick.
2018-02-03 15:39:37 +01:00
Lonami Exo
eefd37c2d7 Stop calling .disconnect() from .__del__()
It was causing some strange behaviour with the synchronized Queue
used by the UpdateState class. Calling .get() with any timeout
would block forever. Perhaps something else got released when
the script ended and then any call would block forever, thus the
thread never joining.
2018-02-03 12:15:38 +01:00
Lonami Exo
2ffe2b71dc Except OSError with errno.WSAEACCES when connecting
"OSError: [WinError 10013] An attempt was made to access a
socket in a way forbidden by its access permissions."
2018-02-03 11:44:05 +01:00
Lonami Exo
cf21808118 Raise error on .get_entity() on non-joined invite link 2018-02-02 17:24:12 +01:00
Lonami Exo
fbd53e2126 Override TLObject's __eq__ and __ne__ methods 2018-02-01 12:10:03 +01:00
Lonami Exo
add122bfe7 Support signing up through .start() 2018-02-01 10:12:57 +01:00
Lonami Exo
d5a91c7273 Don't set session to None on .log_out() 2018-02-01 09:39:41 +01:00
Birger Jarl
c8bbbe3e3c Save session data when migrating from JSON (#570) 2018-01-31 21:01:53 +01:00
Lonami Exo
bf56d32118 Add missing FutureSalts response special case (#81) 2018-01-30 18:32:42 +01:00
Lonami Exo
700b4c3169 Fix-up #565 with some rewording/behaviour changes
Such as not waiting unless strictly needed and better wording.
2018-01-27 21:37:57 +01:00
Matteo
067006d248 Add batch_size and wait_time to get_message_history (#565) 2018-01-27 21:29:38 +01:00
frizzlywitch
3b8365f871 Remove square braces from IPv6 addresses (#561) 2018-01-26 14:38:13 +01:00
Lonami Exo
43a3f40527 Properly close the sqlite3 connection (#560) 2018-01-26 09:59:49 +01:00
Lonami Exo
5c2dfc17a8 Make timeout logging message debug to scare people less 2018-01-25 18:44:21 +01:00
Lonami Exo
4a83784fe8 Simplify TLObject.pretty_format since Telegram returns no dicts 2018-01-25 09:51:12 +01:00
Lonami Exo
2873dcf1c6 Add '_' key to TLObject's .to_dict() and remove recursive param
Closes #559
2018-01-25 09:44:07 +01:00
Lonami Exo
db698858e0 Except TypeNotFoundError on ._invoke() 2018-01-23 22:26:19 +01:00
Lonami Exo
6c73538bd4 Fix time_offset not being used at all after BadMsgNotification
Telegram would refuse to reply any further unless the message ID
had the correct time (causing some behaviour like .connect()
never connecting, due to the first request being sent always
failing). The fix was to use time_offset when calculating the
message ID, while this was right, it wasn't in use.
2018-01-23 11:39:43 +01:00
Lonami Exo
32b92b32a7 Update .send_file() documentation (for f0eb41b) 2018-01-23 12:13:03 +01:00
Lonami Exo
58d90e7e34 Fix .download_media() not accepting Document 2018-01-23 12:10:23 +01:00
Lonami Exo
81c95b5a60 Fix recursive .get_input_media() forgetting parameters 2018-01-23 12:04:35 +01:00
Lonami Exo
f0eb41b902 Accept message/media on .send_file, remove redundancy off README 2018-01-23 11:59:35 +01:00
Tulir Asokan
5f2f04c6c2 Add HTML parse mode (#554) 2018-01-22 10:06:11 +01:00
Lonami Exo
abe26625e6 Add missing ResolvedPeer, InputNotifyPeer, TopPeer cases 2018-01-21 11:04:46 +01:00
Lonami Exo
f1371c3999 Early return from Session.get_input_entity() if Input* given 2018-01-20 19:39:48 +01:00
Lonami Exo
86816a3bdf Add missing InputChannel case on .get_input_peer() 2018-01-20 19:29:05 +01:00