Compare commits

...

28 commits

Author SHA1 Message Date
wulan17
f824e72416
pyrofork: Refactor test_mode
Some checks failed
Pyrofork / build (macos-latest, 3.10) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.11) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.12) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.13) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.9) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.10) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.11) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.12) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.13) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.9) (push) Has been cancelled
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-26 20:48:41 +07:00
wulan17
2212b98b81
pyrofork: Retrive dc address and port from GetConfig
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-26 20:41:48 +07:00
wulan17
070afc0246
pyrofork: disable publish workflows
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2025-06-26 20:21:43 +07:00
wulan17
12d9297c02
pyrofork: Bump version to 2.3.67
Some checks failed
Pyrofork / build (macos-latest, 3.10) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.11) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.12) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.13) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.9) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.10) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.11) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.12) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.13) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.9) (push) Has been cancelled
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-25 19:16:02 +07:00
wulan17
52abec6e01
pyrofork: fix NoneType exception in filters
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-25 19:15:12 +07:00
KurimuzonAkuma
fd4eb09f7a
Add get_call_members method
Signed-off-by: gudmeong <privatemymail758@gmail.com>
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-25 19:15:12 +07:00
wulan17
dbcbadc400
pyrofork: Add back reverse parameter in get_chat_history
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-25 19:15:12 +07:00
KurimuzonAkuma
b65279046e
Update upgraded gift regex
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-25 19:15:12 +07:00
wulan17
9ff40dc90b
pyrofork: fix typo in KeyboardButton
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-25 19:15:06 +07:00
wulan17
6f616ebed8
pyrofork: Bump version to 2.3.66
Some checks failed
Pyrofork / build (macos-latest, 3.10) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.11) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.12) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.13) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.9) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.10) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.11) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.12) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.13) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.9) (push) Has been cancelled
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:48:38 +07:00
wulan17
e33d0bde65
pyrofork: fix typo
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:45:51 +07:00
wulan17
e5b5ef5072
pyrofork: Bump version to 2.3.65
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:59 +07:00
KurimuzonAkuma
a1e3f0f5db
Add transfer_business_account_stars method
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:08 +07:00
KurimuzonAkuma
b6c615df7a
Add get_business_account_gifts and get_business_account_star_balance method
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:08 +07:00
wulan17
a2f3a6a27b
pyrofork: Add reply_to_monoforum_id parameter to supported send_*
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:08 +07:00
wulan17
bd5603a6a7
pyrofork: Add STARS_AMOUNT_INVALID exception
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:07 +07:00
wulan17
1ed7add4dd
pyrofork: Add paid_message_price_changed field to Message
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:07 +07:00
wulan17
068181682e
pyrofork: Add ALLOW_PAYMENT_REQUIRED_X exception
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:07 +07:00
wulan17
c0dcac1fde
pyrofork: Add linked_forum field to Chat
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:07 +07:00
wulan17
ffec107a2c
pyrofork: Drop Chat.is_forum and add new ChatType (FORUM)
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:07 +07:00
wulan17
390786d92c
pyrofork: Add new ChatType (MONOFORUM)
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:07 +07:00
KurimuzonAkuma
a9c4ef4c2e
pyrofork: Add privileges to RequestPeer buttons
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:06 +07:00
KurimuzonAkuma
78467e30a2
pyrofork: Add search_gifts_for_resale, send_resold_gift, set_gift_resale_price, set_pinned_gifts methods
Co-authored-by: "ALi.w" <aminnimaj@gmail.com>
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:06 +07:00
uNickz
3d343a49ff
pyrofork: Add file_name param on InputMedia
* Add file_name param on InputMedia

Add file_name param on:
 - InputMediaVideo
 - InputMediaAudio
 - InputMediaDocument

---------

Co-authored-by: KurimuzonAkuma <31959970+KurimuzonAkuma@users.noreply.github.com>
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:06 +07:00
wulan17
83f3f52681
pyrofork: Refactor Message.link
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:06 +07:00
wulan17
8880a92483
pyrofork: types: Wallpaper: Make document optional
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:06 +07:00
wulan17
71c0a1176a
pyrofork: fix typo in filters
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:38:06 +07:00
wulan17
ddf90f26cf
pyrofork: Update API schema to Layer 204
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-10 22:37:58 +07:00
68 changed files with 1663 additions and 116 deletions

View file

@ -1,40 +0,0 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
push:
tags:
- '*'
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Build package
run: hatch build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1

View file

