Merge branch 'pyrogram:master' into mtpager

This commit is contained in:
Sam 2022-02-02 17:41:08 +08:00 committed by GitHub
commit b472597fbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 736 additions and 558 deletions

View File

@ -1,28 +0,0 @@
---
name: Bug Report
about: Create a bug report affecting the framework or the documentation
---
<!-- WARNING: Ignoring or altering this template could lead to the issue being closed as invalid -->
## Checklist
- [ ] I am sure the error is coming from Pyrogram's code and not elsewhere.
- [ ] I have searched in the issue tracker for similar bug reports, including closed ones.
- [ ] I ran `pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip` and reproduced the issue using the latest development version.
## Description
A **clear** and **concise** description of the problem. Code snippets must be
[minimal, reproducible](https://stackoverflow.com/help/minimal-reproducible-example) and properly formatted.
``` python
from pyrogram import Client
...
```
## Traceback
The full traceback (if applicable).
```
Traceback (most recent call last):
File "main.py", line 1, in <module>
```

51
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: Bug report
description: Report issues affecting the framework or the documentation
body:
- type: checkboxes
attributes:
label: Checklist
options:
- label: I am sure the error is coming from Pyrogram's code and not elsewhere
required: true
- label: I have searched in the issue tracker for similar bug reports, including closed ones
required: true
- label: I ran `pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip` and reproduced the issue using the latest development version
required: true
- type: textarea
attributes:
label: Description
description: Provide a clear and concise description of the issue
placeholder: Description...
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: Explain precisely how to reproduce the issue
placeholder: |
1.
2.
3.
validations:
required: true
- type: textarea
attributes:
label: Code example
description: Provide a [minimal, reproducible](https://stackoverflow.com/help/minimal-reproducible-example) and properly formatted example (if applicable)
placeholder: |
from pyrogram import Client
...
render: python
- type: textarea
attributes:
label: Logs
description: Provide the complete traceback (if applicable)
placeholder: |
Traceback (most recent call last):
File "main.py", line 1, in <module>
...
render: shell

View File

@ -1,14 +0,0 @@
---
name: Feature Request
about: Suggest ideas, new features or enhancements
labels: "enhancement"
---
<!-- WARNING: Ignoring or altering this template could lead to the issue being closed as invalid -->
## Checklist
- [ ] I believe the idea is awesome and would benefit the framework.
- [ ] I have searched in the issue tracker for similar requests, including closed ones.
## Description
A detailed description of the request.

View File

@ -0,0 +1,20 @@
name: Feature request
description: Suggest ideas, new features or enhancements
labels: [enhancement]
body:
- type: checkboxes
attributes:
label: Checklist
options:
- label: I believe the idea is awesome and would benefit the framework
required: true
- label: I have searched in the issue tracker for similar requests, including closed ones
required: true
- type: textarea
attributes:
label: Description
description: Provide a detailed description of the request
placeholder: Description...
validations:
required: true

View File

@ -168,7 +168,7 @@ messageActionGroupCallScheduled#b3a07661 call:InputGroupCall schedule_date:int =
messageActionSetChatTheme#aa786345 emoticon:string = MessageAction;
messageActionChatJoinedByRequest#ebbca3cb = MessageAction;
dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;
dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
photoEmpty#2331b22d id:long = Photo;
@ -544,7 +544,7 @@ inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet;
inputStickerSetDice#e67f520e emoticon:string = InputStickerSet;
inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet;
stickerSet#d7df217a flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int count:int hash:int = StickerSet;
stickerSet#d7df217a flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true gifs:flags.6?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int count:int hash:int = StickerSet;
messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet;
messages.stickerSetNotModified#d3f924eb = messages.StickerSet;
@ -1285,17 +1285,20 @@ auth.loggedOut#c3a2835f flags:# future_auth_token:flags.0?bytes = auth.LoggedOut
reactionCount#6fb250d1 flags:# chosen:flags.0?true reaction:string count:int = ReactionCount;
messageReactions#87b6e36 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector<ReactionCount> recent_reactons:flags.1?Vector<MessageUserReaction> = MessageReactions;
messageReactions#4f2b9479 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector<ReactionCount> recent_reactions:flags.1?Vector<MessagePeerReaction> = MessageReactions;
messageUserReaction#932844fa user_id:long reaction:string = MessageUserReaction;
messages.messageReactionsList#a366923c flags:# count:int reactions:Vector<MessageUserReaction> users:Vector<User> next_offset:flags.0?string = messages.MessageReactionsList;
messages.messageReactionsList#31bd492d flags:# count:int reactions:Vector<MessagePeerReaction> chats:Vector<Chat> users:Vector<User> next_offset:flags.0?string = messages.MessageReactionsList;
availableReaction#c077ec01 flags:# inactive:flags.0?true reaction:string title:string static_icon:Document appear_animation:Document select_animation:Document activate_animation:Document effect_animation:Document around_animation:flags.1?Document center_icon:flags.1?Document = AvailableReaction;
messages.availableReactionsNotModified#9f071957 = messages.AvailableReactions;
messages.availableReactions#768e3aad hash:int reactions:Vector<AvailableReaction> = messages.AvailableReactions;
messages.translateNoResult#67ca4737 = messages.TranslatedText;
messages.translateResultText#a214f7d0 text:string = messages.TranslatedText;
messagePeerReaction#51b67eff flags:# big:flags.0?true unread:flags.1?true peer_id:Peer reaction:string = MessagePeerReaction;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -1574,12 +1577,15 @@ messages.hideChatJoinRequest#7fe7e815 flags:# approved:flags.0?true peer:InputPe
messages.hideAllChatJoinRequests#e085f4ea flags:# approved:flags.0?true peer:InputPeer link:flags.1?string = Updates;
messages.toggleNoForwards#b11eafa2 peer:InputPeer enabled:Bool = Updates;
messages.saveDefaultSendAs#ccfddf96 peer:InputPeer send_as:InputPeer = Bool;
messages.sendReaction#25690ce4 flags:# peer:InputPeer msg_id:int reaction:flags.0?string = Updates;
messages.sendReaction#25690ce4 flags:# big:flags.1?true peer:InputPeer msg_id:int reaction:flags.0?string = Updates;
messages.getMessagesReactions#8bba90e6 peer:InputPeer id:Vector<int> = Updates;
messages.getMessageReactionsList#e0ee6b77 flags:# peer:InputPeer id:int reaction:flags.0?string offset:flags.1?string limit:int = messages.MessageReactionsList;
messages.setChatAvailableReactions#14050ea6 peer:InputPeer available_reactions:Vector<string> = Updates;
messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions;
messages.setDefaultReaction#d960c4d4 reaction:string = Bool;
messages.translateText#24ce6dee flags:# peer:flags.0?InputPeer msg_id:flags.0?int text:flags.1?string from_lang:flags.2?string to_lang:string = messages.TranslatedText;
messages.getUnreadReactions#e85bae1a peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages;
messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory;
updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
@ -1728,4 +1734,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
// LAYER 137
// LAYER 138

View File

@ -544,6 +544,11 @@ def pyrogram_api():
inline_query="""
InlineQuery
InlineQuery.answer
""",
chat_join_request="""
ChatJoinRequest
ChatJoinRequest.approve
ChatJoinRequest.decline
"""
)

View File

@ -91,3 +91,17 @@ InlineQuery
:hidden:
{inline_query_toctree}
ChatJoinRequest
---------------
.. hlist::
:columns: 2
{chat_join_request_hlist}
.. toctree::
:hidden:
{chat_join_request_toctree}

View File

@ -1,2 +1,3 @@
id message
Timeout Telegram is having internal problems. Please try again later.
Timeout Telegram is having internal problems. Please try again later.
ApiCallError Telegram is having internal problems. Please try again later.
1 id message
2 Timeout Telegram is having internal problems. Please try again later.
3 ApiCallError Telegram is having internal problems. Please try again later.

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
__version__ = "1.3.6"
__version__ = "1.4.0"
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"

File diff suppressed because it is too large Load Diff

View File

@ -210,7 +210,9 @@ class Session:
MsgId.set_server_time(msg.msg_id / (2 ** 32))
if msg.seq_no % 2 != 0:
if msg.msg_id not in self.pending_acks:
if msg.msg_id in self.pending_acks:
continue
else:
self.pending_acks.add(msg.msg_id)
if isinstance(msg.body, (raw.types.MsgDetailedInfo, raw.types.MsgNewDetailedInfo)):
@ -366,7 +368,8 @@ class Session:
if amount > sleep_threshold >= 0:
raise
log.warning(f'[{self.client.session_name}] Sleeping for {amount}s (required by "{query}")')
log.warning(f'[{self.client.session_name}] Waiting for {amount} seconds before continuing '
f'(required by "{query}")')
await asyncio.sleep(amount)
except (OSError, TimeoutError, InternalServerError, ServiceUnavailable) as e:

View File

@ -674,6 +674,14 @@ class Message(Object, Update):
video_attributes = attributes.get(raw.types.DocumentAttributeVideo, None)
animation = types.Animation._parse(client, doc, video_attributes, file_name)
media_type = "animation"
elif raw.types.DocumentAttributeSticker in attributes:
sticker = await types.Sticker._parse(
client, doc,
attributes.get(raw.types.DocumentAttributeImageSize, None),
attributes[raw.types.DocumentAttributeSticker],
file_name
)
media_type = "sticker"
elif raw.types.DocumentAttributeVideo in attributes:
video_attributes = attributes[raw.types.DocumentAttributeVideo]
@ -683,14 +691,6 @@ class Message(Object, Update):
else:
video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds)
media_type = "video"
elif raw.types.DocumentAttributeSticker in attributes:
sticker = await types.Sticker._parse(
client, doc,
attributes.get(raw.types.DocumentAttributeImageSize, None),
attributes[raw.types.DocumentAttributeSticker],
file_name
)
media_type = "sticker"
else:
document = types.Document._parse(client, doc, file_name)
media_type = "document"

View File

@ -46,6 +46,9 @@ class Sticker(Object):
is_animated (``bool``):
True, if the sticker is animated
is_video (``bool``):
True, if the sticker is a video sticker
file_name (``str``, *optional*):
Sticker file name.
@ -79,6 +82,7 @@ class Sticker(Object):
width: int,
height: int,
is_animated: bool,
is_video: bool,
file_name: str = None,
mime_type: str = None,
file_size: int = None,
@ -98,6 +102,7 @@ class Sticker(Object):
self.width = width
self.height = height
self.is_animated = is_animated
self.is_video = is_video
self.emoji = emoji
self.set_name = set_name
self.thumbs = thumbs
@ -167,6 +172,7 @@ class Sticker(Object):
width=image_size_attributes.w if image_size_attributes else 512,
height=image_size_attributes.h if image_size_attributes else 512,
is_animated=sticker.mime_type == "application/x-tgsticker",
is_video=sticker.mime_type == "video/webm",
# TODO: mask_position
set_name=set_name,
emoji=sticker_attributes.alt or None,