Commit Graph

453 Commits

Author SHA1 Message Date
Dan
f6ea3e9b42
Cleaner code and some little changes
TODO: "" or None for faulty download, which is better?
2018-03-21 13:39:23 +01:00
Eric Blundell
0f4e29584a Make use of tempfile.NamedTemporaryFile in getfile, use context managers 2018-03-21 04:07:55 -05:00
Eric Blundell
b45960212b Simplify branch in download_worker exception handler 2018-03-21 03:19:09 -05:00
Dan
b6a42aa8cd
Do not mkstemp twice
Also use elif to make it less confusing
2018-03-21 09:01:18 +01:00
Eric Blundell
8796e857af Amend comment on shutil.move in download_worker
os.renames cannot move across drives/partitions on any platform.

that is why shutil.move is used, because the OS allotted temp file could
possibly be on another drive or partition.

Also fix code formatting on new import statements.
2018-03-20 23:20:08 -05:00
Eric Blundell
2cf2dd26f0
Merge branch 'master' into flexible_media_downloads 2018-03-20 22:28:42 -05:00
Eric Blundell
f0c00c8801 move first mkstemp to exception safe location in get_file 2018-03-20 16:30:48 -05:00
Eric Blundell
4c9e4df532 Amendment to comment on fdopen usage in get_file 2018-03-20 16:18:32 -05:00
Eric Blundell
cd0e585d0d Avoid calling fdopen on closed descriptor 2018-03-20 15:42:31 -05:00
Eric Blundell
5bc10b45a3 Use OS temp file, specific path download via path seperator inspection 2018-03-20 15:20:04 -05:00
Dan
aa8125d7a2 Log more info in case there is an exception in get_file #37 2018-03-20 19:27:25 +01:00
Dan
2b33f23990 Check whether get_file failed or not #37
If it failed, also delete any eventual temporary file
2018-03-20 19:25:23 +01:00
Dan
440654a63f Log info when disconnecting 2018-03-20 18:54:05 +01:00
Eric Blundell
62831001b7 Slight amendment to client.download_(media/photo) doc 2018-03-20 09:39:58 -05:00
Eric Blundell
bd1234f227 fix open file leak in client.download_media 2018-03-20 09:02:17 -05:00
Eric Blundell
0694480a46 allow file objects be passed to file_name arg of client.download_media 2018-03-20 08:33:14 -05:00
Eric Blundell
db80c72b08 Create file_name directory trees in download_worker 2018-03-20 08:27:44 -05:00
Eric Blundell
c0212a7b10 Correct default file_dir value behaviour 2018-03-20 08:20:03 -05:00
Eric Blundell
19854a5d4f Actually raise mutually exclusive arg error 2018-03-20 08:10:24 -05:00
Eric Blundell
4ae9a5ad38 Make sure file_dir is created 2018-03-20 08:05:41 -05:00
Eric Blundell
b9f623921d Make file_name and file_dir mutually exclusive 2018-03-20 07:47:38 -05:00
Eric Blundell
6bb004fc83 Add file_dir parameter to client.download_media 2018-03-20 07:34:38 -05:00
Eric Blundell
19b1bbb942 Allow download_media to download media to anywhere
Remove the use of a temporary file in the programs
working directory.
2018-03-20 07:04:35 -05:00
Dan
14a6817d12 Merge branch 'master' into min 2018-03-19 21:03:13 +01:00
Dan
2fd7cd0054 Small fix in the markdown regex 2018-03-19 21:02:54 +01:00
Dan
17f7141278 Merge branch 'master' into min 2018-03-19 19:58:32 +01:00
Dan
2deea2e4a6 Remove unused imports 2018-03-19 03:38:09 +01:00
Dan
299d6aca5c Raise ConnectionError if client is not started 2018-03-19 03:37:43 +01:00
Dan
310f9080c4 Remove unnecessary method calls 2018-03-19 01:54:45 +01:00
Dan
eecc9412b5 Merge branch 'master' into min 2018-03-19 01:53:59 +01:00
Dan
0f2dc6c624 Remove unnecessary method calls 2018-03-19 01:53:07 +01:00
Dan
9e386ed24c Remove resolve_username method 2018-03-19 01:51:47 +01:00
Dan
70ae7f0808 Fix usernames not stored in lowercase 2018-03-19 01:40:36 +01:00
Dan
390b0c12e2 Set updates_workers to 1 2018-03-19 01:08:59 +01:00
Dan
c4142753d0 Handle minified channel updates 2018-03-19 01:08:34 +01:00
Dan
5b5fb6cbec Update docstrings to accommodate joinchat links 2018-03-18 13:00:28 +01:00
Dan
cbd3b71b79 Handle mismatches in a more pythonic way 2018-03-18 12:12:27 +01:00
Dan
1d25b84cde Update invite link regex pattern 2018-03-18 11:43:51 +01:00
Dan
b45f2f4595 Add support for sending messages using joinchat links and hashes 2018-03-17 19:24:27 +01:00
Dan
1da39efa2e Update invite link regex 2018-03-17 19:13:15 +01:00
Dan
600e705d51 Add docstrings for "token" parameter 2018-03-17 19:05:18 +01:00
Dan
6c20661686 Don't use kwargs 2018-03-17 14:29:23 +01:00
Dan
6fd8b582b2 More useful logging 2018-03-16 11:30:05 +01:00
Dan
4dbf1ef5ac Improve re-connection speed 2018-03-16 11:18:16 +01:00
Dan
839f7b99f4 Call GetState for bots 2018-03-15 20:41:13 +01:00
Dan
6d536107ae Add support for bots login via token 2018-03-15 12:25:29 +01:00
Dan
756311710c Don't GetTermsOfService() anymore 2018-03-15 12:03:02 +01:00
Dan
5fc61e2fc9 Update to v0.6.3 2018-03-14 12:03:10 +01:00
Dan
3b2d264f5e Fix reference link 2018-03-14 11:01:33 +01:00
Dan
7beb611cea Update docstrings 2018-03-14 10:59:35 +01:00
Dan
f997e97494 Add support for downloading photos not contained inside a Message 2018-03-13 16:26:53 +01:00
Dan
475012144d
Increase WAIT_TIMEOUT to 30s 2018-03-13 00:21:48 +01:00
Dan
62e67f5257 Add get_messages method 2018-03-11 17:16:38 +01:00
Dan
ca54b62f63 Strip "+" away from phone numbers when logging in 2018-03-10 15:21:31 +01:00
Dan
e12a81ebb6 Attempt to fix cyclic imports 2018-03-10 10:50:51 +01:00
Dan
f26dc10ee2 Use namespace instead of importing types 2018-03-09 15:43:54 +01:00
Dan
85f92120d1 Add types to __init__.py 2018-03-09 14:59:30 +01:00
Dan
d8c634152a Update Message type 2018-03-09 14:59:08 +01:00
Dan
caf1dea227 Update Chat type 2018-03-09 14:48:13 +01:00
Dan
3d2029e9ea Update Audio type 2018-03-09 14:48:01 +01:00
Dan
7ff9f28e15 Add Video type 2018-03-09 14:47:45 +01:00
Dan
140f324cd0 Add StickerSet type 2018-03-09 14:47:36 +01:00
Dan
76b78f6a9e Add ChatPhoto type 2018-03-09 14:47:22 +01:00
Dan
345da2fccd Add UserProfilePhotos type 2018-03-09 14:47:12 +01:00
Dan
59f1fd9ee6 Add Location type 2018-03-09 14:46:58 +01:00
Dan
4d367ce04e Add ChatMember type 2018-03-09 14:46:49 +01:00
Dan
f3f462c009 Add MaskPosition type 2018-03-09 14:46:38 +01:00
Dan
4724953971 Add VideoNote type 2018-03-09 14:46:25 +01:00
Dan
24c2d20137 Add Venue type 2018-03-09 14:46:16 +01:00
Dan
281323288e Add Document type 2018-03-09 14:46:08 +01:00
Dan
35fcfe8266 Add Sticker type 2018-03-09 14:45:58 +01:00
Dan
3fa30b3a50 Add Contact type 2018-03-09 14:45:40 +01:00
Dan
33baf91a26 Add Update type 2018-03-09 14:45:27 +01:00
Dan
4e4d9e6e44 Add MessageEntity type 2018-03-09 14:45:18 +01:00
Dan
48bf7438b7 Add PhotoSize type 2018-03-09 14:45:06 +01:00
Dan
18c20f0ca5 Add Game type 2018-03-09 14:44:53 +01:00
Dan
8bd5a79643 Add Animation type 2018-03-09 14:44:43 +01:00
Dan
8216201f19 Add Voice type 2018-03-09 14:44:31 +01:00
Dan
4132a1d266 Merge branch 'master' into new-api 2018-03-09 13:28:16 +01:00
Dan
f55062bc6d Add support for Bot API style basic group IDs (with minus sign)
Closes #32
2018-03-08 12:28:38 +01:00
Dan
859305b744 Update docstrings 2018-03-08 10:34:04 +01:00
Dan
27a96a0df4 Fix progress going over 100% 2018-03-08 10:31:34 +01:00
Dan
b5c7cf781a Document the progress parameter 2018-03-08 10:25:10 +01:00
Dan
6b6122be92 Add progress parameter 2018-03-08 10:23:48 +01:00
Dan
cc49815cc5 req_pq is deprecated, use req_pq_multi instead 2018-03-08 10:14:26 +01:00
Dan
71f3e07dc1 Add more public keys 2018-03-08 10:13:04 +01:00
Dan
20ec656d91 Fix little typos 2018-03-08 10:11:47 +01:00
Dan
efd435befd
Use snake_case style 2018-03-08 10:09:03 +01:00
23rd
58eb19285e Added sending thumb with video. 2018-03-01 02:36:56 +03:00
Dan
608feac985 Update to v0.6.2 2018-02-27 20:05:11 +01:00
Dan
2e9ee6b073 Use proper client_id values 2018-02-27 18:48:30 +01:00
Dan
536efa5f4a Add get_inline_bot_results and send_inline_bot_result methods 2018-02-27 14:50:43 +01:00
Dan
333c906ac3 Always fetch peers (when applicable) 2018-02-26 15:44:08 +01:00
Dan
bce7d5b6e8 Fix signal handler not working on Windows 2018-02-25 18:43:30 +01:00
Dan
64ebf979e5 Fix file extension 2018-02-25 14:30:17 +01:00
Dan
834fff88da Remove print 2018-02-25 14:22:18 +01:00
Dan
c088018afa Move send_media_group method 2018-02-24 17:46:40 +01:00
Dan
f7a3dc2c22 Add support for phone numbers in docstrings 2018-02-24 17:45:51 +01:00
Dan
09cba224cf Document download_media 2018-02-24 17:41:11 +01:00
Dan
0353cf9588 Add send_sticker method 2018-02-24 17:24:35 +01:00
Dan
ed4ff07742 Add support for progress callback when downloading media 2018-02-24 17:16:25 +01:00
Dan
2e4802fbda Add support for downloading photos 2018-02-23 14:42:50 +01:00
Dan
87bd61ecc2 Set log level to WARNING 2018-02-23 13:59:26 +01:00
Dan
9c9a034f66 Make sure to clean temp files 2018-02-22 14:13:59 +01:00
Dan
26adfc2ef4 Add BadMsgNotification error descriptions. Fixes #26 2018-02-22 01:31:39 +01:00
Dan
28f10bd042 Make sure it's a Contacts before accessing fields 2018-02-22 11:03:48 +01:00
Dan
cfa19bc1c8 Document add_contacts and delete_contacts 2018-02-21 13:44:47 +01:00
Dan
7ee8cb7059 Document InputPhoneNumber 2018-02-21 13:44:12 +01:00
Dan
140a8b4e12 Catch RPCError in InitConnection 2018-02-21 13:35:17 +01:00
Dan
8e538199ea Log info when using a proxy 2018-02-21 13:34:27 +01:00
Dan
efbd052ec3 Add api_key and proxy parameter to the Client class
This gives users full control on how to store and load credentials.
2018-02-21 13:31:27 +01:00
Dan
a5849e9f6d Add missing notice 2018-02-21 11:51:11 +01:00
Dan
2a9da07548 Catch FloodWaits when calling GetContacts 2018-02-20 17:00:25 +01:00
Dan
5a44b93574 Accept phone numbers with and without a leading "+" 2018-02-20 15:48:10 +01:00
Dan
c5281eb963 Add ability to send messages to contacts by using their phone numbers 2018-02-20 15:28:01 +01:00
Dan
c33719be9e Call get_contacts when starting the client 2018-02-20 15:06:12 +01:00
Dan
c99bc9118b Fetch users when getting contacts 2018-02-20 15:05:17 +01:00
Dan
3ff3f5d9f4 Rewrite add_contacts and delete_contacts 2018-02-20 15:03:35 +01:00
Dan
2ab8fbe047 Add InputPhoneContact type 2018-02-20 15:01:28 +01:00
RussFP
7d72738153 add add_contacts, delete_contacts, get_contacts 2018-02-20 14:20:34 +03:00
Dan
027f843047 Fix deadlock in case the message doesn't contain any media 2018-02-19 13:43:16 +01:00
Dan
282e2bb79b Add missing notice 2018-02-19 13:25:44 +01:00
Dan
46e310722a Improve download_media 2018-02-19 13:11:35 +01:00
Dan
02da3fe947 Handle TCP server errors 2018-02-18 20:33:33 +01:00
Dan
15561d19d5 Add initial support for downloading media 2018-02-18 18:11:33 +01:00
Dan
d89d238d30 Fix BadMsgNotification error_code 32 2018-02-18 17:31:00 +01:00
Dan
3bd3d99e6a Rewrite get_file 2018-02-18 15:03:33 +01:00
Dan
aaf1b5c862 Update to v0.6.1 2018-02-17 16:29:03 +01:00
Dan
74a7adcbdd Don't use logging directly 2018-02-17 16:06:36 +01:00
Dan
87dcd4d313 Update warning 2018-02-17 15:01:09 +01:00
Dan
1bf74a9c25 Merge branch 'master' into tgcrypto 2018-02-16 18:42:43 +01:00
Dan
1db1339de8 Update to v0.6.0 2018-02-15 22:22:00 +01:00
Dan
c7b800b478 Add supports_streaming field o the InputMedia.Video object 2018-02-15 21:55:57 +01:00
Dan
a961eb88db Update docstrings 2018-02-15 21:12:42 +01:00
Dan
ad6cfcd165 Use PingDelayDisconnect instead 2018-02-15 21:06:25 +01:00
Dan
5e6361defc Set socket timeout to 10s 2018-02-15 21:06:04 +01:00
Dan
66156431ef Add Emoji module 2018-02-15 18:24:37 +01:00
Dan
e1b2fc7043 Revamp markdown parser 2018-02-15 12:05:35 +01:00
Dan
e14a3644ba Merge branch 'master' into tgcrypto 2018-02-14 17:34:21 +01:00
Dan
11bf40f50b Add new parameter supports_streaming to send_video method 2018-02-14 15:50:24 +01:00
Dan
f35babc26a Fix HTML style parser not working properly. Fixes #21 2018-02-14 08:33:14 +01:00
Dan
89200f4697 Add resolve_peer docstrings 2018-02-13 16:24:04 +01:00
Dan
78f2c9549c Modify resolve_peer to accommodate Peer* types 2018-02-13 14:28:45 +01:00
Dan
aca6fa390e Add SeqNo lock 2018-02-13 14:00:03 +01:00
Dan
560991498d Add MsgId lock 2018-02-13 13:59:29 +01:00
Dan
c6d5fb4178 Add much more detailed set_update_handler docstring 2018-02-13 13:56:09 +01:00
Dan
df89669e04 Revert back to "set_update_handler" name 2018-02-13 12:08:10 +01:00
Dan
8b7f7440b2 Remove reference 2018-02-12 16:39:57 +01:00
Dan
dc94386507 Handle pts 2018-02-11 13:19:52 +01:00
Dan
85b573d1e5 Set NET_WORKERS to 1 2018-02-10 18:28:11 +01:00