@ -108,7 +108,7 @@ userStatusLastMonth#65899777 flags:# by_me:flags.0?true = UserStatus;
chatEmpty#29562865 id:long = Chat; chatEmpty#29562865 id:long = Chat;
chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat;
chatForbidden#6592a1a7 id:long title:string = Chat; chatForbidden#6592a1a7 id:long title:string = Chat;
channel#7482147e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true signature_profiles:flags2.12?true autotranslation:flags2.15?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector<Username> stories_max_id:flags2.4?int color:flags2.7?PeerColor profile_color:flags2.8?PeerColor emoji_status:flags2.9?EmojiStatus level:flags2.10?int subscription_until_date:flags2.11?int bot_verification_icon:flags2.13?long send_paid_messages_stars:flags2.14?long = Chat; channel#fe685355 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true signature_profiles:flags2.12?true autotranslation:flags2.15?true broadcast_messages_allowed:flags2.16?true monoforum:flags2.17?true forum_tabs:flags2.19?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector<Username> stories_max_id:flags2.4?int color:flags2.7?PeerColor profile_color:flags2.8?PeerColor emoji_status:flags2.9?EmojiStatus level:flags2.10?int subscription_until_date:flags2.11?int bot_verification_icon:flags2.13?long send_paid_messages_stars:flags2.14?long linked_monoforum_id:flags2.18?long = Chat;
channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat;
chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector<long> available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector<long> available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull;
@ -195,7 +195,7 @@ messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long trans
messageActionStarGift#4717e8a4 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long = MessageAction; messageActionStarGift#4717e8a4 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long = MessageAction;
messageActionStarGiftUnique#2e3ae60e flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_stars:flags.8?long can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction; messageActionStarGiftUnique#2e3ae60e flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_stars:flags.8?long can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;
messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction; messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction;
messageActionPaidMessagesPrice#bcd71419 stars:long = MessageAction; messageActionPaidMessagesPrice#84b88578 flags:# broadcast_messages_allowed:flags.0?true stars:long = MessageAction;
messageActionConferenceCall#2ffe2f7a flags:# missed:flags.0?true active:flags.1?true video:flags.4?true call_id:long duration:flags.2?int other_participants:flags.3?Vector<Peer> = MessageAction; messageActionConferenceCall#2ffe2f7a flags:# missed:flags.0?true active:flags.1?true video:flags.4?true call_id:long duration:flags.2?int other_participants:flags.3?Vector<Peer> = MessageAction;
dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?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 ttl_period:flags.5?int = Dialog; dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?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 ttl_period:flags.5?int = Dialog;
@ -341,7 +341,7 @@ updateBotCallbackQuery#b9cfc48d flags:# query_id:long user_id:long peer:Peer msg
updateEditMessage#e40370a3 message:Message pts:int pts_count:int = Update; updateEditMessage#e40370a3 message:Message pts:int pts_count:int = Update;
updateInlineBotCallbackQuery#691e9052 flags:# query_id:long user_id:long msg_id:InputBotInlineMessageID chat_instance:long data:flags.0?bytes game_short_name:flags.1?string = Update; updateInlineBotCallbackQuery#691e9052 flags:# query_id:long user_id:long msg_id:InputBotInlineMessageID chat_instance:long data:flags.0?bytes game_short_name:flags.1?string = Update;
updateReadChannelOutbox#b75f99a9 channel_id:long max_id:int = Update; updateReadChannelOutbox#b75f99a9 channel_id:long max_id:int = Update;
updateDraftMessage#1b49ec6d flags:# peer:Peer top_msg_id:flags.0?int draft:DraftMessage = Update; updateDraftMessage#edfc111e flags:# peer:Peer top_msg_id:flags.0?int saved_peer_id:flags.1?Peer draft:DraftMessage = Update;
updateReadFeaturedStickers#571d2742 = Update; updateReadFeaturedStickers#571d2742 = Update;
updateRecentStickers#9a422c20 = Update; updateRecentStickers#9a422c20 = Update;
updateConfig#a229dd06 = Update; updateConfig#a229dd06 = Update;
@ -357,10 +357,10 @@ updatePhoneCall#ab0f6b1e phone_call:PhoneCall = Update;
updateLangPackTooLong#46560264 lang_code:string = Update; updateLangPackTooLong#46560264 lang_code:string = Update;
updateLangPack#56022f4d difference:LangPackDifference = Update; updateLangPack#56022f4d difference:LangPackDifference = Update;
updateFavedStickers#e511996d = Update; updateFavedStickers#e511996d = Update;
updateChannelReadMessagesContents#ea29055d flags:# channel_id:long top_msg_id:flags.0?int messages:Vector<int> = Update; updateChannelReadMessagesContents#25f324f7 flags:# channel_id:long top_msg_id:flags.0?int saved_peer_id:flags.1?Peer messages:Vector<int> = Update;
updateContactsReset#7084a7be = Update; updateContactsReset#7084a7be = Update;
updateChannelAvailableMessages#b23fc698 channel_id:long available_min_id:int = Update; updateChannelAvailableMessages#b23fc698 channel_id:long available_min_id:int = Update;
updateDialogUnreadMark#e16459c3 flags:# unread:flags.0?true peer:DialogPeer = Update; updateDialogUnreadMark#b658f23e flags:# unread:flags.0?true peer:DialogPeer saved_peer_id:flags.1?Peer = Update;
updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update; updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update;
updateChatDefaultBannedRights#54c01850 peer:Peer default_banned_rights:ChatBannedRights version:int = Update; updateChatDefaultBannedRights#54c01850 peer:Peer default_banned_rights:ChatBannedRights version:int = Update;
updateFolderPeers#19360dc0 folder_peers:Vector<FolderPeer> pts:int pts_count:int = Update; updateFolderPeers#19360dc0 folder_peers:Vector<FolderPeer> pts:int pts_count:int = Update;
@ -394,7 +394,7 @@ updateGroupCallConnection#b783982 flags:# presentation:flags.0?true params:DataJ
updateBotCommands#4d712f2e peer:Peer bot_id:long commands:Vector<BotCommand> = Update; updateBotCommands#4d712f2e peer:Peer bot_id:long commands:Vector<BotCommand> = Update;
updatePendingJoinRequests#7063c3db peer:Peer requests_pending:int recent_requesters:Vector<long> = Update; updatePendingJoinRequests#7063c3db peer:Peer requests_pending:int recent_requesters:Vector<long> = Update;
updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:string invite:ExportedChatInvite qts:int = Update; updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:string invite:ExportedChatInvite qts:int = Update;
updateMessageReactions#5e1b3cb8 flags:# peer:Peer msg_id:int top_msg_id:flags.0?int reactions:MessageReactions = Update; updateMessageReactions#1e297bfa flags:# peer:Peer msg_id:int top_msg_id:flags.0?int saved_peer_id:flags.1?Peer reactions:MessageReactions = Update;
updateAttachMenuBots#17b7a20b = Update; updateAttachMenuBots#17b7a20b = Update;
updateWebViewResultSent#1592b79d query_id:long = Update; updateWebViewResultSent#1592b79d query_id:long = Update;
updateBotMenuButton#14b85813 bot_id:long button:BotMenuButton = Update; updateBotMenuButton#14b85813 bot_id:long button:BotMenuButton = Update;
@ -442,6 +442,8 @@ updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Updat
updatePaidReactionPrivacy#8b725fce private:PaidReactionPrivacy = Update; updatePaidReactionPrivacy#8b725fce private:PaidReactionPrivacy = Update;
updateSentPhoneCode#504aa18f sent_code:auth.SentCode = Update; updateSentPhoneCode#504aa18f sent_code:auth.SentCode = Update;
updateGroupCallChainBlocks#a477288f call:InputGroupCall sub_chain_id:int blocks:Vector<bytes> next_offset:int = Update; updateGroupCallChainBlocks#a477288f call:InputGroupCall sub_chain_id:int blocks:Vector<bytes> next_offset:int = Update;
updateReadMonoForumInbox#77b0e372 channel_id:long saved_peer_id:Peer read_max_id:int = Update;
updateReadMonoForumOutbox#a4a79376 channel_id:long saved_peer_id:Peer read_max_id:int = Update;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
@ -1647,8 +1649,9 @@ stories.storyViewsList#59d78fc5 flags:# count:int views_count:int forwards_count
stories.storyViews#de9eed1d views:Vector<StoryViews> users:Vector<User> = stories.StoryViews; stories.storyViews#de9eed1d views:Vector<StoryViews> users:Vector<User> = stories.StoryViews;
inputReplyToMessage#22c0f6d5 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector<MessageEntity> quote_offset:flags.4?int = InputReplyTo; inputReplyToMessage#b07038b0 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector<MessageEntity> quote_offset:flags.4?int monoforum_peer_id:flags.5?InputPeer = InputReplyTo;
inputReplyToStory#5881323a peer:InputPeer story_id:int = InputReplyTo; inputReplyToStory#5881323a peer:InputPeer story_id:int = InputReplyTo;
inputReplyToMonoForum#69d66c45 monoforum_peer_id:InputPeer = InputReplyTo;
exportedStoryLink#3fc9053b link:string = ExportedStoryLink; exportedStoryLink#3fc9053b link:string = ExportedStoryLink;
@ -1721,6 +1724,7 @@ storyReactionPublicRepost#cfcd0f13 peer_id:Peer story:StoryItem = StoryReaction;
stories.storyReactionsList#aa5f789c flags:# count:int reactions:Vector<StoryReaction> chats:Vector<Chat> users:Vector<User> next_offset:flags.0?string = stories.StoryReactionsList; stories.storyReactionsList#aa5f789c flags:# count:int reactions:Vector<StoryReaction> chats:Vector<Chat> users:Vector<User> next_offset:flags.0?string = stories.StoryReactionsList;
savedDialog#bd87cb6c flags:# pinned:flags.2?true peer:Peer top_message:int = SavedDialog; savedDialog#bd87cb6c flags:# pinned:flags.2?true peer:Peer top_message:int = SavedDialog;
monoForumDialog#64407ea7 flags:# unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_reactions_count:int draft:flags.1?DraftMessage = SavedDialog;
messages.savedDialogs#f83ae221 dialogs:Vector<SavedDialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.SavedDialogs; messages.savedDialogs#f83ae221 dialogs:Vector<SavedDialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.SavedDialogs;
messages.savedDialogsSlice#44ba9dd9 count:int dialogs:Vector<SavedDialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.SavedDialogs; messages.savedDialogsSlice#44ba9dd9 count:int dialogs:Vector<SavedDialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.SavedDialogs;
@ -2186,7 +2190,7 @@ messages.receivedMessages#5a954c0 max_id:int = Vector<ReceivedNotifyMessage>;
messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool;
messages.sendMessage#fbf2340a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long = Updates; messages.sendMessage#fbf2340a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long = Updates;
messages.sendMedia#a550cd78 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long = Updates; messages.sendMedia#a550cd78 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long = Updates;
messages.forwardMessages#bb9fa475 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut video_timestamp:flags.20?int allow_paid_stars:flags.21?long = Updates; messages.forwardMessages#38f0188c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut video_timestamp:flags.20?int allow_paid_stars:flags.21?long = Updates;
messages.reportSpam#cf1592db peer:InputPeer = Bool; messages.reportSpam#cf1592db peer:InputPeer = Bool;
messages.getPeerSettings#efd9a6a2 peer:InputPeer = messages.PeerSettings; messages.getPeerSettings#efd9a6a2 peer:InputPeer = messages.PeerSettings;
messages.report#fc78af9b peer:InputPeer id:Vector<int> option:bytes message:string = ReportResult; messages.report#fc78af9b peer:InputPeer id:Vector<int> option:bytes message:string = ReportResult;
@ -2268,8 +2272,8 @@ messages.sendMultiMedia#1bf89d74 flags:# silent:flags.5?true background:flags.6?
messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile;
messages.searchStickerSets#35705b8a flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets; messages.searchStickerSets#35705b8a flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets;
messages.getSplitRanges#1cff7e08 = Vector<MessageRange>; messages.getSplitRanges#1cff7e08 = Vector<MessageRange>;
messages.markDialogUnread#c286d98f flags:# unread:flags.0?true peer:InputDialogPeer = Bool; messages.markDialogUnread#8c5006f8 flags:# unread:flags.0?true parent_peer:flags.1?InputPeer peer:InputDialogPeer = Bool;
messages.getDialogUnreadMarks#22e24e22 = Vector<DialogPeer>; messages.getDialogUnreadMarks#21202222 flags:# parent_peer:flags.0?InputPeer = Vector<DialogPeer>;
messages.clearAllDrafts#7e58ee9c = Bool; messages.clearAllDrafts#7e58ee9c = Bool;
messages.updatePinnedMessage#d2aaf7ec flags:# silent:flags.0?true unpin:flags.1?true pm_oneside:flags.2?true peer:InputPeer id:int = Updates; messages.updatePinnedMessage#d2aaf7ec flags:# silent:flags.0?true unpin:flags.1?true pm_oneside:flags.2?true peer:InputPeer id:int = Updates;
messages.sendVote#10ea6184 peer:InputPeer msg_id:int options:Vector<bytes> = Updates; messages.sendVote#10ea6184 peer:InputPeer msg_id:int options:Vector<bytes> = Updates;
@ -2299,7 +2303,7 @@ messages.getOldFeaturedStickers#7ed094a1 offset:int limit:int hash:long = messag
messages.getReplies#22ddd30c peer:InputPeer msg_id:int offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; messages.getReplies#22ddd30c peer:InputPeer msg_id:int offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages;
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage; messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
messages.unpinAllMessages#ee22b9a8 flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.unpinAllMessages#62dd747 flags:# peer:InputPeer top_msg_id:flags.0?int saved_peer_id:flags.1?InputPeer = messages.AffectedHistory;
messages.deleteChat#5bd0ee50 chat_id:long = Bool; messages.deleteChat#5bd0ee50 chat_id:long = Bool;
messages.deletePhoneCallHistory#f9cbe409 flags:# revoke:flags.0?true = messages.AffectedFoundMessages; messages.deletePhoneCallHistory#f9cbe409 flags:# revoke:flags.0?true = messages.AffectedFoundMessages;
messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed; messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed;
@ -2330,8 +2334,8 @@ messages.setChatAvailableReactions#864b2581 flags:# peer:InputPeer available_rea
messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions; messages.getAvailableReactions#18dea0ac hash:int = messages.AvailableReactions;
messages.setDefaultReaction#4f47a016 reaction:Reaction = Bool; messages.setDefaultReaction#4f47a016 reaction:Reaction = Bool;
messages.translateText#63183030 flags:# peer:flags.0?InputPeer id:flags.0?Vector<int> text:flags.1?Vector<TextWithEntities> to_lang:string = messages.TranslatedText; messages.translateText#63183030 flags:# peer:flags.0?InputPeer id:flags.0?Vector<int> text:flags.1?Vector<TextWithEntities> to_lang:string = messages.TranslatedText;
messages.getUnreadReactions#3223495b flags:# peer:InputPeer top_msg_id:flags.0?int offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; messages.getUnreadReactions#bd7f90ac flags:# peer:InputPeer top_msg_id:flags.0?int saved_peer_id:flags.1?InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages;
messages.readReactions#54aa7f8e flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.readReactions#9ec44f93 flags:# peer:InputPeer top_msg_id:flags.0?int saved_peer_id:flags.1?InputPeer = messages.AffectedHistory;
messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages; messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages;
messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots; messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots;
messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot;
@ -2363,9 +2367,9 @@ messages.getBotApp#34fdc5c3 app:InputBotApp hash:long = messages.BotApp;
messages.requestAppWebView#53618bce flags:# write_allowed:flags.0?true compact:flags.7?true fullscreen:flags.8?true peer:InputPeer app:InputBotApp start_param:flags.1?string theme_params:flags.2?DataJSON platform:string = WebViewResult; messages.requestAppWebView#53618bce flags:# write_allowed:flags.0?true compact:flags.7?true fullscreen:flags.8?true peer:InputPeer app:InputBotApp start_param:flags.1?string theme_params:flags.2?DataJSON platform:string = WebViewResult;
messages.setChatWallPaper#8ffacae1 flags:# for_both:flags.3?true revert:flags.4?true peer:InputPeer wallpaper:flags.0?InputWallPaper settings:flags.2?WallPaperSettings id:flags.1?int = Updates; messages.setChatWallPaper#8ffacae1 flags:# for_both:flags.3?true revert:flags.4?true peer:InputPeer wallpaper:flags.0?InputWallPaper settings:flags.2?WallPaperSettings id:flags.1?int = Updates;
messages.searchEmojiStickerSets#92b4494c flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets; messages.searchEmojiStickerSets#92b4494c flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets;
messages.getSavedDialogs#5381d21a flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.SavedDialogs; messages.getSavedDialogs#1e91fc99 flags:# exclude_pinned:flags.0?true parent_peer:flags.1?InputPeer offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.SavedDialogs;
messages.getSavedHistory#3d9a414d peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; messages.getSavedHistory#998ab009 flags:# parent_peer:flags.0?InputPeer peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages;
messages.deleteSavedHistory#6e98102b flags:# peer:InputPeer max_id:int min_date:flags.2?int max_date:flags.3?int = messages.AffectedHistory; messages.deleteSavedHistory#4dc5085f flags:# parent_peer:flags.0?InputPeer peer:InputPeer max_id:int min_date:flags.2?int max_date:flags.3?int = messages.AffectedHistory;
messages.getPinnedSavedDialogs#d63d94e0 = messages.SavedDialogs; messages.getPinnedSavedDialogs#d63d94e0 = messages.SavedDialogs;
messages.toggleSavedDialogPin#ac81bbde flags:# pinned:flags.0?true peer:InputDialogPeer = Bool; messages.toggleSavedDialogPin#ac81bbde flags:# pinned:flags.0?true peer:InputDialogPeer = Bool;
messages.reorderPinnedSavedDialogs#8b716587 flags:# force:flags.0?true order:Vector<InputDialogPeer> = Bool; messages.reorderPinnedSavedDialogs#8b716587 flags:# force:flags.0?true order:Vector<InputDialogPeer> = Bool;
@ -2400,6 +2404,8 @@ messages.savePreparedInlineMessage#f21f7f2f flags:# result:InputBotInlineResult
messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage; messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage;
messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector<string> offset:int limit:int hash:long = messages.FoundStickers; messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector<string> offset:int limit:int hash:long = messages.FoundStickers;
messages.reportMessagesDelivery#5a6d7395 flags:# push:flags.0?true peer:InputPeer id:Vector<int> = Bool; messages.reportMessagesDelivery#5a6d7395 flags:# push:flags.0?true peer:InputPeer id:Vector<int> = Bool;
messages.getSavedDialogsByID#6f6f9c96 flags:# parent_peer:flags.1?InputPeer ids:Vector<InputPeer> = messages.SavedDialogs;
messages.readSavedHistory#ba4a3b5b parent_peer:InputPeer peer:InputPeer max_id:int = Bool;
updates.getState#edd4882a = updates.State; updates.getState#edd4882a = updates.State;
updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference;
@ -2488,7 +2494,7 @@ channels.toggleJoinRequest#4c2985b6 channel:InputChannel enabled:Bool = Updates;
channels.reorderUsernames#b45ced1d channel:InputChannel order:Vector<string> = Bool; channels.reorderUsernames#b45ced1d channel:InputChannel order:Vector<string> = Bool;
channels.toggleUsername#50f24105 channel:InputChannel username:string active:Bool = Bool; channels.toggleUsername#50f24105 channel:InputChannel username:string active:Bool = Bool;
channels.deactivateAllUsernames#a245dd3 channel:InputChannel = Bool; channels.deactivateAllUsernames#a245dd3 channel:InputChannel = Bool;
channels.toggleForum#a4298b29 channel:InputChannel enabled:Bool = Updates; channels.toggleForum#3ff75734 channel:InputChannel enabled:Bool tabs:Bool = Updates;
channels.createForumTopic#f40c0224 flags:# channel:InputChannel title:string icon_color:flags.0?int icon_emoji_id:flags.3?long random_id:long send_as:flags.2?InputPeer = Updates; channels.createForumTopic#f40c0224 flags:# channel:InputChannel title:string icon_color:flags.0?int icon_emoji_id:flags.3?long random_id:long send_as:flags.2?InputPeer = Updates;
channels.getForumTopics#de560d1 flags:# channel:InputChannel q:flags.0?string offset_date:int offset_id:int offset_topic:int limit:int = messages.ForumTopics; channels.getForumTopics#de560d1 flags:# channel:InputChannel q:flags.0?string offset_date:int offset_id:int offset_topic:int limit:int = messages.ForumTopics;
channels.getForumTopicsByID#b0831eb9 channel:InputChannel topics:Vector<int> = messages.ForumTopics; channels.getForumTopicsByID#b0831eb9 channel:InputChannel topics:Vector<int> = messages.ForumTopics;
@ -2507,8 +2513,9 @@ channels.setBoostsToUnblockRestrictions#ad399cee channel:InputChannel boosts:int
channels.setEmojiStickers#3cd930b7 channel:InputChannel stickerset:InputStickerSet = Bool; channels.setEmojiStickers#3cd930b7 channel:InputChannel stickerset:InputStickerSet = Bool;
channels.restrictSponsoredMessages#9ae91519 channel:InputChannel restricted:Bool = Updates; channels.restrictSponsoredMessages#9ae91519 channel:InputChannel restricted:Bool = Updates;
channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
channels.updatePaidMessagesPrice#fc84653f channel:InputChannel send_paid_messages_stars:long = Updates; channels.updatePaidMessagesPrice#4b12327b flags:# broadcast_messages_allowed:flags.0?true channel:InputChannel send_paid_messages_stars:long = Updates;
channels.toggleAutotranslation#167fc0a1 channel:InputChannel enabled:Bool = Updates; channels.toggleAutotranslation#167fc0a1 channel:InputChannel enabled:Bool = Updates;
channels.getMessageAuthor#ece2a0e6 channel:InputChannel id:int = User;
bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON;
bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool;
@ -2716,4 +2723,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;
fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;
// LAYER 203 // LAYER 204

View file

