Commit Graph

2110 Commits

Author SHA1 Message Date
Dan
ec00c332c2 Update Photo file_id format 2019-08-02 02:26:42 +02:00
Dan
64939e5289 Update Document file ids to make them compatible again with the Bot API
Telegram changed something server side on 29 July, 2019 starting
exactly at 04:00 AM UTC+1 (DST), logs say. Looks like Document file ids,
just like Photo-like ids, are going to change as well after all, if we
want to keep them compatible with the Bot API
2019-08-02 01:15:01 +02:00
Dan
67112a34e9 Remove __slots__ from Pyrogram types 2019-08-02 00:33:48 +02:00
Dan
73e8b8c66e
Update read_history.py 2019-08-01 20:18:17 +02:00
Dan
aa135ea457 Reformat project 2019-08-01 19:11:43 +02:00
Dan
ad0f8284f6 Use the correct way to parse peer identifiers 2019-08-01 19:07:08 +02:00
Dan
9ad5e62dea Move all imported schema objects outside TLObject 2019-08-01 18:44:20 +02:00
Dan
d727754ad6 Remove Null primitive
It's unused
2019-08-01 18:41:04 +02:00
Dan
eddff4769c
Add missing async/await 2019-08-01 10:43:09 +02:00
Dan
b207b028dc
Merge pull request #293 from mendelmaleh/try_handler_check
Try/except handler.check()
2019-08-01 08:38:47 +02:00
Dan
47e5b9a7cb Set Message.text instead of Message.caption in case of web_page previews 2019-08-01 00:53:17 +02:00
Dan
d8765080d3
Update Filters.command
- Removed "posix" parameter because we only want posix=True and the filter becomes simpler.
- Figured out how to deal with single backslashes ("\") errors.
- Refactor the whole filter: use better names for identifiers.
- Rename parameter "prefix" to "prefixes".
2019-07-31 23:57:16 +02:00
Dan
8700e3a0f3 Fix some methods not being defined using async 2019-07-31 13:33:04 +02:00
Mendel E
b4cdf1900c Call shlex.split() only after validating cmd, try/except it. 2019-07-29 20:41:37 -04:00
Dan
0f9029202e Merge develop -> asyncio 2019-07-30 00:06:06 +02:00
Mendel E
584a6a046a Use shlex.split() for message.command
Enables easier and standard parsing, for quote wrapped args, etc.
Filters.command now has a posix argument, and the separator argument was
removed. shlex.split() works similar to having before separator=None.
2019-07-29 07:38:12 -04:00
Mendel E
02451ffeb5 Try/except handler.check()
Previously, when handler.check raised errors, it would be excepted by
the try on line 153, and would fail to loop through the rest of the
groups/handlers.
2019-07-29 07:31:07 -04:00
Dan
d875298937 Fix forward copies having "None" as caption in case of no caption at all 2019-07-29 12:16:00 +02:00
Dan
8cdcf90b10 Enhance Parser when dealing with leading and trailing whitespaces 2019-07-28 15:11:18 +02:00
Dan
e1c6e6ecc1 Better handling of non-string message texts
Now everything will be allowed and automatically casted to string. This
means that send_message(id, True) would send "True", literally.
2019-07-28 10:13:38 +02:00
Dan
bed13de413 Fix ChatPreview objects failing to parse
This happened because Telegram changed the preview photo type from
ChatPhoto to Photo. The reason behind this change was due to ChatPhoto
requiring now a peer id to be downloaded, which is not available in case
of chat previews.
2019-07-28 09:47:11 +02:00
Dan
11ea15aa08 Fix yet another compatibility issue with Path objects and Python 3.5 2019-07-28 09:32:35 +02:00
Dan
87bbd764b9 Add better summary for get_messages 2019-07-28 08:54:18 +02:00
Dan
7b9a38a2ba Fix indentation and docstrings due to bad PR 2019-07-28 08:16:41 +02:00
Dan
881f5ab783 Merge branch 'develop' of https://github.com/pyrogram/pyrogram into develop 2019-07-28 08:06:34 +02:00
Dan
2dec2442e5 Add examples to all available methods 2019-07-25 11:22:14 +02:00
Dan
fe2ccc6036 Clean up Message docstrings 2019-07-25 11:18:11 +02:00
Dan
8f56610c2c Add examples to utility methods 2019-07-25 11:17:28 +02:00
Dan
72b7a53ff5 Log to warning only in the last attempt 2019-07-25 11:15:56 +02:00
Dan
b2886c21ca Clarify get_messages error messages 2019-07-25 10:48:36 +02:00
Dan
0b66cf2cb9
Merge pull request #279 from kalmengr/patch-5
Add retract_vote bound method to Message
2019-07-22 14:22:02 +02:00
Dan
a320088fee
Fix Message.retract_vote style 2019-07-22 14:21:42 +02:00
Dan
810df3f476
Merge pull request #278 from kalmengr/patch-4
Add bound method vote to Message
2019-07-22 14:17:11 +02:00
Dan
948bba7a08
Add missing return type 2019-07-22 14:16:43 +02:00
Dan
776557f60b Refactor regex filter 2019-07-22 13:31:50 +02:00
Dan
af1bb3b0a7 Fix command filter relying on a previous command state 2019-07-22 13:31:03 +02:00
Dan
f0c1cb00ca Rework InlineQueryResultArticle. Also add *Photo and *Animation types 2019-07-21 23:18:38 +02:00
Dan
4274ef9639 Add abstract method InputMessageContent.write 2019-07-21 23:10:57 +02:00
Dan
c0e9b98cab Add is_gallery parameter to answer_inline_query and InlineQuery.answer 2019-07-21 23:10:23 +02:00
Dan
036a73997a Add new methods: add_chat_members, create_* and delete_* chats
- add_chat_members
- create_group
- create_channel
- create_supergroup
- delete_channel
- delete_supergroup
2019-07-21 23:08:30 +02:00
Dan
184f851625 Fix idle() and run() breaking after latest changes 2019-07-21 02:22:46 +02:00
Dan
6459ce0a07 Fix lots of bound methods breaking due to latest changes on parse_mode
Addresses #287
2019-07-21 01:03:19 +02:00
Dan
62a39521d9 Allow send_media_group send media from URLs 2019-07-19 13:40:12 +02:00
Dan
f2b3db47a9 Add "bot" chat type into Filters.private.
Bots are still 1-to-1 private chats
2019-07-16 07:41:11 +02:00
Dan
c30e8f9c55 Don't start the client in case run() is called with a coroutine as arg 2019-07-15 01:26:29 +02:00
Dan
4d324abbb5 Don't automatically install uvloop. Let people do that
People are reporting uvloop would crash with weird core-dumped errors
when using other asyncio libs, such as aiohttp. Plus, this was a bad
idea and people should install uvloop themselves before running their
codes.
2019-07-15 00:54:35 +02:00
Dan
9940dd678f Replace ensure_future usages to create_task 2019-07-15 00:51:32 +02:00
Elliot Manson
52902d4d43 bug fix 2019-07-14 22:23:23 +04:00
Elliot Manson
50d62259a8 start by steps 2019-07-14 13:28:49 +04:00
kalmengr
449f318e6d
Add retract_vote bound method to Message 2019-07-12 18:29:35 -04:00
kalmengr
ba47488142
Update message.py 2019-07-12 12:13:14 -04:00
kalmengr
2095f9fb5e
Add bound method vote to Message 2019-07-12 12:05:19 -04:00
Dan
385ab22b68 Rework Client.idle()
idle() is now static and doesn't stop the client anymore
2019-07-11 19:59:56 +02:00
Dan
fed8cbf87e Add new set_parse_mode utility method 2019-07-11 19:28:33 +02:00
Dan
e1197e066e Use a better name for the special plugin attribute when decorating funcs 2019-07-11 17:14:38 +02:00
Dan
5599182fd1 Fix Chat.join
The bound method will only be able to make users join public chats that
have set a username.
2019-07-11 14:42:18 +02:00
Dan
3c4a8f0da4
Merge pull request #275 from kalmengr/patch-2
Add join and leave bound methods to Chat object
2019-07-11 14:29:54 +02:00
Dan
efe564064b
Update chat.py 2019-07-11 14:29:41 +02:00
Dan
f7ba7bfd3a Update dev version 2019-07-11 04:21:02 +02:00
Dan
d5f31a8473 Update asyncio-dev version 2019-07-11 04:20:23 +02:00
Dan
d441f16879 Merge develop -> asyncio 2019-07-11 04:17:46 +02:00
Dan
7c704bbb6a Make the text parser log warnings instead of raising exceptions 2019-07-11 04:14:14 +02:00
Dan
2f07e7abc4 Rework user.status, add last_online_date and next_offline_date 2019-07-11 01:35:02 +02:00
Dan
f9ea45f987 Fix restrict_chat and restrict_chat_member combined permissions 2019-07-11 01:32:18 +02:00
Dan
997a3c1626 Remove UserStatus (user_status.py) 2019-07-11 00:12:27 +02:00
Dan
52b0988af4 Clarify default value of supports_streaming parameter (send_video) 2019-07-10 22:04:57 +02:00
Dan
d119998212 Remove get_user_dc method, add dc_id attribute to User 2019-07-10 20:20:22 +02:00
Dan
e41d21ba29 Add "md" to possible parse modes for Markdown style 2019-07-10 20:03:10 +02:00
kalmengr
be8d1068c0
Add join and leave methods to Chat object 2019-07-10 10:39:07 -04:00
Dan
6a62d1b8c4 Fix tiny typo: contact -> contacts 2019-07-09 23:51:43 +02:00
Dan
3a0d67bf0a Merge branch 'develop' of https://github.com/pyrogram/pyrogram into develop 2019-07-09 23:49:49 +02:00
Dan
92d47f17f3
Add new blank lines for clarity and for fixing rst 2019-07-09 23:39:48 +02:00
kalmengr
856870c195
Add bound methods block and unblock to User object 2019-07-09 17:33:41 -04:00
Dan
e039c1fb80 Update Client.idle() docstrings to make summary clearer 2019-07-09 20:03:03 +02:00
Dan
ee2d5b1315 Fix RPCError raising an error itself because of non-optional args 2019-07-09 19:03:37 +02:00
Dan
82efc9a154 Small documentation fix 2019-07-09 19:03:15 +02:00
Dan
13d6ce1495 Update DC IPs 2019-07-09 19:02:54 +02:00
Dan
2769f5219d Merge develop -> asyncio 2019-07-04 21:02:33 +02:00
Dan
303d0318c8 Merge remote-tracking branch 'origin/develop' into develop 2019-07-04 21:00:36 +02:00
Dan
bdd554575a Fix export_chat_invite_link not working for bots on channels/supergroups
Telegram still hasn't enabled this for bots...
Closes
2019-07-04 21:00:22 +02:00
Dan
ee1f6e2c9f Fix errors and warnings when using Pyrogram async with Python <3.5.3 2019-07-04 12:57:07 +02:00
Dan
9059bab4d0
Merge pull request #268 from mendelmaleh/develop
Add message.web_page attributes
2019-07-03 20:40:36 +02:00
Mendel E
b4a8763452 Message: media = None if WebPage is empty 2019-07-03 10:59:11 -04:00
Mendel E
f7bfd5597e Make optional values italics 2019-07-03 09:27:06 -04:00
Mendel E
dfffa9510a Add more types in WebPage docs 2019-07-02 21:04:08 -04:00
Mendel E
d363a18e84 Initial docs for WebPage 2019-07-02 10:46:08 -04:00
Mendel E
9687ef2820 flake8 errors 2019-07-02 10:00:03 -04:00
Mendel E
17a2589891 Add message.web_page attributes 2019-07-02 09:44:08 -04:00
Dan
ac4714c0dd Merge develop -> asyncio 2019-07-02 00:05:51 +02:00
Dan
18b581fb45 Update Pyrogram to v0.15.1 2019-07-02 00:03:14 +02:00
Dan
be3947e20b Fix some methods not working correctly with the new Text Parser 2019-07-02 00:01:18 +02:00
Dan
b20e0ef2d2 Merge branch 'develop' into asyncio
# Conflicts:
#	pyrogram/__init__.py
#	pyrogram/client/methods/chats/export_chat_invite_link.py
#	pyrogram/client/parser/html.py
2019-07-01 14:49:47 +02:00
Dan
544cddfd1c Update Pyrogram to v0.15.0 2019-07-01 13:44:16 +02:00
Dan
46a03a2000 Log the invalid values when raising errors 2019-07-01 13:17:16 +02:00
Dan
8e9f61148f Merge remote-tracking branch 'origin/develop' into asyncio
# Conflicts:
#	pyrogram/client/types/user_and_chats/chat.py
2019-07-01 12:30:34 +02:00
Dan
6c80064f2c Enable custom format for User mentions
Examples:
  - format(user, "mention")
  - "{:mention}".format(user)
  - f"{user:mention}"
2019-06-30 21:10:28 +02:00
Dan
a790431274 Do string conversion and striping in the Parser 2019-06-30 21:08:50 +02:00
Dan
40b0c57b54 Don't rename the in-memory sessions 2019-06-30 20:53:35 +02:00
Dan
83c386cbec Use consistent naming 2019-06-30 20:53:05 +02:00
Dan
580c684cb3 Fix export_chat_invite_link not working correctly (channels/supergroups) 2019-06-30 16:13:10 +02:00
Dan
0d6f8cd462
Merge pull request #260 from mendelmaleh/develop
Add convenience bound methods to Chat
2019-06-30 10:49:22 +02:00
Dan
09e1ac5eb4
Fix bad params when defining and calling methods 2019-06-30 10:48:19 +02:00
Dan
80d7a8cbbd
Add missing colon 2019-06-30 10:03:45 +02:00
Dan
a02cd271c9
Update chat.py 2019-06-30 10:01:39 +02:00
Mendel E
2c1834b1b2 Add .(kick|unban|restrict|promote)_member bound methods to Chat 2019-06-29 22:12:59 -04:00
Mendel E
54c8e24f48 Add .set_ bound methods to Chat 2019-06-28 17:07:38 -04:00
Dan
59b43af02e Fix RPCError not setting the x attribute 2019-06-28 20:43:06 +02:00
Dan
8c2a971fec Merge branch 'develop' into asyncio
# Conflicts:
#	pyrogram/client/methods/messages/send_document.py
2019-06-28 16:31:52 +02:00
Dan
46bf382480 Fix self.parser not calling .parse for send_document 2019-06-28 16:31:32 +02:00
Dan
d8d72395b7 Merge branch 'develop' into asyncio 2019-06-28 11:12:19 +02:00
Dan
155580649a Update filters: Make the name argument optional 2019-06-28 11:11:59 +02:00
Dan
506253e506 Fix objects failing to print in case there's no __slots__ attribute 2019-06-28 10:41:57 +02:00
Dan
fa1b66f914 Make unknown errors with known error codes inherit from base categories 2019-06-27 11:59:44 +02:00
Dan
40bcd4e59d Fix delete_profile_photos. Closes #259 2019-06-26 21:43:08 +02:00
Dan
8ef97f2177 Merge branch 'develop' into asyncio
# Conflicts:
#	pyrogram/client/methods/messages/edit_message_text.py
#	pyrogram/client/methods/messages/send_animation.py
#	pyrogram/client/methods/messages/send_audio.py
#	pyrogram/client/methods/messages/send_cached_media.py
#	pyrogram/client/methods/messages/send_document.py
#	pyrogram/client/methods/messages/send_message.py
#	pyrogram/client/methods/messages/send_photo.py
#	pyrogram/client/methods/messages/send_video.py
#	pyrogram/client/methods/messages/send_voice.py
#	pyrogram/client/parser/html.py
#	pyrogram/client/parser/markdown.py
#	pyrogram/client/types/input_message_content/input_text_message_content.py
2019-06-26 19:34:49 +02:00
Dan
39e25147bd Update parse_mode parameter docstrings 2019-06-26 16:36:24 +02:00
Dan
197cf5506c Only allow either "markdown" or "html" as text style parse mode 2019-06-26 16:36:00 +02:00
Dan
f05e79e0f4 Update usages of Parser all around the library 2019-06-26 16:08:24 +02:00
Dan
e61bf92627 Add Parser package
Revamped from HTML/Markdown
2019-06-26 16:07:27 +02:00
Dan
be5f0c9529 Parser's client can be None
In that case, check if is None and don't parse user mentions.
This happens only in text content for inline results
2019-06-26 16:06:50 +02:00
Dan
8d852cb47e Implement strict and loose markdown parsing
This is enabled by default:

  - strict: only markdown syntax is parsed
  - loose: both markdown and html syntax are parsed
2019-06-26 16:05:09 +02:00
Dan
e4a6d16cf3 Remove generated inline query result types 2019-06-26 15:56:08 +02:00
Dan
7cd145b0db Merge branch 'develop' into asyncio
# Conflicts:
#	pyrogram/client/style/html.py
#	pyrogram/client/style/markdown.py
2019-06-25 11:48:43 +02:00
Dan
7490f6cfa3 Update the HTML parser: make it easy for asyncio to deal with mentions
We can't await coroutines inside HTMLParser overridden methods, such as
handle_starttag, because they can't be async. This commit moves the
resolve_peer call into the parse method of the HTML class, which can be
defined async.
2019-06-25 11:47:45 +02:00
Dan
32ca805f6b Update message.py 2019-06-25 10:25:21 +02:00
Dan
168fce09da Implement HTML.unparse and Markdown.unparse 2019-06-25 10:24:19 +02:00
Dan
a086964e85 Make the HTML parser more sound 2019-06-25 07:41:48 +02:00
Dan
07bc7e39df Allow entities to overlap, like: <b>bold <i>and</b> italic</i> 2019-06-25 07:08:38 +02:00
Dan
df386b2f91 Make slicing text messages & captions work properly with entity offsets 2019-06-25 05:53:41 +02:00
Dan
de02848a69 Revert "Delete style utils.py and move its content inside html.py The HTML parser is now the only one that makes use of those util methods"
This reverts commit cd1e41b1
2019-06-25 05:47:57 +02:00
Dan
656aa4a7ca Enable scheduling of more than 1 updates worker 2019-06-24 17:33:33 +02:00
Dan
cd1e41b130 Delete style utils.py and move its content inside html.py
The HTML parser is now the only one that makes use of those util methods
2019-06-24 14:33:17 +02:00
Dan
a27dc575e4 Actually fix the HTML Parser feeding by calling .close() when done 2019-06-24 14:17:46 +02:00
Dan
cac0bcabf9 Fix HTML parsing breaking with no tags 2019-06-24 13:36:27 +02:00
Dan
8e0182633f Ignore any other style when inside a fixed-width style 2019-06-24 13:35:58 +02:00
Dan
f12cee5d94 Automatically escape URL bodies when using markdown 2019-06-24 10:54:58 +02:00
Dan
d6900cde9f Remove debug print() 2019-06-24 10:11:21 +02:00
Dan
e7c49c6a1b Revamp HTML and Markdown parsers to allow multiple nested entities 2019-06-24 10:07:28 +02:00
Dan
3237847ce1 Merge branch 'develop' into asyncio 2019-06-23 23:36:45 +02:00
Dan
648f37cf6d Add support for underline and strikethrough text via Markdown
New delimiters:

    - ~~strikethrough~~
    - --underline--
2019-06-23 22:43:11 +02:00
Dan
978ee4e6a6 Add new message entity types: "underline", "strike" and "blockquote" 2019-06-23 22:32:45 +02:00
Dan
0985d7ad90 Enable parsing underline, strikethrough and blockquote text for HTML 2019-06-23 22:31:55 +02:00
Dan
633e11531a Fix coroutine scheduling when adding/removing handlers 2019-06-23 13:56:12 +02:00
Dan
1e546099a3 Merge develop -> asyncio 2019-06-23 01:35:53 +02:00
Dan
31f39a00ab Make plugin callback functions return the function itself when decorated 2019-06-23 01:33:46 +02:00
Dan
84278f9cee Merge branch 'develop' into asyncio
# Conflicts:
#	pyrogram/client/ext/dispatcher.py
2019-06-22 00:49:13 +02:00
Dan
e7fffd2f76 Fix workers not running concurrently anymore after using a shared Lock 2019-06-22 00:45:49 +02:00
Dan
2ba445d21e Fix asyncio lock not being awaited properly 2019-06-21 21:48:35 +02:00
Dan
b439e44015 Fix tiny typo 2019-06-21 03:43:43 +02:00
Dan
471a124d2c Merge develop -> asyncio 2019-06-21 02:04:16 +02:00