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
c11aefa95b
Fix message entities being ignored by edit_message
2018-02-16 13:42: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
9abeefac7f
Send video files as video by default instead as document ( #601 )
2018-02-12 10:33:51 +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
5ec984dd82
Allow adding events with the client.on decorator
2018-02-07 10:41:58 +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
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
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
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
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
b716c4fe67
Several documentation enhancements and build warnings fixes
...
- Made the documentation even more friendly towards newbies.
- Eased the usage of methods like get history which now set
a default empty message for message actions and vice versa.
- Fixed some docstring documentations too.
- Updated the old normal docs/ to link back and forth RTD.
- Fixed the version of the documentation, now auto-loaded.
2018-01-20 11:47:17 +01:00
Lonami Exo
e3c56b0d98
Reduce autocast overhead as much as possible
...
Rationale: if the user is doing things right, the penalty for
being friendly (i.e. autocasting to the right version, like
User -> InputPeerUser), should be as little as possible.
Removing the redundant type() call to access .SUBCLASS_OF_ID
and assuming the user provided a TLObject (through excepting
whenever the attribute is not available) is x2 and x4 times
faster respectively.
Of course, this is a micro-optimization, but I still consider
it's good to benefit users doing things right or avoiding
redundant calls.
2018-01-19 13:00:17 +01:00
Lonami Exo
b546c02210
Return a custom class for sized InputFile instead extra attrs
2018-01-18 20:09:59 +01:00
Lonami Exo
0e4611a593
Properly implement InputPhoto/InputDocument caching
...
Since uploading a file is done on the TelegramClient, and the
InputFiles are only valid for a short period of time, it only
makes sense to cache the sent media instead (which should not
expire). The problem is the MD5 is only needed when uploading
the file.
The solution is to allow this method to check for the wanted
cache, and if available, return an instance of that, so to
preserve the flexibility of both options (always InputFile,
or the cached InputPhoto/InputDocument) instead reuploading.
2018-01-18 19:36:47 +01:00
Lonami Exo
1a3feec481
Move upload/download file methods to the TelegramClient
2018-01-18 13:55:03 +01:00
Lonami Exo
428abebed8
Fix sending albums failing on invalid cache
2018-01-17 13:29:08 +01:00
Lonami Exo
bfe9378054
Fix .send_file failing with strings (as they are iterable)
2018-01-17 13:28:56 +01:00
Lonami Exo
fde0d60f72
Update old interactive example ( #546 )
2018-01-16 18:36:50 +01:00
Lonami Exo
36e2101910
Allow sending multiple files as album ( closes #455 )
2018-01-15 18:15:30 +01:00
Lonami Exo
494c90af69
Fix uploaded files cache may have expired
2018-01-15 12:36:46 +01:00
Lonami Exo
00859d52c3
Ask for the phone on start only if required
2018-01-15 09:48:37 +01:00
Lonami Exo
0d429f55c5
Fix asking for phone on .start()
2018-01-13 12:00:53 +01:00
Lonami Exo
77301378f8
Make .start() more friendly by asking phone if not given
...
Ping #530
2018-01-13 11:55:12 +01:00
Joscha Götzer
80f81fe69a
Added .start() convenience method to quickly connect/authorize ( #528 )
2018-01-11 12:43:46 +01:00
Lonami Exo
8038971753
Add clear_mentions parameter to .send_read_acknowledge()
2018-01-10 12:50:49 +01:00
Lonami Exo
01820c9943
Associate phone code hash with phone (so phone can change)
2018-01-08 14:18:36 +01:00
Nikola Vlahović
0c3216cb36
Fix channel check issue on send_read_acknowledge ( #526 )
2018-01-08 12:46:47 +01:00
Lonami Exo
4871a6fb96
Accept 'me' and 'self' usernames to get self user entity
2018-01-05 19:51:44 +01:00
Lonami Exo
ec4ca5dbfc
More consistent with asyncio branch (style/small fixes)
...
Like passing an extra (invalid) dt parameter when serializing
a datetime, and handling more errors in the TcpClient class.
2018-01-05 18:31:48 +01:00
Lonami Exo
c4e26c95f5
Always cache files smaller than 10MB, now in the database
...
This removes the need for a .clear_cache() method as now files
are identified by their MD5 (which needs to be calculated
always) and their file size (to make collisions even more
unlikely) instead using the file path (which can now change).
2018-01-05 15:33:25 +01:00
Lonami Exo
a489b4b18b
Clean up some more twirks on RTD and update docstrings
2018-01-05 13:30:21 +01:00
Csaba Henk
2c437c51bb
client: add thumbnail support for send_file()
2018-01-04 12:17:47 +01:00
Csaba Henk
78871b697e
client: return the message in send_file, too
2018-01-04 12:17:47 +01:00
Lonami Exo
33d6afa0bd
Add missing L74 hash parameter to .get_message_history()
2018-01-03 19:18:24 +01:00
Lonami Exo
50d413b1c9
Fix slicing dialogs was turning UserList into list
2017-12-28 14:55:02 +01:00
Lonami Exo
55b67b65a1
Remove optional add_mark parameter from .get_peer_id
...
It was always True after all, and it made no sense for it to
be False.
2017-12-28 13:31:43 +01:00
Lonami Exo
7ed3be8e6f
Fix .get_dialogs() failing due to IDs being marked
...
Also removed utils.find_user_or_chat to prevent this from
happening again. Using a dict {marked_id: entity} is better.
2017-12-28 13:21:35 +01:00
Lonami Exo
75a342e24b
Fix .download_media() not handling Photo ( closes #473 )
2017-12-28 12:11:31 +01:00
Lonami Exo
bfff1567af
Fix up some mismatching raise/except types since 6ec6967
2017-12-28 11:55:05 +01:00
Lonami Exo
459022bdab
Return a UserList with a .total attribute for get dialogs/history
2017-12-28 11:49:35 +01:00
Lonami Exo
0755bda220
Stop returning tuples off .get_message_history()
...
Now the information is saved in the modified Message instances,
which makes it easier to use (message.sender, message.to...)
2017-12-28 02:01:22 +01:00
Lonami Exo
52a4ef82f4
Merge branch 'master' of github.com:LonamiWebs/Telethon
2017-12-28 01:17:30 +01:00
Lonami Exo
b35fc075e0
Merge branch 'sqlite-session'
2017-12-28 01:15:12 +01:00
Dmitry D. Chernov
6ec6967ff9
Make exception types correspond to Python docs
2017-12-28 09:48:02 +10:00
Lonami Exo
1a746e1464
Fix .download_profile_photo() for some channels ( closes #500 )
2017-12-28 09:48:02 +10:00
Lonami Exo
166d5a4012
Fix .get_dialogs() being inconsistent with the return type
2017-12-28 09:48:01 +10:00
Lonami Exo
bdd63b91a2
Fix .download_profile_photo() for some channels ( closes #500 )
2017-12-27 23:54:31 +01:00
Lonami Exo
292e4fc29f
Fix .get_dialogs() being inconsistent with the return type
2017-12-27 23:46:06 +01:00
Lonami Exo
f3d47769df
Fix .send_read_acknowledge() for channels ( #501 )
2017-12-27 15:26:23 +01:00
Lonami Exo
21e5f0b547
Fix GetUsersRequest has a limit of 200
2017-12-27 15:08:29 +01:00
Birger Jarl
73edb0f4ff
Avoid using None dates on file download ( #462 )
2017-12-27 14:52:33 +01:00
Lonami Exo
f96d88d3b5
Modify .get_entity to support fetching many entities at once
2017-12-27 12:36:38 +01:00
Lonami Exo
3512028d0f
Fix .get_input_entity excepting wrong type
2017-12-27 12:36:14 +01:00
Lonami Exo
5c17097d8d
Clean up .get_entity and remove force_fetch
2017-12-27 11:56:05 +01:00
Lonami Exo
aef96f1b68
Remove custom EntityDatabase and use sqlite3 instead
...
There are still a few things to change, like cleaning up the
code and actually caching the entities as a whole (currently,
although the username/phone/name can be used to fetch their
input version which is an improvement, their full version
needs to be re-fetched. Maybe it's a good thing though?)
2017-12-27 00:50:09 +01:00
Lonami Exo
238198db5a
Create a convenient class to wrap Dialog instances
2017-12-24 16:18:09 +01:00
Dmitry D. Chernov
fb9813ae61
TelegramClient.send_code_request(): Change logic of methods invocation
...
Before:
First call, force_sms=False: SendCodeRequest
Next call, force_sms=False: SendCodeRequest
First call, force_sms=True: raise ValueError
Next call, force_sms=True: ResendCodeRequest
That's inconvenient because the user must remember whether the code requested at all and whether the request was successful.
In addition, the repeated invocation of SendCodeRequest does nothing.
This commit changes logic to this:
First call, force_sms=False: SendCodeRequest
Next call, force_sms=False: ResendCodeRequest
First call, force_sms=True: SendCodeRequest, ResendCodeRequest
Next call, force_sms=True: ResendCodeRequest
2017-12-24 21:25:17 +10:00
Lonami Exo
152856dfbc
Add a force_fetch parameter to .get_entity
2017-11-20 10:58:11 +01:00
Vladislav Kolesnichenko
ee5915e86d
Add support for connecting through IPv6 ( #425 for #112 )
2017-11-16 13:30:18 +01:00
Lonami Exo
b346561f89
Remove unnecessary call to .get_input_entity()
2017-11-16 13:24:32 +01:00
Lonami Exo
5a57a8a498
Fix message history failing if sender fwd from channel
...
Closes #424
2017-11-11 19:35:57 +01:00
Lonami Exo
81baced12b
Support t.me/ links when resolving usernames/joinchat links
...
Closes #419
2017-11-10 13:27:51 +01:00
Lonami Exo
7d75eebdab
Make markdown parser use only Telegram's MessageEntity's
2017-11-10 11:07:36 +01:00
Lonami Exo
f381b26790
Add optional force_sms parameter to .send_code_request()
2017-11-04 20:46:02 +01:00
Lonami Exo
1741608f28
Use larger batches for .get_dialogs(limit=None)
2017-11-04 12:35:12 +01:00
Lonami Exo
9a12738f0e
Fix .get_message_history not working with limit=0
2017-10-31 13:52:43 +01:00
Lonami Exo
3d6c8915e3
Allow >100 limits when getting message history (implements #290 )
2017-10-31 12:52:07 +01:00
Lonami
6c2363acd2
Merge pull request #396 from LonamiWebs/md-parsing
...
Support markdown again (implements #118 )
2017-10-30 11:19:48 +01:00
Lonami Exo
7e204632e2
Add parse_mode parameter to TelegramClient.send_message()
2017-10-30 11:17:22 +01:00
Lonami Exo
6567f4b567
Clean .download_contact and a wrong indent level
2017-10-29 20:13:36 +01:00
Lonami Exo
e48f15be80
Fix-up af08d59
(missing parenthesis)
2017-10-28 11:11:51 +02:00
Tanuj
af08d59cb7
Fix bug with semicolons when downloading contacts ( #319 )
2017-10-28 11:09:46 +02:00
Lonami Exo
d7f917ebfc
Update docstrings
2017-10-21 16:59:20 +02:00
Nikolay
9907d763a8
Use peer as key instead top_message on .get_dialogs ( fix #329 )
2017-10-14 11:50:48 +02:00
88ee55
db63b5e39a
Fix .send_message not expecting UpdateNewChannelMessage ( #331 )
2017-10-13 10:53:36 +02:00
Lonami Exo
2a1a4508b8
Allow overriding DocumentAttributes on .send_file ( fix #294 )
2017-10-09 11:20:31 +02:00
Lonami Exo
4673a02ce6
Stop calling .process_entities where not needed
2017-10-09 11:20:31 +02:00
Joscha Götzer
4a482b3506
.get_drafts() and a custom Draft class ( #310 )
2017-10-09 09:54:48 +02:00
Lonami Exo
48c8837f19
Don't look on all dialogs on .get_entity miss
2017-10-08 16:25:50 +02:00
Lonami Exo
a17def8026
Use basename instead abspath for filename attribute ( #294 )
2017-10-06 21:48:53 +02:00
Lonami Exo
3bf70692b4
Fix TelegramClient.get_input_entity always failing/missing return
2017-10-06 21:43:04 +02:00
Lonami Exo
804a29d0bc
Fix get_input_entity from peer ID not actually working
2017-10-06 21:05:02 +02:00
Lonami Exo
7aa21dbd07
Fix .get_dialogs to never return more than limit
2017-10-05 13:55:58 +02:00
Lonami Exo
99cc0778bb
Allow EntityDatabase to be accessed by phone
2017-10-05 13:01:00 +02:00
Lonami Exo
e5c4df98df
Use EntityDatabase on TelegramClient.get_entity instead lru_cache
2017-10-05 12:27:32 +02:00
Joscha Götzer
6c375a7aed
Add method to .delete_messages() ( #282 )
2017-10-02 18:59:29 +02:00
3bl3gamer
0f019f0476
Rename last subclass_of_id to upper case ( #285 )
2017-10-02 13:26:55 +02:00
Lonami Exo
ba147bbe10
Fix TgClient.get_input* not calling utils.get_input* when needed
2017-10-01 21:15:49 +02:00
Lonami Exo
43f796caab
Fix .get_dialogs() failing on Windows
2017-10-01 21:02:41 +02:00
Lonami Exo
62ea77cbea
Fix opposite condition on .get_dialogs
2017-10-01 19:45:42 +02:00
Lonami Exo
269949595f
Allow phone as int on .sign_in ( #278 )
2017-10-01 19:02:53 +02:00
Lonami Exo
d30fdbe778
Support "string" peers on .get_input_entity
2017-10-01 16:59:18 +02:00
Lonami Exo
8df4d7c4a5
Internal methods should use .get_input_entity
2017-10-01 16:54:11 +02:00
Lonami Exo
1cdf879888
Fix .get_input_entity failing for chats
2017-10-01 16:53:47 +02:00
Lonami Exo
71b6e527a6
Allow using parenthesis or spaces in phones when .get_entity
2017-10-01 15:50:23 +02:00
Lonami Exo
5b6f9b6542
Add a new .get_input_entity method and use it on .get_entity
2017-10-01 14:19:04 +02:00
Lonami Exo
9445d2ba53
More enhancements on .sign_in from different clients ( #278 )
2017-10-01 11:37:18 +02:00
Lonami Exo
1d250a5441
Allow overriding phone on .sign_in ( fix #278 )
2017-10-01 11:31:26 +02:00
Lonami Exo
68e7d481f4
Add support to get all dialogs at once
2017-10-01 11:25:12 +02:00
Lonami Exo
671ac1cdb7
Fix **kwargs not being passed to TelegramBareClient
2017-09-30 18:02:08 +02:00
Lonami Exo
61033b2f56
Allow disabling spawning a second thread
2017-09-30 11:28:15 +02:00
Lonami Exo
7cef5885fa
Rename process_updates/polling to workers
2017-09-30 11:17:31 +02:00
Lonami Exo
479afddf50
Move core functionality to the TelegramBareClient
...
Rationale: the intended behaviour of the TelegramClient will now
be to focus on abstracting the users from manually importing
requests and types to work with Telegram's API. Thus, all the
core functionality has been moved to the TelegramBareClient,
which will now be responsible of spawning new threads or
connections and even handling updates.
This way there is a clear distinction between the two clients,
TelegramClient is the one meant to be exposed to the end user,
since it provides all the mentioned abstractions, while the
TelegramBareClient is the "basic" client needed to work with
the API in a comfortable way.
There is still a need for an MtProtoSender, which still even
lower level, and knows as little as possible of what requests
are. This handles parsing the messages received from the
server so that their result can be understood.
2017-09-30 10:27:46 +02:00
Lonami Exo
b61deb5cfb
Delete methods to create_new_connection and invoke_on_dc
2017-09-30 10:27:46 +02:00
Lonami Exo
0a693c705a
Create a new connection when called from a different thread
...
This allows to invoke several requests in parallel while not
waiting for other requests to be written to the network.
2017-09-30 10:27:46 +02:00
Lonami Exo
56103845de
Fix LogOutRequest consuming all retries ( #270 )
2017-09-29 13:58:15 +02:00
Lonami Exo
afc4bd9cab
Rename constructor/subclass_of_id to upper case, keep only static
2017-09-29 13:11:33 +02:00
Lonami Exo
f233110732
Allow sending several requests at once through new MessageContainer
2017-09-25 20:52:27 +02:00
Lonami Exo
c0ee123156
Add a small sleep when trying to reconnect forever
2017-09-25 11:04:09 +02:00
Lonami Exo
b04607e7ba
Ignore requests invoked from ReadThread instead raising
...
Any unhandled exception on the ReadThread would cause it to stop,
and handling the exception to the main thread on the next invoke
or poll. Instead causing the thread to stop, simply ignore it.
2017-09-23 11:31:58 +02:00
Lonami Exo
b0f6b23e52
Fix creating new connections accessing invalid attributes
2017-09-22 16:11:07 +02:00
Lonami Exo
bfa3001f87
Fix MainThread would lock when reconnecting
...
This is because it was thinking that the ReadThread would be
ready to read the result, but actually, this thread is also
locked trying to reconnect at the same time
2017-09-22 16:02:10 +02:00
Lonami Exo
6d60e83adc
Start background thread only if it was None
2017-09-22 13:13:41 +02:00
Lonami Exo
4d5f16f2aa
Fix background thread could not reconnect properly
2017-09-22 12:44:09 +02:00
Lonami Exo
4245ec5abc
Make reconnect private
2017-09-22 12:31:41 +02:00
Lonami Exo
bc15b451b5
Use a safer reconnect behaviour (respect multithread too)
2017-09-22 12:20:38 +02:00
Lonami Exo
12c6d4d3ac
Start the background thread only if the user is authorized
2017-09-21 15:36:20 +02:00
Lonami Exo
2b2da843a1
Create a Connection only once and avoid no-op if was "connected"
2017-09-21 13:44:22 +02:00
Lonami Exo
c22224f516
Attempt at handling ProxyConnectionError on .connect()
2017-09-20 13:23:52 +02:00
Lonami Exo
b8d7b1c8af
Phone number shouldn't actually start with '+'
2017-09-20 13:23:52 +02:00
jiang gau
9ae4f7f641
Fix wrong check on .send_message ( closes #250 )
2017-09-19 16:27:10 +02:00
Lonami Exo
91f44613a8
Fix SendMessageRequest could return UpdateShortSentMessage
2017-09-18 11:59:55 +02:00
Lonami Exo
143e046cf5
Attempt at passing errors to the main thread through .updates
2017-09-18 10:59:54 +02:00
Lonami Exo
e3ab98815d
Fix reconnect on TypeNotFoundError failing
2017-09-18 10:21:53 +02:00
Lonami Exo
e0e3947d2f
Fix some misleading errors/documentation
2017-09-18 09:37:20 +02:00
Lonami Exo
940dfe6816
Fix process_updates=True preventing new sessions from signing in
2017-09-17 18:13:58 +02:00
Lonami Exo
05a8723d36
Catch calling .receive() when .sender is None on recv_thread
2017-09-17 16:37:08 +02:00
Lonami Exo
73fe7258d1
Modify .send_message to return the sent message object
2017-09-13 12:00:27 +02:00
Lonami Exo
d12fb5b924
Add an optional reply_to parameter to .send_message/media
2017-09-13 11:51:23 +02:00
Lonami Exo
7043f4c9ba
Add a convenience method to send voice notes
2017-09-13 11:30:20 +02:00
Lonami Exo
a76c31ede2
Add lru_cache decorator to .get_entity()
2017-09-11 12:53:39 +02:00
Lonami Exo
83f9cafabf
Make .get_entity() public
2017-09-11 11:54:32 +02:00
Lonami Exo
188b1c8816
Fix client reconnection not actually working
2017-09-11 11:38:36 +02:00
Lonami Exo
48dead76ac
Retry up to five times before giving up on a request
2017-09-11 10:52:36 +02:00
Lonami Exo
54ba0661c6
Fix wrong variable name causing .connect() to fail
2017-09-08 18:28:31 +02:00
Lonami Exo
c81537bed0
Simplify the workflow with UpdateState exposing a single flag param
2017-09-08 12:54:38 +02:00
Lonami Exo
25bbb20b0c
Use RLocks properly on MtProtoSender (only needed on net IO)
2017-09-07 21:32:46 +02:00
Lonami Exo
16a5ab3070
Add back the periodic PingRequest
2017-09-07 21:23:37 +02:00
Lonami Exo
a24b4020fe
Allow adding update handlers without the need to poll updates
2017-09-07 20:29:51 +02:00
Lonami Exo
b8e881b6b6
Add basic updates processing to ignore updates with lower .pts
2017-09-07 20:17:40 +02:00
Lonami Exo
d237375208
Allow adding callback methods to UpdateState
2017-09-07 18:58:54 +02:00
Lonami Exo
d4f36162cd
Create and use UpdateState to .process() unhandled TLObjects
2017-09-07 18:49:08 +02:00