@ -365,16 +365,24 @@ def pyrogram_api():
get_chat_gifts get_chat_gifts
hide_gift hide_gift
refund_star_payment refund_star_payment
search_gifts_for_resale
send_invoice send_invoice
send_paid_media send_paid_media
send_paid_reaction send_paid_reaction
send_payment_form send_payment_form
send_gift send_gift
send_resold_gift
set_gift_resale_price
set_pinned_gifts
show_gift show_gift
transfer_gift transfer_gift
upgrade_gift upgrade_gift
get_stars_balance get_stars_balance
""", """,
phone="""
Phone
get_call_members
""",
password=""" password="""
Password Password
enable_cloud_password enable_cloud_password
@ -411,6 +419,9 @@ def pyrogram_api():
answer_shipping_query answer_shipping_query
delete_business_messages delete_business_messages
get_business_connection get_business_connection
get_business_account_gifts
get_business_account_star_balance
transfer_business_account_stars
""", """,
authorization=""" authorization="""
Authorization Authorization
@ -507,6 +518,7 @@ def pyrogram_api():
PeerUser PeerUser
PeerChannel PeerChannel
BotInfo BotInfo
GroupCallMember
ChatColor ChatColor
CollectibleItemInfo CollectibleItemInfo
BotVerification BotVerification
@ -605,6 +617,7 @@ def pyrogram_api():
Invoice Invoice
LabeledPrice LabeledPrice
PaidMedia PaidMedia
PaidMessagePriceChanged
PaymentForm PaymentForm
PaymentInfo PaymentInfo
PaymentRefunded PaymentRefunded
@ -714,6 +727,7 @@ def pyrogram_api():
InputMessageContent InputMessageContent
InputMessageContent InputMessageContent
InputReplyToMessage InputReplyToMessage
InputReplyToMonoforum
InputReplyToStory InputReplyToStory
InputTextMessageContent InputTextMessageContent
InputLocationMessageContent InputLocationMessageContent

View file

@ -35,6 +35,7 @@ BOT_GAMES_DISABLED Bot games cannot be used in this type of chat
BOT_GROUPS_BLOCKED This bot can't be added to groups BOT_GROUPS_BLOCKED This bot can't be added to groups
BOT_INLINE_DISABLED The inline feature of the bot is disabled BOT_INLINE_DISABLED The inline feature of the bot is disabled
BOT_INVALID This is not a valid bot BOT_INVALID This is not a valid bot
BOT_INVOICE_INVALID The provided invoice is invalid
BOT_METHOD_INVALID The method can't be used by bots BOT_METHOD_INVALID The method can't be used by bots
BOT_MISSING This method can only be run by a bot BOT_MISSING This method can only be run by a bot
BOT_ONESIDE_NOT_AVAIL Bots can't pin messages for one side only in private chats BOT_ONESIDE_NOT_AVAIL Bots can't pin messages for one side only in private chats
@ -46,6 +47,7 @@ BROADCAST_CALLS_DISABLED Broadcast calls disabled
BROADCAST_ID_INVALID The channel is invalid BROADCAST_ID_INVALID The channel is invalid
BROADCAST_PUBLIC_VOTERS_FORBIDDEN Polls with public voters cannot be sent in channels BROADCAST_PUBLIC_VOTERS_FORBIDDEN Polls with public voters cannot be sent in channels
BROADCAST_REQUIRED The request can only be used with a channel BROADCAST_REQUIRED The request can only be used with a channel
BUSINESS_BOT_MISSING Business bot missing
BUTTON_DATA_INVALID The button callback data is invalid or too large BUTTON_DATA_INVALID The button callback data is invalid or too large
BUTTON_ID_INVALID The button_id parameter is invalid BUTTON_ID_INVALID The button_id parameter is invalid
BUTTON_TEXT_INVALID The specified button text is invalid BUTTON_TEXT_INVALID The specified button text is invalid
@ -503,3 +505,4 @@ BOOSTS_EMPTY You can't modify the icon of the General topic.
BOOST_NOT_MODIFIED You're already boosting the specified channel. BOOST_NOT_MODIFIED You're already boosting the specified channel.
PAYMENT_REQUIRED The payment is required PAYMENT_REQUIRED The payment is required
BOOST_PEER_INVALID The specified `boost_peer` is invalid. BOOST_PEER_INVALID The specified `boost_peer` is invalid.
STARS_AMOUNT_INVALID The specified `amount` is invalid.
1 id message
35 BOT_GROUPS_BLOCKED This bot can't be added to groups
36 BOT_INLINE_DISABLED The inline feature of the bot is disabled
37 BOT_INVALID This is not a valid bot
38 BOT_INVOICE_INVALID The provided invoice is invalid
39 BOT_METHOD_INVALID The method can't be used by bots
40 BOT_MISSING This method can only be run by a bot
41 BOT_ONESIDE_NOT_AVAIL Bots can't pin messages for one side only in private chats
47 BROADCAST_ID_INVALID The channel is invalid
48 BROADCAST_PUBLIC_VOTERS_FORBIDDEN Polls with public voters cannot be sent in channels
49 BROADCAST_REQUIRED The request can only be used with a channel
50 BUSINESS_BOT_MISSING Business bot missing
51 BUTTON_DATA_INVALID The button callback data is invalid or too large
52 BUTTON_ID_INVALID The button_id parameter is invalid
53 BUTTON_TEXT_INVALID The specified button text is invalid
505 BOOST_NOT_MODIFIED You're already boosting the specified channel.
506 PAYMENT_REQUIRED The payment is required
507 BOOST_PEER_INVALID The specified `boost_peer` is invalid.
508 STARS_AMOUNT_INVALID The specified `amount` is invalid.

View file

@ -44,3 +44,4 @@ GROUPCALL_ALREADY_STARTED The groupcall has already started, you can join direct
GROUPCALL_FORBIDDEN The group call has already ended GROUPCALL_FORBIDDEN The group call has already ended
LIVE_DISABLED Story is disabled server-side LIVE_DISABLED Story is disabled server-side
CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commenting CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commenting
ALLOW_PAYMENT_REQUIRED_X Payment of {value} stars is required to perform this action
1 id message
44 GROUPCALL_FORBIDDEN The group call has already ended
45 LIVE_DISABLED Story is disabled server-side
46 CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commenting
47 ALLOW_PAYMENT_REQUIRED_X Payment of {value} stars is required to perform this action

View file

@ -0,0 +1,8 @@
GiftAttributeType
=================
.. autoclass:: pyrogram.enums.GiftForResaleOrder()
:members:
.. raw:: html
:file: ./cleanup.html

View file

@ -18,7 +18,7 @@
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
__fork_name__ = "PyroFork" __fork_name__ = "PyroFork"
__version__ = "2.3.64" __version__ = "2.3.67"
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)" __license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>" __copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>"

View file

@ -61,6 +61,7 @@ from .file_id import FileId, FileType, ThumbnailSource
from .mime_types import mime_types from .mime_types import mime_types
from .parser import Parser from .parser import Parser
from .session.internals import MsgId from .session.internals import MsgId
from .session.internals.data_center import DataCenter
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
MONGO_AVAIL = False MONGO_AVAIL = False
@ -231,6 +232,7 @@ class Client(Methods):
PARENT_DIR = Path(sys.argv[0]).parent PARENT_DIR = Path(sys.argv[0]).parent
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:joinchat/|\+))([\w-]+)$") INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:joinchat/|\+))([\w-]+)$")
UPGRADED_GIFT_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:nft/|\+))([\w-]+)$")
WORKERS = min(32, (os.cpu_count() or 0) + 4) # os.cpu_count() can be None WORKERS = min(32, (os.cpu_count() or 0) + 4) # os.cpu_count() can be None
WORKDIR = PARENT_DIR WORKDIR = PARENT_DIR
@ -314,6 +316,8 @@ class Client(Methods):
self.max_message_cache_size = max_message_cache_size self.max_message_cache_size = max_message_cache_size
self.max_message_cache_size = max_message_cache_size self.max_message_cache_size = max_message_cache_size
self.max_business_user_connection_cache_size = max_business_user_connection_cache_size self.max_business_user_connection_cache_size = max_business_user_connection_cache_size
self.test_addr = None
self.test_port = None
self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler") self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")
@ -391,6 +395,25 @@ class Client(Methods):
except ConnectionError: except ConnectionError:
pass pass
def set_dc(self, addr: str, port: int = 80):
"""Set the data center address and port.
Parameters:
addr (``str``):
The data center address, e.g.: "149.154.167.40".
port (``int``, *optional*):
The data center port, e.g.: 443.
Defaults to 80.
"""
if not isinstance(addr, str):
raise TypeError("addr must be a string")
if not isinstance(port, int):
raise TypeError("port must be an integer")
self.test_addr = addr
self.test_port = port
async def updates_watchdog(self): async def updates_watchdog(self):
while True: while True:
try: try:
@ -521,6 +544,16 @@ class Client(Methods):
break break
if isinstance(signed_in, User): if isinstance(signed_in, User):
if not self.test_mode:
is_dc_default = await self.check_dc_default()
if is_dc_default:
log.info("Your session is using the default data center.")
log.info("Updating the data center options from GetConfig...")
await self.update_dc_option()
log.info("Data center updated successfully.")
log.info("Restarting the session to apply the changes...")
await self.session.stop()
await self.session.start()
return signed_in return signed_in
def set_parse_mode(self, parse_mode: Optional["enums.ParseMode"]): def set_parse_mode(self, parse_mode: Optional["enums.ParseMode"]):
@ -855,6 +888,45 @@ class Client(Methods):
break break
except Exception as e: except Exception as e:
print(e) print(e)
# Needed for migration from storage v3 to v4
if self.in_memory or self.session_string:
await self.insert_default_dc_options()
if not await self.storage.get_dc_address(await self.storage.dc_id(), self.ipv6):
log.info("No DC address found, inserting default DC options...")
await self.insert_default_dc_options()
async def insert_default_dc_options(self):
for dc_id in range(1, 6):
for is_ipv6 in (False, True):
if dc_id in [2,4]:
for media in (False, True):
address, port = DataCenter(dc_id, False, is_ipv6, self.alt_port, media)
await self.storage.update_dc_address(
(dc_id, address, port, is_ipv6, media, True)
)
else:
address, port = DataCenter(dc_id, False, is_ipv6, False, False)
await self.storage.update_dc_address(
(dc_id, address, port, is_ipv6, False, True)
)
async def update_dc_option(self):
config = await self.invoke(raw.functions.help.GetConfig())
for option in config.dc_options:
await self.storage.update_dc_address(
(option.id, option.address, option.port, option.is_ipv6, option.is_media, False)
)
async def check_dc_default(
self,
dc_id: int,
is_ipv6: bool,
media: bool = False
) -> bool:
current_dc = await self.storage.get_dc_address(dc_id, is_ipv6, media)
if current_dc is not None and current_dc[2]:
return True
return False
def is_excluded(self, exclude, module): def is_excluded(self, exclude, module):
for e in exclude: for e in exclude:

View file

@ -22,7 +22,6 @@ import logging
from typing import Optional, Type from typing import Optional, Type
from .transport import TCP, TCPAbridged from .transport import TCP, TCPAbridged
from ..session.internals import DataCenter
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -34,6 +33,8 @@ class Connection:
self, self,
dc_id: int, dc_id: int,
test_mode: bool, test_mode: bool,
server_ip: str,
server_port: int,
ipv6: bool, ipv6: bool,
alt_port: bool, alt_port: bool,
proxy: dict, proxy: dict,
@ -42,13 +43,14 @@ class Connection:
) -> None: ) -> None:
self.dc_id = dc_id self.dc_id = dc_id
self.test_mode = test_mode self.test_mode = test_mode
self.server_ip = server_ip
self.server_port = 5222 if alt_port else server_port
self.ipv6 = ipv6 self.ipv6 = ipv6
self.alt_port = alt_port
self.proxy = proxy self.proxy = proxy
self.media = media self.media = media
self.protocol_factory = protocol_factory self.protocol_factory = protocol_factory
self.address = DataCenter(dc_id, test_mode, ipv6, alt_port, media) self.address = (server_ip, server_port)
self.protocol: Optional[TCP] = None self.protocol: Optional[TCP] = None
async def connect(self) -> None: async def connect(self) -> None:

View file

@ -27,6 +27,7 @@ from .chat_type import ChatType
from .client_platform import ClientPlatform from .client_platform import ClientPlatform
from .folder_color import FolderColor from .folder_color import FolderColor
from .gift_attribute_type import GiftAttributeType from .gift_attribute_type import GiftAttributeType
from .gift_for_resale_order import GiftForResaleOrder
from .listerner_types import ListenerTypes from .listerner_types import ListenerTypes
from .message_entity_type import MessageEntityType from .message_entity_type import MessageEntityType
from .message_media_type import MessageMediaType from .message_media_type import MessageMediaType
@ -55,6 +56,7 @@ __all__ = [
'ClientPlatform', 'ClientPlatform',
'FolderColor', 'FolderColor',
'GiftAttributeType', 'GiftAttributeType',
'GiftForResaleOrder',
'ListenerTypes', 'ListenerTypes',
'MessageEntityType', 'MessageEntityType',
'MessageMediaType', 'MessageMediaType',

View file

@ -39,3 +39,9 @@ class ChatType(AutoName):
CHANNEL = auto() CHANNEL = auto()
"Chat is a channel" "Chat is a channel"
FORUM = auto()
"Chat is a forum"
MONOFORUM = auto()
"Chat is a monoforum"

View file

@ -0,0 +1,35 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from enum import auto
from .auto_name import AutoName
class GiftForResaleOrder(AutoName):
"""Describes order in which upgraded gifts for resale will be sorted. Used in :meth:`~pyrogram.Client.search_gifts_for_resale`."""
PRICE = auto()
"The gifts will be sorted by their price from the lowest to the highest"
CHANGE_DATE = auto()
"The gifts will be sorted by the last date when their price was changed from the newest to the oldest"
NUMBER = auto()
"The gifts will be sorted by their number from the smallest to the largest"

View file

@ -132,3 +132,6 @@ class MessageServiceType(AutoName):
SCREENSHOT_TAKEN = auto() SCREENSHOT_TAKEN = auto()
"Screenshot taken" "Screenshot taken"
PAID_MESSAGE_PRICE_CHANGED = auto()
"Paid message price changed"

View file

@ -1035,7 +1035,7 @@ class user(Filter, set):
async def __call__(self, _, message: Message): async def __call__(self, _, message: Message):
is_usernames_in_filters = False is_usernames_in_filters = False
if message.from_user.usernames: if message.from_user and message.from_user.usernames:
for username in message.from_user.usernames: for username in message.from_user.usernames:
if ( if (
username.username in self username.username in self
@ -1078,7 +1078,7 @@ class chat(Filter, set):
async def __call__(self, _, message: Union[Message, Story]): async def __call__(self, _, message: Union[Message, Story]):
if isinstance(message, Story): if isinstance(message, Story):
is_usernames_in_filters = False is_usernames_in_filters = False
if message.sender_chat.usernames: if message.sender_chat and message.sender_chat.usernames:
for username in message.sender_chat.usernames: for username in message.sender_chat.usernames:
if ( if (
username.username in self username.username in self
@ -1107,8 +1107,8 @@ class chat(Filter, set):
) or is_usernames_in_filters ) or is_usernames_in_filters
else: else:
is_usernames_in_filters = False is_usernames_in_filters = False
if message.chat.usernames: if message.chat and message.chat.usernames:
for username in message._chat.usernames: for username in message.chat.usernames:
if ( if (
username.username in self username.username in self
or username.username.lower() in self or username.username.lower() in self

View file

@ -29,6 +29,7 @@ from .password import Password
from .pyromod import Pyromod from .pyromod import Pyromod
from .stickers import Stickers from .stickers import Stickers
from .payments import Payments from .payments import Payments
from .phone import Phone
from .users import Users from .users import Users
from .utilities import Utilities from .utilities import Utilities
from .business import TelegramBusiness from .business import TelegramBusiness
@ -42,6 +43,7 @@ class Methods(
Password, Password,
Pyromod, Pyromod,
Payments, Payments,
Phone,
Chats, Chats,
Stickers, Stickers,
Users, Users,

View file

@ -61,6 +61,8 @@ class SendCode:
) )
) )
except (PhoneMigrate, NetworkMigrate) as e: except (PhoneMigrate, NetworkMigrate) as e:
if not self.test_mode:
await self.update_dc_option()
# pylint: disable=access-member-before-definition # pylint: disable=access-member-before-definition
await self.session.stop() await self.session.stop()

View file

@ -58,6 +58,8 @@ class SignInBot:
) )
) )
except UserMigrate as e: except UserMigrate as e:
if not self.test_mode:
await self.update_dc_option()
# pylint: disable=access-member-before-definition # pylint: disable=access-member-before-definition
await self.session.stop() await self.session.stop()

View file

@ -80,6 +80,8 @@ class SignInQrcode:
return types.User._parse(self, r.authorization.user) return types.User._parse(self, r.authorization.user)
if isinstance(r, raw.types.auth.LoginTokenMigrateTo): if isinstance(r, raw.types.auth.LoginTokenMigrateTo):
if not self.test_mode:
await self.update_dc_option()
# pylint: disable=access-member-before-definition # pylint: disable=access-member-before-definition
await self.session.stop() await self.session.stop()

View file

@ -21,6 +21,9 @@ from .answer_pre_checkout_query import AnswerPreCheckoutQuery
from .answer_shipping_query import AnswerShippingQuery from .answer_shipping_query import AnswerShippingQuery
from .delete_business_messages import DeleteBusinessMessages from .delete_business_messages import DeleteBusinessMessages
from .get_business_connection import GetBusinessConnection from .get_business_connection import GetBusinessConnection
from .get_business_account_gifts import GetBusinessAccountGifts
from .get_business_account_star_balance import GetBusinessAccountStarBalance
from .transfer_business_account_stars import TransferBusinessAccountStars
class TelegramBusiness( class TelegramBusiness(
@ -28,5 +31,8 @@ class TelegramBusiness(
AnswerShippingQuery, AnswerShippingQuery,
DeleteBusinessMessages, DeleteBusinessMessages,
GetBusinessConnection, GetBusinessConnection,
GetBusinessAccountGifts,
GetBusinessAccountStarBalance,
TransferBusinessAccountStars,
): ):
pass pass

View file

@ -0,0 +1,129 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Optional
import pyrogram
from pyrogram import raw, types
class GetBusinessAccountGifts:
async def get_business_account_gifts(
self: "pyrogram.Client",
business_connection_id: str,
exclude_unsaved: Optional[bool] = None,
exclude_saved: Optional[bool] = None,
exclude_unlimited: Optional[bool] = None,
exclude_limited: Optional[bool] = None,
exclude_upgraded: Optional[bool] = None,
sort_by_price: Optional[bool] = None,
limit: int = 0,
offset: str = "",
):
"""Return the gifts received and owned by a managed business account.
.. note::
Requires the `can_view_gifts_and_stars` business bot right.
.. include:: /_includes/usable-by/bots.rst
Parameters:
business_connection_id (``str``):
Unique identifier of business connection on behalf of which to send the request.
exclude_unsaved (``bool``, *optional*):
Pass True to exclude gifts that arent saved to the accounts profile page.
exclude_saved (``bool``, *optional*):
Pass True to exclude gifts that are saved to the accounts profile page.
exclude_unlimited (``bool``, *optional*):
Pass True to exclude gifts that can be purchased an unlimited number of times.
exclude_limited (``bool``, *optional*):
Pass True to exclude gifts that can be purchased a limited number of times.
exclude_upgraded (``bool``, *optional*):
Pass True to exclude upgraded gifts.
sort_by_price (``bool``, *optional*):
Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.
offset (``str``, *optional*):
Offset of the first entry to return as received from the previous request.
limit (``int``, *optional*):
The maximum number of gifts to be returned.
Returns:
``Generator``: A generator yielding :obj:`~pyrogram.types.Gift` objects.
Example:
.. code-block:: python
async for gift in app.get_business_account_gifts(connection_id):
print(gift)
"""
current = 0
total = abs(limit) or (1 << 31) - 1
limit = min(100, total)
connection_info = await self.get_business_connection(business_connection_id)
while True:
r = await self.invoke(
raw.functions.payments.GetSavedStarGifts(
peer=await self.resolve_peer(connection_info.user.id),
offset=offset,
limit=limit,
exclude_unsaved=exclude_unsaved,
exclude_saved=exclude_saved,
exclude_unlimited=exclude_unlimited,
exclude_limited=exclude_limited,
exclude_unique=exclude_upgraded,
sort_by_value=sort_by_price
),
sleep_threshold=60,
business_connection_id=business_connection_id
)
users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
user_star_gifts = [
await types.Gift._parse_saved(self, gift, users, chats)
for gift in r.gifts
]
if not user_star_gifts:
return
for gift in user_star_gifts:
yield gift
current += 1
if current >= total:
return
offset = r.next_offset
if not offset:
return

View file

@ -0,0 +1,61 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Optional, Union
import pyrogram
from pyrogram import raw
class GetBusinessAccountStarBalance:
async def get_business_account_star_balance(
self: "pyrogram.Client",
business_connection_id: str,
) -> int:
"""Return the amount of Telegram Stars owned by a managed business account.
.. note::
Requires the `can_view_gifts_and_stars` business bot right.
.. include:: /_includes/usable-by/bots.rst
Parameters:
business_connection_id (``str``):
Unique identifier of business connection on behalf of which to send the request.
Returns:
``int``: On success, the current stars balance is returned.
Example:
.. code-block:: python
# Get stars balance
await app.get_business_account_star_balance("connection_id")
"""
connection_info = await self.get_business_connection(business_connection_id)
r = await self.invoke(
raw.functions.payments.GetStarsStatus(
peer=await self.resolve_peer(connection_info.user.id),
),
business_connection_id=business_connection_id
)
return r.balance.amount

View file

@ -0,0 +1,72 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram import raw
class TransferBusinessAccountStars:
async def transfer_business_account_stars(
self: "pyrogram.Client",
business_connection_id: str,
star_count: int,
) -> bool:
"""Transfers Telegram Stars from the business account balance to the bots balance.
.. note::
Requires the `can_transfer_stars` business bot right.
.. include:: /_includes/usable-by/users.rst
Parameters:
business_connection_id (``str``):
Unique identifier of the business connection.
star_count (``int`` | ``str``):
Number of Telegram Stars to transfer, 1-10000.
Returns:
``bool``: On success, True is returned.
"""
# Why telegram won't let us just use InputPeerSelf :(
if self.me:
bot_id = self.me.id
else:
bot_id = (
await self.invoke(raw.functions.users.GetUsers(id=[raw.types.InputPeerSelf()]))
)[0].id
invoice = raw.types.InputInvoiceBusinessBotTransferStars(
bot=await self.resolve_peer(bot_id), stars=star_count
)
payment_form = await self.invoke(
raw.functions.payments.GetPaymentForm(invoice=invoice),
business_connection_id=business_connection_id,
)
await self.invoke(
raw.functions.payments.SendStarsForm(
form_id=payment_form.form_id,
invoice=invoice,
),
business_connection_id=business_connection_id,
)
return True

View file

@ -33,7 +33,8 @@ async def get_chunk(
from_message_id: int = 0, from_message_id: int = 0,
from_date: datetime = utils.zero_datetime(), from_date: datetime = utils.zero_datetime(),
min_id: int = 0, min_id: int = 0,
max_id: int = 0 max_id: int = 0,
reverse: Optional[bool] = None
): ):
messages = await client.invoke( messages = await client.invoke(
raw.functions.messages.GetHistory( raw.functions.messages.GetHistory(
@ -48,6 +49,8 @@ async def get_chunk(
), ),
sleep_threshold=60 sleep_threshold=60
) )
if reverse:
messages.messages.reverse()
return await utils.parse_messages(client, messages, replies=0) return await utils.parse_messages(client, messages, replies=0)
@ -61,7 +64,8 @@ class GetChatHistory:
offset_id: int = 0, offset_id: int = 0,
offset_date: datetime = utils.zero_datetime(), offset_date: datetime = utils.zero_datetime(),
min_id: int = 0, min_id: int = 0,
max_id: int = 0 max_id: int = 0,
reverse: Optional[bool] = None
) -> Optional[AsyncGenerator["types.Message", None]]: ) -> Optional[AsyncGenerator["types.Message", None]]:
"""Get messages from a chat history. """Get messages from a chat history.
@ -96,6 +100,9 @@ class GetChatHistory:
max_id: (``int``, *optional*): max_id: (``int``, *optional*):
The maximum message id. you will not get any message which have id greater than max_id. The maximum message id. you will not get any message which have id greater than max_id.
reverse (``bool``, *optional*):
Pass True to retrieve the messages in reversed order (from older to most recent).
Returns: Returns:
``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects. ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.
@ -118,7 +125,8 @@ class GetChatHistory:
from_message_id=offset_id, from_message_id=offset_id,
from_date=offset_date, from_date=offset_date,
min_id=min_id, min_id=min_id,
max_id=max_id max_id=max_id,
reverse=reverse
) )
if not messages: if not messages:

View file

@ -52,6 +52,7 @@ class SendAnimation:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None, schedule_date: datetime = None,
@ -145,6 +146,11 @@ class SendAnimation:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -226,6 +232,7 @@ class SendAnimation:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -50,6 +50,7 @@ class SendAudio:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
message_effect_id: int = None, message_effect_id: int = None,
@ -137,6 +138,11 @@ class SendAudio:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -216,6 +222,7 @@ class SendAudio:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -40,6 +40,7 @@ class SendCachedMedia:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None, schedule_date: datetime = None,
@ -104,6 +105,11 @@ class SendCachedMedia:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -144,6 +150,7 @@ class SendCachedMedia:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -38,6 +38,7 @@ class SendContact:
business_connection_id: str = None, business_connection_id: str = None,
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
@ -95,6 +96,11 @@ class SendContact:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -139,6 +145,7 @@ class SendContact:
reply_to_message_id=reply_to_message_id, reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -36,6 +36,7 @@ class SendDice:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
@ -91,6 +92,11 @@ class SendDice:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -143,6 +149,7 @@ class SendDice:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -48,6 +48,7 @@ class SendDocument:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
message_effect_id: int = None, message_effect_id: int = None,
@ -129,6 +130,11 @@ class SendDocument:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -203,6 +209,7 @@ class SendDocument:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -38,6 +38,7 @@ class SendLocation:
business_connection_id: str = None, business_connection_id: str = None,
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
@ -89,6 +90,11 @@ class SendLocation:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
reply_to_message_id (``int``, *optional*): reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message If the message is a reply, ID of the original message
@ -136,6 +142,7 @@ class SendLocation:
reply_to_message_id=reply_to_message_id, reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -56,6 +56,7 @@ class SendMediaGroup:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
@ -104,6 +105,11 @@ class SendMediaGroup:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -180,6 +186,7 @@ class SendMediaGroup:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode, parse_mode=parse_mode,
@ -271,7 +278,7 @@ class SendMediaGroup:
w=i.width, w=i.width,
h=i.height h=i.height
), ),
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)), raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media)),
] ]
if is_animation: if is_animation:
attributes.append(raw.types.DocumentAttributeAnimated()) attributes.append(raw.types.DocumentAttributeAnimated())
@ -339,7 +346,7 @@ class SendMediaGroup:
w=i.width, w=i.width,
h=i.height h=i.height
), ),
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "video.mp4")), raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "video.mp4")),
], ],
), ),
), ),
@ -371,7 +378,7 @@ class SendMediaGroup:
performer=i.performer, performer=i.performer,
title=i.title title=i.title
), ),
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)), raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media)),
], ],
), ),
), ),
@ -419,7 +426,7 @@ class SendMediaGroup:
performer=i.performer, performer=i.performer,
title=i.title title=i.title
), ),
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "audio.mp3")), raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "audio.mp3")),
], ],
), ),
), ),
@ -445,7 +452,7 @@ class SendMediaGroup:
file=file, file=file,
thumb=thumb, thumb=thumb,
attributes=[ attributes=[
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)), raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media)),
], ],
), ),
), ),
@ -490,7 +497,7 @@ class SendMediaGroup:
file=file, file=file,
thumb=thumb, thumb=thumb,
attributes=[ attributes=[
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "file.zip")), raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "file.zip")),
], ],
), ),
), ),

View file

@ -39,6 +39,7 @@ class SendMessage:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: int = None, reply_to_chat_id: int = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None, schedule_date: datetime = None,
@ -100,6 +101,11 @@ class SendMessage:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of the monoforum.
for reply to message from a monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -174,6 +180,7 @@ class SendMessage:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -46,6 +46,7 @@ class SendPhoto:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None, schedule_date: datetime = None,
@ -122,6 +123,11 @@ class SendPhoto:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -203,6 +209,7 @@ class SendPhoto:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -44,6 +44,7 @@ class SendSticker:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
@ -104,6 +105,11 @@ class SendSticker:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -178,6 +184,7 @@ class SendSticker:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -50,6 +50,7 @@ class SendVideo:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
cover: Union[str, BinaryIO] = None, cover: Union[str, BinaryIO] = None,
@ -151,6 +152,11 @@ class SendVideo:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -251,6 +257,7 @@ class SendVideo:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -45,6 +45,7 @@ class SendVideoNote:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
@ -118,6 +119,11 @@ class SendVideoNote:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -197,6 +203,7 @@ class SendVideoNote:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -46,6 +46,7 @@ class SendVoice:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None, schedule_date: datetime = None,
@ -121,6 +122,11 @@ class SendVoice:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -189,6 +195,7 @@ class SendVoice:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -39,6 +39,7 @@ class SendWebPage:
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
reply_to_chat_id: Union[int, str] = None, reply_to_chat_id: Union[int, str] = None,
reply_to_monoforum_id: Union[int, str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None, schedule_date: datetime = None,
@ -106,6 +107,11 @@ class SendWebPage:
for reply to message from another chat. for reply to message from another chat.
You can also use chat public link in form of *t.me/<username>* (str). You can also use chat public link in form of *t.me/<username>* (str).
reply_to_monoforum_id (``int`` | ``str``, *optional*):
Unique identifier for the target user of monoforum.
for reply to message from monoforum.
for channel administrators only.
quote_text (``str``, *optional*): quote_text (``str``, *optional*):
Text to quote. Text to quote.
for reply_to_message only. for reply_to_message only.
@ -161,6 +167,7 @@ class SendWebPage:
reply_to_story_id=reply_to_story_id, reply_to_story_id=reply_to_story_id,
message_thread_id=message_thread_id, message_thread_id=message_thread_id,
reply_to_chat_id=reply_to_chat_id, reply_to_chat_id=reply_to_chat_id,
reply_to_monoforum_id=reply_to_monoforum_id,
quote_text=quote_text, quote_text=quote_text,
quote_entities=quote_entities, quote_entities=quote_entities,
parse_mode=parse_mode parse_mode=parse_mode

View file

@ -31,11 +31,15 @@ from .get_chat_gifts_count import GetChatGiftsCount
from .get_chat_gifts import GetChatGifts from .get_chat_gifts import GetChatGifts
from .hide_gift import HideGift from .hide_gift import HideGift
from .refund_stars_payment import RefundStarPayment from .refund_stars_payment import RefundStarPayment
from .search_gifts_for_resale import SearchGiftsForResale
from .send_invoice import SendInvoice from .send_invoice import SendInvoice
from .send_paid_media import SendPaidMedia from .send_paid_media import SendPaidMedia
from .send_paid_reaction import SendPaidReaction from .send_paid_reaction import SendPaidReaction
from .send_payment_form import SendPaymentForm from .send_payment_form import SendPaymentForm
from .send_gift import SendGift from .send_gift import SendGift
from .send_resold_gift import SendResoldGift
from .set_gift_resale_price import SetGiftResalePrice
from .set_pinned_gifts import SetPinnedGifts
from .show_gift import ShowGift from .show_gift import ShowGift
from .transfer_gift import TransferGift from .transfer_gift import TransferGift
from .upgrade_gift import UpgradeGift from .upgrade_gift import UpgradeGift
@ -55,11 +59,15 @@ class Payments(
GetChatGifts, GetChatGifts,
HideGift, HideGift,
RefundStarPayment, RefundStarPayment,
SearchGiftsForResale,
SendPaidReaction, SendPaidReaction,
SendPaidMedia, SendPaidMedia,
SendInvoice, SendInvoice,
SendPaymentForm, SendPaymentForm,
SendGift, SendGift,
SendResoldGift,
SetGiftResalePrice,
SetPinnedGifts,
ShowGift, ShowGift,
TransferGift, TransferGift,
UpgradeGift UpgradeGift

View file

@ -47,7 +47,7 @@ class GetUpgradedGift:
# Get information about upgraded gift by slug # Get information about upgraded gift by slug
gift = await client.get_upgraded_gift("SignetRing-903") gift = await client.get_upgraded_gift("SignetRing-903")
""" """
match = re.match(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:nft/|\+))([\w-]+)$", link) match = self.UPGRADED_GIFT_RE.match(link)
if match: if match:
slug = match.group(1) slug = match.group(1)

View file

@ -0,0 +1,110 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from typing import List, Optional
import pyrogram
from pyrogram import enums, raw, types
class SearchGiftsForResale:
async def search_gifts_for_resale(
self: "pyrogram.Client",
gift_id: int,
order: "enums.GiftForResaleOrder" = enums.GiftForResaleOrder.CHANGE_DATE,
attributes: Optional[List["types.UpgradedGiftAttributeId"]] = None,
limit: int = 0,
offset: str = ""
):
"""Get upgraded gifts that can be bought from other owners.
.. include:: /_includes/usable-by/users.rst
Parameters:
gift_id (``int``):
Identifier of the regular gift that was upgraded to a unique gift.
order (:obj:`~pyrogram.enums.GiftForResaleOrder`):
Order in which the results will be sorted.
attributes (List of :obj:`~pyrogram.types.UpgradedGiftAttributeId`, *optional*):
Attributes used to filter received gifts.
If multiple attributes of the same type are specified, then all of them are allowed.
If none attributes of specific type are specified, then all values for this attribute type are allowed.
limit (``int``, *optional*):
The maximum number of gifts to return. Default is 0 (no limit).
offset (``str``, *optional*):
The offset from which to start returning results. Default is "" (no offset).
Returns:
``Generator``: A generator yielding :obj:`~pyrogram.types.Gift` objects.
Example:
.. code-block:: python
async for gift in app.search_gifts_for_resale(gift_id=123456):
print(gift)
# Buy first gift from resale market
async for gift in app.search_gifts_for_resale(gift_id=123456, limit=1):
await app.send_resold_gift(gift_link=gift.link, new_owner_chat_id="me") # or just use await gift.buy()
"""
current = 0
total = abs(limit) or (1 << 31) - 1
limit = min(100, total)
while True:
r = await self.invoke(
raw.functions.payments.GetResaleStarGifts(
gift_id=gift_id,
offset=offset,
limit=limit,
sort_by_price=order == enums.GiftForResaleOrder.PRICE,
sort_by_num=order == enums.GiftForResaleOrder.NUMBER,
attributes=[attr.write() for attr in attributes] if attributes else None,
),
sleep_threshold=60
)
users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
gifts = [
await types.Gift._parse(self, gift, users, chats)
for gift in r.gifts
]
if not gifts:
return
for gift in gifts:
yield gift
current += 1
if current >= total:
return
offset = r.next_offset
if not offset:
return

View file

@ -0,0 +1,89 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from typing import Optional, Union
import pyrogram
from pyrogram import raw, types, utils
class SendResoldGift:
async def send_resold_gift(
self: "pyrogram.Client",
gift_link: str,
new_owner_chat_id: Union[int, str],
) -> Optional["types.Message"]:
"""Send an upgraded gift that is available for resale to another user or channel chat.
.. note::
Gifts already owned by the current user must be transferred using :meth:`~pyrogram.Client.transfer_gift` and can't be passed to this method.
.. include:: /_includes/usable-by/users.rst
Parameters:
gift_link (``str``):
Link to the gift.
new_owner_chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat you want to transfer the star gift to.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
Returns:
:obj:`~pyrogram.types.Message`: On success, the sent message is returned.
Example:
.. code-block:: python
# Transfer gift to another user
await app.send_resold_gift(gift_link="https://t.me/nft/NekoHelmet-9215", new_owner_chat_id=123)
"""
match = self.UPGRADED_GIFT_RE.match(gift_link)
if not match:
raise ValueError(
"Invalid gift link provided."
)
peer = await self.resolve_peer(new_owner_chat_id)
invoice = raw.types.InputInvoiceStarGiftResale(
slug=match.group(1),
to_id=peer
)
r = await self.invoke(
raw.functions.payments.SendStarsForm(
form_id=(await self.invoke(
raw.functions.payments.GetPaymentForm(
invoice=invoice
),
)).form_id,
invoice=invoice
),
)
messages = await utils.parse_messages(
client=self,
messages=r.updates if isinstance(r, raw.types.payments.PaymentResult) else r
)
return messages[0] if messages else None

View file

@ -0,0 +1,82 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
import re
import pyrogram
from pyrogram import raw
class SetGiftResalePrice:
async def set_gift_resale_price(
self: "pyrogram.Client",
owned_gift_id: str,
resale_star_count: int
) -> bool:
"""Change resale price of a unique gift owned by the current user.
.. include:: /_includes/usable-by/users.rst
Parameters:
owned_gift_id (``str``):
Unique identifier of the target gift.
For a user gift, you can use the message ID (int) of the gift message.
For a channel gift, you can use the packed format `chatID_savedID` (str).
For a upgraded gift, you can use the gift link.
resale_star_count (``int``):
The new price for the unique gift. Pass 0 to disallow gift resale.
Returns:
``bool``: On success, True is returned.
Example:
.. code-block:: python
# Change resale price of a unique gift
await app.set_gift_resale_price(owned_gift_id="123456", resale_star_count=100)
"""
if not isinstance(owned_gift_id, str):
raise ValueError(f"owned_gift_id has to be str, but {type(owned_gift_id)} was provided")
saved_gift_match = re.match(r"^(-\d+)_(\d+)$", owned_gift_id)
slug_match = self.UPGRADED_GIFT_RE.match(owned_gift_id)
if saved_gift_match:
stargift = raw.types.InputSavedStarGiftChat(
peer=await self.resolve_peer(saved_gift_match.group(1)),
saved_id=int(saved_gift_match.group(2))
)
elif slug_match:
stargift = raw.types.InputSavedStarGiftSlug(
slug=slug_match.group(1)
)
else:
stargift = raw.types.InputSavedStarGiftUser(
msg_id=int(owned_gift_id)
)
await self.invoke(
raw.functions.payments.UpdateStarGiftPrice(
stargift=stargift,
resell_stars=resale_star_count
)
)
return True

View file

@ -0,0 +1,95 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
import re
from typing import List, Union
import pyrogram
from pyrogram import raw
class SetPinnedGifts:
async def set_pinned_gifts(
self: "pyrogram.Client",
owner_id: Union[int, str],
owned_gift_ids: List[str],
) -> bool:
"""Change the list of pinned gifts on the current user.
.. include:: /_includes/usable-by/users.rst
Parameters:
owner_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
owned_gift_ids (List of ``str``):
New list of pinned gifts.
All gifts must be upgraded and saved on the profile page first.
For a user gift, you can use the message ID (int) of the gift message.
For a channel gift, you can use the packed format `chatID_savedID` (str).
For a upgraded gift, you can use the gift link.
Returns:
``bool``: On success, True is returned.
Example:
.. code-block:: python
# Set pinned gifts in user profile
await app.set_pinned_gifts(received_gift_ids=["123", "456"])
"""
stargifts = []
for gift in owned_gift_ids:
if not isinstance(gift, str):
raise ValueError(f"gift id has to be str, but {type(gift)} was provided")
saved_gift_match = re.match(r"^(\d+)_(\d+)$", str(gift))
slug_match = self.UPGRADED_GIFT_RE.match(str(gift))
if saved_gift_match:
stargifts.append(
raw.types.InputSavedStarGiftChat(
peer=await self.resolve_peer(saved_gift_match.group(1)),
saved_id=int(saved_gift_match.group(2))
)
)
elif slug_match:
stargifts.append(
raw.types.InputSavedStarGiftSlug(
slug=slug_match.group(1)
)
)
else:
stargifts.append(
raw.types.InputSavedStarGiftUser(
msg_id=int(gift)
)
)
r = await self.invoke(
raw.functions.payments.ToggleStarGiftsPinnedToTop(
peer=await self.resolve_peer(owner_id),
stargift=stargifts
)
)
return r

View file

@ -0,0 +1,25 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from .get_call_members import GetCallMembers
class Phone(
GetCallMembers
):
pass

View file

@ -0,0 +1,103 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Union, AsyncGenerator
import pyrogram
from pyrogram import types, raw
class GetCallMembers:
async def get_call_members(
self: "pyrogram.Client",
chat_id: Union[int, str],
limit: int = 0
) -> AsyncGenerator["types.GroupCallMember", None]:
"""Get the members list of a chat call.
A chat can be either a basic group or a supergroup.
.. include:: /_includes/usable-by/users.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
limit (``int``, *optional*):
Limits the number of members to be retrieved.
Returns:
``Generator``: On success, a generator yielding :obj:`~pyrogram.types.GroupCallMember` objects is returned.
Example:
.. code-block:: python
# Get members
async for member in app.get_call_members(chat_id):
print(member)
"""
peer = await self.resolve_peer(chat_id)
if isinstance(peer, raw.types.InputPeerChannel):
r = await self.invoke(raw.functions.channels.GetFullChannel(channel=peer))
elif isinstance(peer, raw.types.InputPeerChat):
r = await self.invoke(raw.functions.messages.GetFullChat(chat_id=peer.chat_id))
else:
raise ValueError("Target chat should be group, supergroup or channel.")
full_chat = r.full_chat
if not getattr(full_chat, "call", None):
raise ValueError("There is no active call in this chat.")
current = 0
offset = ""
total = abs(limit) or (1 << 31) - 1
limit = min(20, total)
while True:
r = await self.invoke(
raw.functions.phone.GetGroupParticipants(
call=full_chat.call,
ids=[],
sources=[],
offset=offset,
limit=limit
),
sleep_threshold=60
)
users = {u.id: u for u in r.users}
chats = {c.id: c for c in r.chats}
members = [
types.GroupCallMember._parse(self, member, users, chats)
for member in r.participants
]
if not members:
return
offset = r.next_offset
for member in members:
yield member
current += 1
if current >= total:
return

View file

@ -45,11 +45,13 @@ class Auth:
dc_id: int, dc_id: int,
test_mode: bool test_mode: bool
): ):
self.client = client
self.dc_id = dc_id self.dc_id = dc_id
self.test_mode = test_mode self.test_mode = test_mode
self.ipv6 = client.ipv6 self.ipv6 = client.ipv6
self.alt_port = client.alt_port self.alt_port = client.alt_port
self.proxy = client.proxy self.proxy = client.proxy
self.storage = client.storage
self.connection_factory = client.connection_factory self.connection_factory = client.connection_factory
self.protocol_factory = client.protocol_factory self.protocol_factory = client.protocol_factory
@ -85,10 +87,19 @@ class Auth:
# The server may close the connection at any time, causing the auth key creation to fail. # The server may close the connection at any time, causing the auth key creation to fail.
# If that happens, just try again up to MAX_RETRIES times. # If that happens, just try again up to MAX_RETRIES times.
if not self.test_mode:
address, port, _ = await self.storage.get_dc_address(self.dc_id, self.ipv6)
else:
address = self.client.test_addr
port = self.client.test_port
if address is None or port is None:
raise ValueError("Test address and port must be set for test mode.")
while True: while True:
self.connection = self.connection_factory( self.connection = self.connection_factory(
dc_id=self.dc_id, dc_id=self.dc_id,
test_mode=self.test_mode, test_mode=self.test_mode,
server_ip=address,
server_port=port,
ipv6=self.ipv6, ipv6=self.ipv6,
alt_port=self.alt_port, alt_port=self.alt_port,
proxy=self.proxy, proxy=self.proxy,

View file

@ -104,10 +104,19 @@ class Session:
self.loop = asyncio.get_event_loop() self.loop = asyncio.get_event_loop()
async def start(self): async def start(self):
if not self.test_mode:
address, port, _ = await self.client.storage.get_dc_address(self.dc_id, self.client.ipv6, self.is_media)
else:
address = self.client.test_addr
port = self.client.test_port
if address is None or port is None:
raise ValueError("Test address and port must be set for test mode.")
while True: while True:
self.connection = self.client.connection_factory( self.connection = self.client.connection_factory(
dc_id=self.dc_id, dc_id=self.dc_id,
test_mode=self.test_mode, test_mode=self.test_mode,
server_ip=address,
server_port=port,
ipv6=self.client.ipv6, ipv6=self.client.ipv6,
alt_port=self.client.alt_port, alt_port=self.client.alt_port,
proxy=self.client.proxy, proxy=self.client.proxy,

View file

@ -68,6 +68,12 @@ class FileStorage(SQLiteStorage):
version += 1 version += 1
if version == 4:
with self.conn:
self.conn.executescript(self.UPDATE_DC_SCHEMA)
version += 1
self.version(version) self.version(version)
async def open(self): async def open(self):

View file

@ -77,6 +77,7 @@ class MongoStorage(Storage):
self._session = database['session'] self._session = database['session']
self._usernames = database['usernames'] self._usernames = database['usernames']
self._states = database['update_state'] self._states = database['update_state']
self._dc_options = database['dc_options']
self._remove_peers = remove_peers self._remove_peers = remove_peers
async def open(self): async def open(self):
@ -221,6 +222,51 @@ class MongoStorage(Storage):
return get_input_peer(r['_id'], r['access_hash'], r['type']) return get_input_peer(r['_id'], r['access_hash'], r['type'])
async def update_dc_address(
self,
value: Tuple[int, str, int, bool, bool, bool] = object
):
"""
Updates or inserts a data center address.
Parameters:
value (Tuple[int, str, int, bool]): A tuple containing:
- dc_id (int): Data center ID.
- address (str): Address of the data center.
- port (int): Port of the data center.
- is_ipv6 (bool): Whether the address is IPv6.
- is_media (bool): Whether it is a media data center.
- is_default_ip (bool): Whether it is the dc IP address provided by library.
"""
if value == object:
return
await self._dc_options.update_one(
{"$and": [
{'dc_id': value[0]},
{'is_ipv6': value[3]},
{'is_media': value[4]}
]},
{'$set': {'address': value[1], 'port': value[2], 'is_default_ip': value[6]}},
upsert=True
)
async def get_dc_address(
self,
dc_id: int,
is_ipv6: bool,
media: bool = False
) -> Tuple[str, int]:
if dc_id in [1,3,5] and media:
media = False
r = await self._dc_options.find_one(
{'dc_id': dc_id, 'is_ipv6': is_ipv6, 'is_media': media},
{'address': 1, 'port': 1, 'is_default_ip': 1}
)
if r is None:
return None
return r['address'], r['port'], r.get['is_default_ip']
async def _get(self): async def _get(self):
attr = inspect.stack()[2].function attr = inspect.stack()[2].function
d = await self._session.find_one({'_id': 0}, {attr: 1}) d = await self._session.find_one({'_id': 0}, {attr: 1})

View file

@ -97,6 +97,21 @@ END;
""" """
UPDATE_DC_SCHEMA = """
CREATE TABLE dc_options
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
dc_id INTEGER,
address TEXT,
port INTEGER,
is_ipv6 BOOLEAN,
is_media BOOLEAN,
is_default_ip BOOLEAN,
UNIQUE(dc_id, is_ipv6, is_media)
);
"""
def get_input_peer(peer_id: int, access_hash: int, peer_type: str): def get_input_peer(peer_id: int, access_hash: int, peer_type: str):
if peer_type in ["user", "bot"]: if peer_type in ["user", "bot"]:
return raw.types.InputPeerUser( return raw.types.InputPeerUser(
@ -121,6 +136,7 @@ def get_input_peer(peer_id: int, access_hash: int, peer_type: str):
class SQLiteStorage(Storage): class SQLiteStorage(Storage):
VERSION = 4 VERSION = 4
USERNAME_TTL = 8 * 60 * 60 USERNAME_TTL = 8 * 60 * 60
UPDATE_DC_SCHEMA = globals().get("UPDATE_DC_SCHEMA", "")
def __init__(self, name: str): def __init__(self, name: str):
super().__init__(name) super().__init__(name)
@ -131,6 +147,7 @@ class SQLiteStorage(Storage):
with self.conn: with self.conn:
self.conn.executescript(SCHEMA) self.conn.executescript(SCHEMA)
self.conn.executescript(UNAME_SCHEMA) self.conn.executescript(UNAME_SCHEMA)
self.conn.executescript(self.UPDATE_DC_SCHEMA)
self.conn.execute( self.conn.execute(
"INSERT INTO version VALUES (?)", "INSERT INTO version VALUES (?)",
@ -252,6 +269,61 @@ class SQLiteStorage(Storage):
return get_input_peer(*r) return get_input_peer(*r)
async def update_dc_address(
self,
value: Tuple[int, str, int, bool, bool, bool, bool] = object
):
"""
Updates or inserts a data center address.
Parameters:
value (Tuple[int, str, int, bool, bool, bool]): A tuple containing:
- dc_id (int): Data center ID.
- address (str): Address of the data center.
- port (int): Port of the data center.
- is_ipv6 (bool): Whether the address is IPv6.
- is_media (bool): Whether it is a media data center.
- is_default_ip (bool): Whether it is the dc IP address provided by library.
"""
if value == object:
return
with self.conn:
self.conn.execute(
"""
INSERT INTO dc_options (dc_id, address, port, is_ipv6, is_media)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(dc_id, is_ipv6, is_media, is_default_ip)
DO UPDATE SET address=excluded.address, port=excluded.port
""",
value
)
async def get_dc_address(
self,
dc_id: int,
is_ipv6: bool,
media: bool = False
) -> Tuple[str, int]:
"""
Retrieves the address of a data center.
Parameters:
dc_id (int): Data center ID.
is_ipv6 (bool): Whether the address is IPv6.
media (bool): Whether it is a media data center.
Returns:
Tuple[str, int]: A tuple containing the address and port of the data center.
"""
if dc_id in [1,3,5] and media:
media = False
r = self.conn.execute(
"SELECT address, port, is_default_ip FROM dc_options WHERE dc_id = ? AND is_ipv6 = ? AND is_media = ?",
(dc_id, is_ipv6, media)
).fetchone()
return r
def _get(self): def _get(self):
attr = inspect.stack()[2].function attr = inspect.stack()[2].function

View file

@ -76,6 +76,21 @@ class Storage:
async def get_peer_by_phone_number(self, phone_number: str): async def get_peer_by_phone_number(self, phone_number: str):
raise NotImplementedError raise NotImplementedError
async def update_dc_address(
self,
value: Tuple[int, str, int, bool, bool] = object
):
raise NotImplementedError
async def get_dc_address(
self,
dc_id: int,
is_ipv6: bool,
test_mode: bool = False,
media: bool = False
):
raise NotImplementedError
async def dc_id(self, value: int = object): async def dc_id(self, value: int = object):
raise NotImplementedError raise NotImplementedError

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from pyrogram import raw, types from pyrogram import enums, raw, types
from ..object import Object from ..object import Object
from typing import Union from typing import Union
@ -99,15 +99,21 @@ class KeyboardButton(Object):
if isinstance(b, raw.types.KeyboardButtonRequestPeer): if isinstance(b, raw.types.KeyboardButtonRequestPeer):
if isinstance(b.peer_type, raw.types.RequestPeerTypeBroadcast): if isinstance(b.peer_type, raw.types.RequestPeerTypeBroadcast):
user_privileges = getattr(b.peer_type, "user_admin_rights", None)
bot_privileges = getattr(b.peer_type, "bot_admin_rights", None)
return KeyboardButton( return KeyboardButton(
text=b.text, text=b.text,
request_chat=types.RequestPeerTypeChannel( request_chat=types.RequestPeerTypeChannel(
is_creator=b.peer_type.creator, is_creator=b.peer_type.creator,
is_username=b.peer_type.has_username, is_username=b.peer_type.has_username,
max=b.max_quantity max=b.max_quantity,
user_privileges=user_privileges,
bot_privileges=bot_privileges
) )
) )
if isinstance(b.peer_type, raw.types.RequestPeerTypeChat): if isinstance(b.peer_type, raw.types.RequestPeerTypeChat):
user_privileges = getattr(b.peer_type, "user_admin_rights", None)
bot_privileges = getattr(b.peer_type, "bot_admin_rights", None)
return KeyboardButton( return KeyboardButton(
text=b.text, text=b.text,
request_chat=types.RequestPeerTypeChat( request_chat=types.RequestPeerTypeChat(
@ -115,7 +121,9 @@ class KeyboardButton(Object):
is_bot_participant=b.peer_type.bot_participant, is_bot_participant=b.peer_type.bot_participant,
is_username=b.peer_type.has_username, is_username=b.peer_type.has_username,
is_forum=b.peer_type.forum, is_forum=b.peer_type.forum,
max=b.max_quantity max=b.max_quantity,
user_privileges=user_privileges,
bot_privileges=bot_privileges
) )
) )
@ -135,13 +143,52 @@ class KeyboardButton(Object):
elif self.request_location: elif self.request_location:
return raw.types.KeyboardButtonRequestGeoLocation(text=self.text) return raw.types.KeyboardButtonRequestGeoLocation(text=self.text)
elif self.request_chat: elif self.request_chat:
user_privileges = self.request_chat.user_privileges
bot_privileges = self.request_chat.bot_privileges
user_admin_rights = raw.types.ChatAdminRights(
change_info=user_privileges.can_change_info,
post_messages=user_privileges.can_post_messages,
post_stories=user_privileges.can_post_stories,
edit_messages=user_privileges.can_edit_messages,
edit_stories=user_privileges.can_post_stories,
delete_messages=user_privileges.can_delete_messages,
delete_stories=user_privileges.can_delete_stories,
ban_users=user_privileges.can_restrict_members,
invite_users=user_privileges.can_invite_users,
pin_messages=user_privileges.can_pin_messages,
add_admins=user_privileges.can_promote_members,
anonymous=user_privileges.is_anonymous,
manage_call=user_privileges.can_manage_video_chats,
other=user_privileges.can_manage_chat
) if user_privileges else None
bot_admin_rights = raw.types.ChatAdminRights(
change_info=bot_privileges.can_change_info,
post_messages=bot_privileges.can_post_messages,
post_stories=bot_privileges.can_post_stories,
edit_messages=bot_privileges.can_edit_messages,
edit_stories=bot_privileges.can_post_stories,
delete_messages=bot_privileges.can_delete_messages,
delete_stories=bot_privileges.can_delete_stories,
ban_users=bot_privileges.can_restrict_members,
invite_users=bot_privileges.can_invite_users,
pin_messages=bot_privileges.can_pin_messages,
add_admins=bot_privileges.can_promote_members,
anonymous=bot_privileges.is_anonymous,
manage_call=bot_privileges.can_manage_video_chats,
other=bot_privileges.can_manage_chat
) if bot_privileges else None
if isinstance(self.request_chat, types.RequestPeerTypeChannel): if isinstance(self.request_chat, types.RequestPeerTypeChannel):
return raw.types.InputKeyboardButtonRequestPeer( return raw.types.InputKeyboardButtonRequestPeer(
text=self.text, text=self.text,
button_id=self.request_chat.button_id, button_id=self.request_chat.button_id,
peer_type=raw.types.RequestPeerTypeBroadcast( peer_type=raw.types.RequestPeerTypeBroadcast(
creator=self.request_chat.is_creator, creator=self.request_chat.is_creator,
has_username=self.request_chat.is_username has_username=self.request_chat.is_username,
user_admin_rights=user_admin_rights,
bot_admin_rights=bot_admin_rights
), ),
max_quantity=self.request_chat.max, max_quantity=self.request_chat.max,
name_requested=self.request_chat.is_name_requested, name_requested=self.request_chat.is_name_requested,
@ -155,7 +202,9 @@ class KeyboardButton(Object):
creator=self.request_chat.is_creator, creator=self.request_chat.is_creator,
bot_participant=self.request_chat.is_bot_participant, bot_participant=self.request_chat.is_bot_participant,
has_username=self.request_chat.is_username, has_username=self.request_chat.is_username,
forum=self.request_chat.is_forum forum=self.request_chat.is_forum,
user_admin_rights=user_admin_rights,
bot_admin_rights=bot_admin_rights
), ),
max_quantity=self.request_chat.max, max_quantity=self.request_chat.max,
name_requested=self.request_chat.is_name_requested, name_requested=self.request_chat.is_name_requested,

View file

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from pyrogram import types
from ..object import Object from ..object import Object
@ -47,6 +49,12 @@ class RequestPeerTypeChannel(Object):
is_photo_requested (``bool``, *optional*): is_photo_requested (``bool``, *optional*):
If True, Channel photo is requested. If True, Channel photo is requested.
default True. default True.
user_privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
Privileged actions that an user administrator is able to take.
bot_privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
Privileged actions that a bot administrator is able to take.
""" # TODO user_admin_rights, bot_admin_rights """ # TODO user_admin_rights, bot_admin_rights
def __init__( def __init__(
@ -57,7 +65,9 @@ class RequestPeerTypeChannel(Object):
max: int = 1, max: int = 1,
is_name_requested: bool = True, is_name_requested: bool = True,
is_username_requested: bool = True, is_username_requested: bool = True,
is_photo_requested: bool=True is_photo_requested: bool = True,
user_privileges: "types.ChatPrivileges" = None,
bot_privileges: "types.ChatPrivileges" = None
): ):
super().__init__() super().__init__()
@ -68,3 +78,6 @@ class RequestPeerTypeChannel(Object):
self.is_name_requested = is_name_requested self.is_name_requested = is_name_requested
self.is_username_requested = is_username_requested self.is_username_requested = is_username_requested
self.is_photo_requested = is_photo_requested self.is_photo_requested = is_photo_requested
self.user_privileges = user_privileges
self.bot_privileges = bot_privileges

View file

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from pyrogram import types
from ..object import Object from ..object import Object
@ -53,6 +55,12 @@ class RequestPeerTypeChat(Object):
is_photo_requested (``bool``, *optional*): is_photo_requested (``bool``, *optional*):
If True, Chat photo is requested. If True, Chat photo is requested.
default True. default True.
user_privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
Privileged actions that an user administrator is able to take.
bot_privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
Privileged actions that a bot administrator is able to take.
""" # TODO user_admin_rights, bot_admin_rights """ # TODO user_admin_rights, bot_admin_rights
def __init__( def __init__(
@ -65,7 +73,9 @@ class RequestPeerTypeChat(Object):
max: int = 1, max: int = 1,
is_name_requested: bool = True, is_name_requested: bool = True,
is_username_requested: bool = True, is_username_requested: bool = True,
is_photo_requested: bool=True is_photo_requested: bool = True,
user_privileges: "types.ChatPrivileges" = None,
bot_privileges: "types.ChatPrivileges" = None
): ):
super().__init__() super().__init__()
@ -78,3 +88,5 @@ class RequestPeerTypeChat(Object):
self.is_name_requested = is_name_requested self.is_name_requested = is_name_requested
self.is_username_requested = is_username_requested self.is_username_requested = is_username_requested
self.is_photo_requested = is_photo_requested self.is_photo_requested = is_photo_requested
self.user_privileges = user_privileges
self.bot_privileges = bot_privileges

View file

@ -62,6 +62,10 @@ class InputMediaAudio(InputMedia):
title (``str``, *optional*): title (``str``, *optional*):
Title of the audio Title of the audio
file_name (``str``, *optional*):
File name of the audio sent.
Defaults to file's path basename.
""" """
def __init__( def __init__(
@ -73,7 +77,8 @@ class InputMediaAudio(InputMedia):
caption_entities: List[MessageEntity] = None, caption_entities: List[MessageEntity] = None,
duration: int = 0, duration: int = 0,
performer: str = "", performer: str = "",
title: str = "" title: str = "",
file_name: str = None
): ):
super().__init__(media, caption, parse_mode, caption_entities) super().__init__(media, caption, parse_mode, caption_entities)
@ -81,3 +86,4 @@ class InputMediaAudio(InputMedia):
self.duration = duration self.duration = duration
self.performer = performer self.performer = performer
self.title = title self.title = title
self.file_name = file_name

View file

@ -51,6 +51,10 @@ class InputMediaDocument(InputMedia):
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in the caption, which can be specified instead of *parse_mode*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
file_name (``str``, *optional*):
File name of the document sent.
Defaults to file's path basename.
""" """
def __init__( def __init__(
@ -59,8 +63,10 @@ class InputMediaDocument(InputMedia):
thumb: str = None, thumb: str = None,
caption: str = "", caption: str = "",
parse_mode: Optional["enums.ParseMode"] = None, parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List[MessageEntity] = None caption_entities: List[MessageEntity] = None,
file_name: str = None
): ):
super().__init__(media, caption, parse_mode, caption_entities) super().__init__(media, caption, parse_mode, caption_entities)
self.thumb = thumb self.thumb = thumb
self.file_name = file_name

View file

@ -62,6 +62,10 @@ class InputMediaVideo(InputMedia):
duration (``int``, *optional*): duration (``int``, *optional*):
Video duration. Video duration.
file_name (``str``, *optional*):
File name of the video sent.
Defaults to file's path basename.
supports_streaming (``bool``, *optional*): supports_streaming (``bool``, *optional*):
Pass True, if the uploaded video is suitable for streaming. Pass True, if the uploaded video is suitable for streaming.
@ -79,6 +83,7 @@ class InputMediaVideo(InputMedia):
width: int = 0, width: int = 0,
height: int = 0, height: int = 0,
duration: int = 0, duration: int = 0,
file_name: str = None,
supports_streaming: bool = True, supports_streaming: bool = True,
has_spoiler: bool = None, has_spoiler: bool = None,
): ):
@ -88,5 +93,6 @@ class InputMediaVideo(InputMedia):
self.width = width self.width = width
self.height = height self.height = height
self.duration = duration self.duration = duration
self.file_name = file_name
self.supports_streaming = supports_streaming self.supports_streaming = supports_streaming
self.has_spoiler = has_spoiler self.has_spoiler = has_spoiler

View file

@ -19,6 +19,7 @@
from .input_message_content import InputMessageContent from .input_message_content import InputMessageContent
from .input_reply_to_message import InputReplyToMessage from .input_reply_to_message import InputReplyToMessage
from .input_reply_to_monoforum import InputReplyToMonoforum
from .input_reply_to_story import InputReplyToStory from .input_reply_to_story import InputReplyToStory
from .input_text_message_content import InputTextMessageContent from .input_text_message_content import InputTextMessageContent
from .input_location_message_content import InputLocationMessageContent from .input_location_message_content import InputLocationMessageContent
@ -29,6 +30,7 @@ from .input_invoice_message_content import InputInvoiceMessageContent
__all__ = [ __all__ = [
"InputMessageContent", "InputMessageContent",
"InputReplyToMessage", "InputReplyToMessage",
"InputReplyToMonoforum",
"InputReplyToStory", "InputReplyToStory",
"InputTextMessageContent", "InputTextMessageContent",
"InputLocationMessageContent", "InputLocationMessageContent",

View file

@ -0,0 +1,43 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from pyrogram import raw
from ..object import Object
class InputReplyToMonoforum(Object):
"""Contains information about a target replied monoforum.
Parameters:
monoforum_peer (:obj:`~pyrogram.raw.types.InputPeer`):
An InputPeer.
"""
def __init__(
self, *,
monoforum_peer: "raw.types.InputPeer"
):
super().__init__()
self.monoforum_peer = monoforum_peer
def write(self):
return raw.types.InputReplyToMonoForum(
monoforum_peer_id=self.monoforum_peer
).write()

View file

@ -480,6 +480,7 @@ class Message(Object, Update):
gift_code: "types.GiftCode" = None, gift_code: "types.GiftCode" = None,
gift: "types.Gift" = None, gift: "types.Gift" = None,
screenshot_taken: "types.ScreenshotTaken" = None, screenshot_taken: "types.ScreenshotTaken" = None,
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
invoice: "types.Invoice" = None, invoice: "types.Invoice" = None,
story: Union["types.MessageStory", "types.Story"] = None, story: Union["types.MessageStory", "types.Story"] = None,
alternative_videos: List["types.AlternativeVideo"] = None, alternative_videos: List["types.AlternativeVideo"] = None,
@ -596,6 +597,7 @@ class Message(Object, Update):
self.gift_code = gift_code self.gift_code = gift_code
self.gift = gift self.gift = gift
self.screenshot_taken = screenshot_taken self.screenshot_taken = screenshot_taken
self.paid_message_price_changed = paid_message_price_changed
self.invoice = invoice self.invoice = invoice
self.story = story self.story = story
self.video = video self.video = video
@ -760,6 +762,7 @@ class Message(Object, Update):
gift_code = None gift_code = None
gift = None gift = None
screenshot_taken = None screenshot_taken = None
paid_message_price_changed = None
service_type = None service_type = None
chat_join_type = None chat_join_type = None
@ -881,6 +884,9 @@ class Message(Object, Update):
elif isinstance(action, raw.types.MessageActionScreenshotTaken): elif isinstance(action, raw.types.MessageActionScreenshotTaken):
screenshot_taken = types.ScreenshotTaken() screenshot_taken = types.ScreenshotTaken()
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
elif isinstance(action, raw.types.MessageActionPaidMessagesPrice):
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
parsed_message = Message( parsed_message = Message(
id=message.id, id=message.id,
@ -926,6 +932,7 @@ class Message(Object, Update):
contact_registered=contact_registered, contact_registered=contact_registered,
gift_code=gift_code, gift_code=gift_code,
screenshot_taken=screenshot_taken, screenshot_taken=screenshot_taken,
paid_message_price_changed=paid_message_price_changed,
raw=message, raw=message,
chat_join_type=chat_join_type, chat_join_type=chat_join_type,
client=client client=client
@ -970,7 +977,7 @@ class Message(Object, Update):
else: else:
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
parsed_message.is_topic_message = True parsed_message.is_topic_message = True
elif parsed_message.chat.is_forum and parsed_message.message_thread_id is None: elif parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
parsed_message.message_thread_id = 1 parsed_message.message_thread_id = 1
parsed_message.is_topic_message = True parsed_message.is_topic_message = True
@ -1299,7 +1306,7 @@ class Message(Object, Update):
pass pass
else: else:
parsed_message.reply_to_story = reply_to_story parsed_message.reply_to_story = reply_to_story
if parsed_message.chat.is_forum and parsed_message.message_thread_id is None: if parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
parsed_message.message_thread_id = 1 parsed_message.message_thread_id = 1
parsed_message.is_topic_message = True parsed_message.is_topic_message = True
@ -1314,8 +1321,13 @@ class Message(Object, Update):
self.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL) self.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)
and self.chat.username and self.chat.username
): ):
if self.chat.type == enums.ChatType.SUPERGROUP and self.message_thread_id:
return f"https://t.me/{self.chat.username}/{self.message_thread_id}/{self.id}"
return f"https://t.me/{self.chat.username}/{self.id}" return f"https://t.me/{self.chat.username}/{self.id}"
else: if self.chat.type == enums.ChatType.PRIVATE:
return f"tg://openmessage?user_id={self.from_user.id}&message_id={self.id}"
if self.message_thread_id:
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.message_thread_id}/{self.id}"
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.id}" return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.id}"
@property @property

View file

@ -54,7 +54,7 @@ class Wallpaper(Object):
self, self,
id: int, id: int,
slug: str, slug: str,
document: "types.Document", document: "types.Document" = None,
is_creator: bool = None, is_creator: bool = None,
is_default: bool = None, is_default: bool = None,
is_pattern: bool = None, is_pattern: bool = None,
@ -73,6 +73,8 @@ class Wallpaper(Object):
@staticmethod @staticmethod
def _parse(client: "pyrogram.Client", wallpaper: "raw.base.WallPaper") -> "Wallpaper": def _parse(client: "pyrogram.Client", wallpaper: "raw.base.WallPaper") -> "Wallpaper":
doc = None
if not isinstance(wallpaper, raw.types.WallPaperNoFile):
doc = wallpaper.document doc = wallpaper.document
attributes = {type(i): i for i in doc.attributes} attributes = {type(i): i for i in doc.attributes}
@ -84,7 +86,7 @@ class Wallpaper(Object):
return Wallpaper( return Wallpaper(
id=wallpaper.id, id=wallpaper.id,
slug=wallpaper.slug, slug=wallpaper.slug,
document=types.Document._parse(client, doc, file_name), document=types.Document._parse(client, doc, file_name) if doc is not None else None,
is_creator=getattr(wallpaper, "creator", None), is_creator=getattr(wallpaper, "creator", None),
is_default=getattr(wallpaper, "default", None), is_default=getattr(wallpaper, "default", None),
is_pattern=getattr(wallpaper, "pattern", None), is_pattern=getattr(wallpaper, "pattern", None),

View file

@ -27,6 +27,7 @@ from .input_stars_transaction import InputStarsTransaction
from .invoice import Invoice from .invoice import Invoice
from .labeled_price import LabeledPrice from .labeled_price import LabeledPrice
from .paid_media import PaidMedia from .paid_media import PaidMedia
from .paid_message_price_changed import PaidMessagePriceChanged
from .payment_form import PaymentForm from .payment_form import PaymentForm
from .payment_info import PaymentInfo from .payment_info import PaymentInfo
from .payment_refunded import PaymentRefunded from .payment_refunded import PaymentRefunded
@ -46,6 +47,7 @@ __all__ = [
"Invoice", "Invoice",
"LabeledPrice", "LabeledPrice",
"PaidMedia", "PaidMedia",
"PaidMessagePriceChanged",
"PaymentForm", "PaymentForm",
"PaymentInfo", "PaymentInfo",
"PaymentRefunded", "PaymentRefunded",

View file

@ -0,0 +1,49 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from typing import List, Union
from pyrogram import raw
from pyrogram import types
from ..object import Object
class PaidMessagePriceChanged(Object):
"""A PaidMessagePriceChanged.
Parameters:
stars_amount (``int``):
Amount of stars.
extended_media (List of :obj:`~pyrogram.types.Animation` | :obj:`~pyrogram.types.ExtendedMediaPreview` | :obj:`~pyrogram.types.Photo` | :obj:`~pyrogram.types.Video`, *optional*):
Extended media.
"""
def __init__(
self,
*,
stars_amount: int,
):
super().__init__()
self.stars_amount = stars_amount
@staticmethod
def _parse(action: "raw.types.MessageActionPaidMessagesPrice") -> "PaidMessagePriceChanged":
return PaidMessagePriceChanged(
stars_amount=action.stars
)

View file

@ -43,6 +43,7 @@ from .chat_reactions import ChatReactions
from .dialog import Dialog from .dialog import Dialog
from .emoji_status import EmojiStatus from .emoji_status import EmojiStatus
from .folder import Folder from .folder import Folder
from .group_call_member import GroupCallMember
from .invite_link_importer import InviteLinkImporter from .invite_link_importer import InviteLinkImporter
from .restriction import Restriction from .restriction import Restriction
from .user import User from .user import User
@ -106,5 +107,6 @@ __all__ = [
"ChatPrivileges", "ChatPrivileges",
"ChatJoiner", "ChatJoiner",
"EmojiStatus", "EmojiStatus",
"GroupCallMember",
"ChatReactions" "ChatReactions"
] ]

View file

@ -56,9 +56,6 @@ class Chat(Object):
is_support (``bool``): is_support (``bool``):
True, if this chat is part of the Telegram support team. Users and bots only. True, if this chat is part of the Telegram support team. Users and bots only.
is_forum (``bool``, *optional*):
True, if the supergroup chat is a forum
is_participants_hidden (``bool``, *optional*): is_participants_hidden (``bool``, *optional*):
True, if the chat members are hidden. True, if the chat members are hidden.
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
@ -170,6 +167,10 @@ class Chat(Object):
The linked discussion group (in case of channels) or the linked channel (in case of supergroups). The linked discussion group (in case of channels) or the linked channel (in case of supergroups).
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
linked_forum (:obj:`~pyrogram.types.Chat`, *optional*):
The linked monoforum (in case of channels) or the linked channel (in case of monoforum).
Returned only in :meth:`~pyrogram.Client.get_chat`.
send_as_chat (:obj:`~pyrogram.types.Chat`, *optional*): send_as_chat (:obj:`~pyrogram.types.Chat`, *optional*):
The default "send_as" chat. The default "send_as" chat.
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
@ -231,7 +232,6 @@ class Chat(Object):
is_scam: bool = None, is_scam: bool = None,
is_fake: bool = None, is_fake: bool = None,
is_support: bool = None, is_support: bool = None,
is_forum: bool = None,
is_participants_hidden: bool = None, is_participants_hidden: bool = None,
is_join_request: bool = None, is_join_request: bool = None,
is_join_to_send: bool = None, is_join_to_send: bool = None,
@ -263,6 +263,7 @@ class Chat(Object):
permissions: "types.ChatPermissions" = None, permissions: "types.ChatPermissions" = None,
distance: int = None, distance: int = None,
linked_chat: "types.Chat" = None, linked_chat: "types.Chat" = None,
linked_forum: "types.Chat" = None,
send_as_chat: "types.Chat" = None, send_as_chat: "types.Chat" = None,
available_reactions: Optional["types.ChatReactions"] = None, available_reactions: Optional["types.ChatReactions"] = None,
usernames: List["types.Username"] = None, usernames: List["types.Username"] = None,
@ -286,7 +287,6 @@ class Chat(Object):
self.is_scam = is_scam self.is_scam = is_scam
self.is_fake = is_fake self.is_fake = is_fake
self.is_support = is_support self.is_support = is_support
self.is_forum = is_forum
self.is_participants_hidden = is_participants_hidden self.is_participants_hidden = is_participants_hidden
self.is_join_request = is_join_request self.is_join_request = is_join_request
self.is_join_to_send = is_join_to_send self.is_join_to_send = is_join_to_send
@ -318,6 +318,7 @@ class Chat(Object):
self.permissions = permissions self.permissions = permissions
self.distance = distance self.distance = distance
self.linked_chat = linked_chat self.linked_chat = linked_chat
self.linked_forum = linked_forum
self.send_as_chat = send_as_chat self.send_as_chat = send_as_chat
self.available_reactions = available_reactions self.available_reactions = available_reactions
self.usernames = usernames self.usernames = usernames
@ -394,6 +395,16 @@ class Chat(Object):
restriction_reason = getattr(channel, "restriction_reason", []) restriction_reason = getattr(channel, "restriction_reason", [])
user_name = getattr(channel, "username", None) user_name = getattr(channel, "username", None)
active_usernames = getattr(channel, "usernames", []) active_usernames = getattr(channel, "usernames", [])
if getattr(channel, "monoforum", None):
chat_type = enums.ChatType.MONOFORUM
elif getattr(channel, "forum", None):
chat_type = enums.ChatType.FORUM
elif getattr(channel, "megagroup", None):
chat_type = enums.ChatType.SUPERGROUP
elif getattr(channel, "broadcast", None):
chat_type = enums.ChatType.CHANNEL
else:
chat_type = enums.ChatType.GROUP
usernames = None usernames = None
if len(active_usernames) >= 1: if len(active_usernames) >= 1:
usernames = [] usernames = []
@ -410,13 +421,12 @@ class Chat(Object):
return Chat( return Chat(
id=peer_id, id=peer_id,
type=enums.ChatType.SUPERGROUP if getattr(channel, "megagroup", None) else enums.ChatType.CHANNEL, type=chat_type,
is_verified=getattr(channel, "verified", None), is_verified=getattr(channel, "verified", None),
is_restricted=getattr(channel, "restricted", None), is_restricted=getattr(channel, "restricted", None),
is_creator=getattr(channel, "creator", None), is_creator=getattr(channel, "creator", None),
is_scam=getattr(channel, "scam", None), is_scam=getattr(channel, "scam", None),
is_fake=getattr(channel, "fake", None), is_fake=getattr(channel, "fake", None),
is_forum=getattr(channel, "forum", None),
is_join_request=getattr(channel, "join_request", None), is_join_request=getattr(channel, "join_request", None),
is_join_to_send=getattr(channel, "join_to_send", None), is_join_to_send=getattr(channel, "join_to_send", None),
is_slowmode_enabled=getattr(channel, "slowmode_enabled", None), is_slowmode_enabled=getattr(channel, "slowmode_enabled", None),
@ -546,9 +556,14 @@ class Chat(Object):
linked_chat_raw = chats.get(full_chat.linked_chat_id, None) linked_chat_raw = chats.get(full_chat.linked_chat_id, None)
linked_forum_raw = chats.get(getattr(chat_raw, "linked_monoforum_id"), None)
if linked_chat_raw: if linked_chat_raw:
parsed_chat.linked_chat = Chat._parse_channel_chat(client, linked_chat_raw) parsed_chat.linked_chat = Chat._parse_channel_chat(client, linked_chat_raw)
if linked_forum_raw:
parsed_chat.linked_forum = Chat._parse_channel_chat(client, linked_forum_raw)
default_send_as = full_chat.default_send_as default_send_as = full_chat.default_send_as
if default_send_as: if default_send_as:

View file

@ -0,0 +1,149 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from datetime import datetime
from typing import Dict
import pyrogram
from pyrogram import raw, types, utils
from ..object import Object
class GroupCallMember(Object):
"""Contains information about one member of a group call.
Parameters:
chat (:obj:`~pyrogram.types.Chat`, *optional*):
Information about the user or chat.
date (:py:obj:`~datetime.datetime`, *optional*):
Date when this participant join this group call.
active_date (:py:obj:`~datetime.datetime`, *optional*):
Date when this participant last active in this group call.
volume (``int``, *optional*):
Volume, if not set the volume is set to 100%.
can_self_unmute (``bool``, *optional*):
Whether the participant can unmute themselves.
is_muted (``bool``, *optional*):
Whether the participant is muted.
is_left (``bool``, *optional*):
Whether the participant has left.
is_just_joined (``bool``, *optional*):
Whether the participant has just joined.
is_muted_by_you (``bool``, *optional*):
Whether this participant was muted by the current user.
is_volume_by_admin (``bool``, *optional*):
Whether our volume can only changed by an admin.
is_self (``bool``, *optional*):
Whether this participant is the current user.
is_video_joined (``bool``, *optional*):
Whether this participant is currently broadcasting video.
is_hand_raised (``bool``, *optional*):
Whether this participant is raised hand.
is_video_enabled (``bool``, *optional*):
Whether this participant is currently broadcasting video.
is_screen_sharing_enabled (``bool``, *optional*):
Whether this participant is currently shared screen.
"""
def __init__(
self,
*,
client: "pyrogram.Client" = None,
chat: "types.Chat" = None,
date: datetime = None,
active_date: datetime = None,
volume: int = None,
can_self_unmute: bool = None,
is_muted: bool = None,
is_left: bool = None,
is_just_joined: bool = None,
is_muted_by_you: bool = None,
is_volume_by_admin: bool = None,
is_self: bool = None,
is_video_joined: bool = None,
is_hand_raised: bool = None,
is_video_enabled: bool = None,
is_screen_sharing_enabled: bool = None
):
super().__init__(client)
self.chat = chat
self.date = date
self.active_date = active_date
self.volume = volume
self.can_self_unmute = can_self_unmute
self.is_muted = is_muted
self.is_left = is_left
self.is_just_joined = is_just_joined
self.is_muted_by_you = is_muted_by_you
self.is_volume_by_admin = is_volume_by_admin
self.is_self = is_self
self.is_video_joined = is_video_joined
self.is_hand_raised = is_hand_raised
self.is_video_enabled = is_video_enabled
self.is_screen_sharing_enabled = is_screen_sharing_enabled
@staticmethod
def _parse(
client: "pyrogram.Client",
member: "raw.types.GroupCallParticipant",
users: Dict[int, "raw.base.User"],
chats: Dict[int, "raw.base.Chat"]
) -> "GroupCallMember":
peer = member.peer
peer_id = utils.get_raw_peer_id(peer)
parsed_chat = types.Chat._parse_chat(
client,
users[peer_id] if isinstance(peer, raw.types.PeerUser) else chats[peer_id],
)
parsed_chat.bio = getattr(member, "about", None)
return GroupCallMember(
chat=parsed_chat,
date=utils.timestamp_to_datetime(member.date),
active_date=utils.timestamp_to_datetime(member.active_date),
volume=getattr(member, "volume", None),
can_self_unmute=member.can_self_unmute,
is_muted=member.muted,
is_left=member.left,
is_just_joined=member.just_joined,
is_muted_by_you=member.muted_by_you,
is_volume_by_admin=member.volume_by_admin,
is_self=member.is_self,
is_video_joined=member.video_joined,
is_hand_raised=bool(getattr(member, "raise_hand_rating", None)),
is_video_enabled=bool(getattr(member, "video", None)),
is_screen_sharing_enabled=bool(getattr(member, "presentation", None)),
client=client
)

View file

@ -487,6 +487,7 @@ async def get_reply_to(
reply_to_message_id: int = None, reply_to_message_id: int = None,
reply_to_story_id: int = None, reply_to_story_id: int = None,
message_thread_id: int = None, message_thread_id: int = None,
reply_to_monoforum_id: Union[int,str] = None,
reply_to_chat_id: Union[int,str] = None, reply_to_chat_id: Union[int,str] = None,
quote_text: str = None, quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None, quote_entities: List["types.MessageEntity"] = None,
@ -495,7 +496,12 @@ async def get_reply_to(
): ):
reply_to = None reply_to = None
reply_to_chat = None reply_to_chat = None
if reply_to_message_id or message_thread_id: if reply_to_monoforum_id:
peer = await client.resolve_peer(reply_to_monoforum_id)
reply_to = types.InputReplyToMonoforum(
monoforum_peer=peer
)
elif reply_to_message_id or message_thread_id:
text, entities = (await parse_text_entities(client, quote_text, parse_mode, quote_entities)).values() text, entities = (await parse_text_entities(client, quote_text, parse_mode, quote_entities)).values()
if reply_to_chat_id is not None: if reply_to_chat_id is not None:
reply_to_chat = await client.resolve_peer(reply_to_chat_id) reply_to_chat = await client.resolve_peer(reply_to_chat_id)
@ -507,7 +513,7 @@ async def get_reply_to(
quote_entities=entities, quote_entities=entities,
quote_offset=quote_offset, quote_offset=quote_offset,
) )
if reply_to_story_id: elif reply_to_story_id:
peer = await client.resolve_peer(chat_id) peer = await client.resolve_peer(chat_id)
reply_to = types.InputReplyToStory( reply_to = types.InputReplyToStory(
peer=peer, peer=peer,