mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Compare commits
9 commits
fb7d5a46a2
...
9fd572d8a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fd572d8a2 | ||
|
|
50b8d17400 | ||
|
|
e020eba68f | ||
|
|
e5b01eb04b | ||
|
|
776ee3afb3 | ||
|
|
a1db77fcee | ||
|
|
6e3a840c5a | ||
|
|
1b27e24675 | ||
|
|
c8b90101eb |
95 changed files with 345 additions and 218 deletions
|
|
@ -130,7 +130,7 @@ def get_type_hint(type: str) -> str:
|
|||
return f"Optional[{type}] = None" if is_flag else type
|
||||
else:
|
||||
ns, name = type.split(".") if "." in type else ("", type)
|
||||
type = f'"raw.base.' + ".".join([ns, name]).strip(".") + '"'
|
||||
type = '"raw.base.' + ".".join([ns, name]).strip(".") + '"'
|
||||
|
||||
return f'{type}{" = None" if is_flag else ""}'
|
||||
|
||||
|
|
@ -430,11 +430,11 @@ def start(format: bool = False):
|
|||
if function_docs:
|
||||
docstring += function_docs["desc"] + "\n"
|
||||
else:
|
||||
docstring += f"Telegram API function."
|
||||
docstring += "Telegram API function."
|
||||
|
||||
docstring += f"\n\n Details:\n - Layer: ``{layer}``\n - ID: ``{c.id[2:].upper()}``\n\n"
|
||||
docstring += f" Parameters:\n " + \
|
||||
(f"\n ".join(docstring_args) if docstring_args else "No parameters required.\n")
|
||||
docstring += " Parameters:\n " + \
|
||||
("\n ".join(docstring_args) if docstring_args else "No parameters required.\n")
|
||||
|
||||
if c.section == "functions":
|
||||
docstring += "\n Returns:\n " + get_docstring_arg_type(c.qualtype)
|
||||
|
|
|
|||
|
|
@ -194,6 +194,8 @@ messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long c
|
|||
messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = 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#acdfcb81 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 = MessageAction;
|
||||
messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction;
|
||||
messageActionPaidMessagesPrice#bcd71419 stars:long = 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;
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
|
|
@ -213,6 +215,7 @@ geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radiu
|
|||
|
||||
auth.sentCode#5e002502 flags:# type:auth.SentCodeType phone_code_hash:string next_type:flags.1?auth.CodeType timeout:flags.2?int = auth.SentCode;
|
||||
auth.sentCodeSuccess#2390fe44 authorization:auth.Authorization = auth.SentCode;
|
||||
auth.sentCodePaymentRequired#d7cef980 store_product:string phone_code_hash:string = auth.SentCode;
|
||||
|
||||
auth.authorization#2ea2c0d4 flags:# setup_password_required:flags.1?true otherwise_relogin_days:flags.1?int tmp_sessions:flags.0?int future_auth_token:flags.2?bytes user:User = auth.Authorization;
|
||||
auth.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization;
|
||||
|
|
@ -245,7 +248,7 @@ inputReportReasonFake#f5ddd6e7 = ReportReason;
|
|||
inputReportReasonIllegalDrugs#a8eb2be = ReportReason;
|
||||
inputReportReasonPersonalDetails#9ec7863d = ReportReason;
|
||||
|
||||
userFull#d2234ea0 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram bot_verification:flags2.12?BotVerification send_paid_messages_stars:flags2.14?long = UserFull;
|
||||
userFull#99e78045 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true display_gifts_button:flags2.16?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram bot_verification:flags2.12?BotVerification send_paid_messages_stars:flags2.14?long disallowed_gifts:flags2.15?DisallowedGiftsSettings = UserFull;
|
||||
|
||||
contact#145ade0b user_id:long mutual:Bool = Contact;
|
||||
|
||||
|
|
@ -436,6 +439,7 @@ updateBusinessBotCallbackQuery#1ea2fda7 flags:# query_id:long user_id:long conne
|
|||
updateStarsRevenueStatus#a584b019 peer:Peer status:StarsRevenueStatus = Update;
|
||||
updateBotPurchasedPaidMedia#283bd312 user_id:long payload:string qts:int = Update;
|
||||
updatePaidReactionPrivacy#8b725fce private:PaidReactionPrivacy = Update;
|
||||
updateSentPhoneCode#504aa18f sent_code:auth.SentCode = Update;
|
||||
|
||||
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
||||
|
||||
|
|
@ -1320,7 +1324,7 @@ statsGroupTopInviter#535f779d user_id:long invitations:int = StatsGroupTopInvite
|
|||
|
||||
stats.megagroupStats#ef7ff916 period:StatsDateRangeDays members:StatsAbsValueAndPrev messages:StatsAbsValueAndPrev viewers:StatsAbsValueAndPrev posters:StatsAbsValueAndPrev growth_graph:StatsGraph members_graph:StatsGraph new_members_by_source_graph:StatsGraph languages_graph:StatsGraph messages_graph:StatsGraph actions_graph:StatsGraph top_hours_graph:StatsGraph weekdays_graph:StatsGraph top_posters:Vector<StatsGroupTopPoster> top_admins:Vector<StatsGroupTopAdmin> top_inviters:Vector<StatsGroupTopInviter> users:Vector<User> = stats.MegagroupStats;
|
||||
|
||||
globalPrivacySettings#c9d8df1c flags:# archive_and_mute_new_noncontact_peers:flags.0?true keep_archived_unmuted:flags.1?true keep_archived_folders:flags.2?true hide_read_marks:flags.3?true new_noncontact_peers_require_premium:flags.4?true noncontact_peers_paid_stars:flags.5?long = GlobalPrivacySettings;
|
||||
globalPrivacySettings#fe41b34f flags:# archive_and_mute_new_noncontact_peers:flags.0?true keep_archived_unmuted:flags.1?true keep_archived_folders:flags.2?true hide_read_marks:flags.3?true new_noncontact_peers_require_premium:flags.4?true display_gifts_button:flags.7?true noncontact_peers_paid_stars:flags.5?long disallowed_gifts:flags.6?DisallowedGiftsSettings = GlobalPrivacySettings;
|
||||
|
||||
help.countryCode#4203c5ef flags:# country_code:string prefixes:flags.0?Vector<string> patterns:flags.1?Vector<string> = help.CountryCode;
|
||||
|
||||
|
|
@ -1503,6 +1507,7 @@ inputStorePaymentPremiumGiveaway#160544ca flags:# only_new_subscribers:flags.0?t
|
|||
inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = InputStorePaymentPurpose;
|
||||
inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose;
|
||||
inputStorePaymentStarsGiveaway#751f08fa flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true stars:long boost_peer:InputPeer additional_peers:flags.1?Vector<InputPeer> countries_iso2:flags.2?Vector<string> prize_description:flags.4?string random_id:long until_date:int currency:string amount:long users:int = InputStorePaymentPurpose;
|
||||
inputStorePaymentAuthCode#9bb2636d flags:# restore:flags.0?true phone_number:string phone_code_hash:string currency:string amount:long = InputStorePaymentPurpose;
|
||||
|
||||
paymentFormMethod#88f8f21b url:string title:string = PaymentFormMethod;
|
||||
|
||||
|
|
@ -1761,7 +1766,7 @@ inputQuickReplyShortcutId#1190cf1 shortcut_id:int = InputQuickReplyShortcut;
|
|||
messages.quickReplies#c68d6695 quick_replies:Vector<QuickReply> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.QuickReplies;
|
||||
messages.quickRepliesNotModified#5f91eb5b = messages.QuickReplies;
|
||||
|
||||
connectedBot#bd068601 flags:# can_reply:flags.0?true bot_id:long recipients:BusinessBotRecipients = ConnectedBot;
|
||||
connectedBot#cd64636c flags:# bot_id:long recipients:BusinessBotRecipients rights:BusinessBotRights = ConnectedBot;
|
||||
|
||||
account.connectedBots#17d7f87b connected_bots:Vector<ConnectedBot> users:Vector<User> = account.ConnectedBots;
|
||||
|
||||
|
|
@ -1769,7 +1774,7 @@ messages.dialogFilters#2ad93719 flags:# tags_enabled:flags.0?true filters:Vector
|
|||
|
||||
birthday#6c8e1e06 flags:# day:int month:int year:flags.0?int = Birthday;
|
||||
|
||||
botBusinessConnection#896433b4 flags:# can_reply:flags.0?true disabled:flags.1?true connection_id:string user_id:long dc_id:int date:int = BotBusinessConnection;
|
||||
botBusinessConnection#8f34b2f5 flags:# disabled:flags.1?true connection_id:string user_id:long dc_id:int date:int rights:flags.2?BusinessBotRights = BotBusinessConnection;
|
||||
|
||||
inputBusinessIntro#9c469cd flags:# title:string description:string sticker:flags.0?InputDocument = InputBusinessIntro;
|
||||
|
||||
|
|
@ -1953,6 +1958,15 @@ requirementToContactEmpty#50a9839 = RequirementToContact;
|
|||
requirementToContactPremium#e581e4e9 = RequirementToContact;
|
||||
requirementToContactPaidMessages#b4f67e93 stars_amount:long = RequirementToContact;
|
||||
|
||||
businessBotRights#a0624cf7 flags:# reply:flags.0?true read_messages:flags.1?true delete_sent_messages:flags.2?true delete_received_messages:flags.3?true edit_name:flags.4?true edit_bio:flags.5?true edit_profile_photo:flags.6?true edit_username:flags.7?true view_gifts:flags.8?true sell_gifts:flags.9?true change_gift_settings:flags.10?true transfer_and_upgrade_gifts:flags.11?true transfer_stars:flags.12?true manage_stories:flags.13?true = BusinessBotRights;
|
||||
|
||||
disallowedGiftsSettings#71f276c4 flags:# disallow_unlimited_stargifts:flags.0?true disallow_limited_stargifts:flags.1?true disallow_unique_stargifts:flags.2?true disallow_premium_gifts:flags.3?true = DisallowedGiftsSettings;
|
||||
|
||||
sponsoredPeer#c69708d3 flags:# random_id:bytes peer:Peer sponsor_info:flags.0?string additional_info:flags.1?string = SponsoredPeer;
|
||||
|
||||
contacts.sponsoredPeersEmpty#ea32b4b1 = contacts.SponsoredPeers;
|
||||
contacts.sponsoredPeers#eb032884 peers:Vector<SponsoredPeer> chats:Vector<Chat> users:Vector<User> = contacts.SponsoredPeers;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
|
|
@ -2087,7 +2101,7 @@ account.updateBusinessWorkHours#4b00e066 flags:# business_work_hours:flags.0?Bus
|
|||
account.updateBusinessLocation#9e6b131a flags:# geo_point:flags.1?InputGeoPoint address:flags.0?string = Bool;
|
||||
account.updateBusinessGreetingMessage#66cdafc4 flags:# message:flags.0?InputBusinessGreetingMessage = Bool;
|
||||
account.updateBusinessAwayMessage#a26a7fa5 flags:# message:flags.0?InputBusinessAwayMessage = Bool;
|
||||
account.updateConnectedBot#43d8521d flags:# can_reply:flags.0?true deleted:flags.1?true bot:InputUser recipients:InputBusinessBotRecipients = Updates;
|
||||
account.updateConnectedBot#66a08c7e flags:# deleted:flags.1?true rights:flags.0?BusinessBotRights bot:InputUser recipients:InputBusinessBotRecipients = Updates;
|
||||
account.getConnectedBots#4ea4c80f = account.ConnectedBots;
|
||||
account.getBotBusinessConnection#76a86270 connection_id:string = Updates;
|
||||
account.updateBusinessIntro#a614d034 flags:# intro:flags.0?InputBusinessIntro = Bool;
|
||||
|
|
@ -2138,6 +2152,7 @@ contacts.importContactToken#13005788 token:string = User;
|
|||
contacts.editCloseFriends#ba6705f0 id:Vector<long> = Bool;
|
||||
contacts.setBlocked#94c65c76 flags:# my_stories_from:flags.0?true id:Vector<InputPeer> limit:int = Bool;
|
||||
contacts.getBirthdays#daeda864 = contacts.ContactBirthdays;
|
||||
contacts.getSponsoredPeers#b6c8c393 q:string = contacts.SponsoredPeers;
|
||||
|
||||
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
|
||||
messages.getDialogs#a0f4cb4f flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.Dialogs;
|
||||
|
|
@ -2356,9 +2371,9 @@ messages.requestMainWebView#c9e01e7b flags:# compact:flags.7?true fullscreen:fla
|
|||
messages.sendPaidReaction#58bbcb50 flags:# peer:InputPeer msg_id:int count:int random_id:long private:flags.0?PaidReactionPrivacy = Updates;
|
||||
messages.togglePaidReactionPrivacy#435885b5 peer:InputPeer msg_id:int private:PaidReactionPrivacy = Bool;
|
||||
messages.getPaidReactionPrivacy#472455aa = Updates;
|
||||
messages.viewSponsoredMessage#673ad8f1 peer:InputPeer random_id:bytes = Bool;
|
||||
messages.clickSponsoredMessage#f093465 flags:# media:flags.0?true fullscreen:flags.1?true peer:InputPeer random_id:bytes = Bool;
|
||||
messages.reportSponsoredMessage#1af3dbb8 peer:InputPeer random_id:bytes option:bytes = channels.SponsoredMessageReportResult;
|
||||
messages.viewSponsoredMessage#269e3643 random_id:bytes = Bool;
|
||||
messages.clickSponsoredMessage#8235057e flags:# media:flags.0?true fullscreen:flags.1?true random_id:bytes = Bool;
|
||||
messages.reportSponsoredMessage#12cbf0c4 random_id:bytes option:bytes = channels.SponsoredMessageReportResult;
|
||||
messages.getSponsoredMessages#9bd2f439 peer:InputPeer = messages.SponsoredMessages;
|
||||
messages.savePreparedInlineMessage#f21f7f2f flags:# result:InputBotInlineResult user_id:InputUser peer_types:flags.0?Vector<InlineQueryPeerType> = messages.BotPreparedInlineMessage;
|
||||
messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage;
|
||||
|
|
@ -2514,7 +2529,6 @@ payments.getBankCardData#2e79d779 number:string = payments.BankCardData;
|
|||
payments.exportInvoice#f91b065 invoice_media:InputMedia = payments.ExportedInvoice;
|
||||
payments.assignAppStoreTransaction#80ed747d receipt:bytes purpose:InputStorePaymentPurpose = Updates;
|
||||
payments.assignPlayMarketTransaction#dffd50d3 receipt:DataJSON purpose:InputStorePaymentPurpose = Updates;
|
||||
payments.canPurchasePremium#9fc19eb6 purpose:InputStorePaymentPurpose = Bool;
|
||||
payments.getPremiumGiftCodeOptions#2757ba54 flags:# boost_peer:flags.0?InputPeer = Vector<PremiumGiftCodeOption>;
|
||||
payments.checkGiftCode#8e51b4c1 slug:string = payments.CheckedGiftCode;
|
||||
payments.applyGiftCode#f6e26854 slug:string = Updates;
|
||||
|
|
@ -2552,6 +2566,7 @@ payments.getSavedStarGift#b455a106 stargift:Vector<InputSavedStarGift> = payment
|
|||
payments.getStarGiftWithdrawalUrl#d06e93a8 stargift:InputSavedStarGift password:InputCheckPasswordSRP = payments.StarGiftWithdrawalUrl;
|
||||
payments.toggleChatStarGiftNotifications#60eaefa1 flags:# enabled:flags.0?true peer:InputPeer = Bool;
|
||||
payments.toggleStarGiftsPinnedToTop#1513e7b0 peer:InputPeer stargift:Vector<InputSavedStarGift> = Bool;
|
||||
payments.canPurchaseStore#4fdc5ea7 purpose:InputStorePaymentPurpose = Bool;
|
||||
|
||||
stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector<InputStickerSetItem> software:flags.3?string = messages.StickerSet;
|
||||
stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet;
|
||||
|
|
@ -2672,4 +2687,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;
|
|||
|
||||
fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;
|
||||
|
||||
// LAYER 200
|
||||
// LAYER 201
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ def pyrogram_api():
|
|||
fmt_keys = {}
|
||||
|
||||
for k, v in categories.items():
|
||||
name, *methods = get_title_list(v)
|
||||
_, *methods = get_title_list(v)
|
||||
fmt_keys.update({k: "\n ".join("{0} <{0}>".format(m) for m in methods)})
|
||||
|
||||
for method in methods:
|
||||
|
|
@ -740,7 +740,7 @@ def pyrogram_api():
|
|||
fmt_keys = {}
|
||||
|
||||
for k, v in categories.items():
|
||||
name, *types = get_title_list(v)
|
||||
_, *types = get_title_list(v)
|
||||
|
||||
fmt_keys.update({k: "\n ".join(types)})
|
||||
|
||||
|
|
|
|||
|
|
@ -17,17 +17,13 @@
|
|||
# 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 concurrent.futures.thread import ThreadPoolExecutor
|
||||
|
||||
from . import raw, types, filters, handlers, emoji, enums
|
||||
from .client import Client
|
||||
from .sync import idle, compose
|
||||
|
||||
__fork_name__ = "PyroFork"
|
||||
__version__ = "2.3.59"
|
||||
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
|
||||
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>"
|
||||
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
|
||||
|
||||
class StopTransmission(Exception):
|
||||
pass
|
||||
|
|
@ -40,6 +36,11 @@ class StopPropagation(StopAsyncIteration):
|
|||
class ContinuePropagation(StopAsyncIteration):
|
||||
pass
|
||||
|
||||
|
||||
from . import raw, types, filters, handlers, emoji, enums # pylint: disable=wrong-import-position
|
||||
from .client import Client # pylint: disable=wrong-import-position
|
||||
from .sync import idle, compose # pylint: disable=wrong-import-position
|
||||
|
||||
crypto_executor = ThreadPoolExecutor(1, thread_name_prefix="CryptoWorker")
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -888,7 +888,7 @@ class Client(Methods):
|
|||
count = 0
|
||||
|
||||
if not include:
|
||||
for current_root, dirnames, filenames in os.walk(root.replace(".", "/")):
|
||||
for current_root, _, filenames in os.walk(root.replace(".", "/")):
|
||||
namespace = current_root.replace("/", ".").replace("\\", ".")
|
||||
if "__pycache__" in namespace:
|
||||
continue
|
||||
|
|
@ -1042,7 +1042,7 @@ class Client(Methods):
|
|||
)
|
||||
|
||||
count += 1
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if handlers is None:
|
||||
|
|
@ -1106,7 +1106,7 @@ class Client(Methods):
|
|||
async def handle_download(self, packet):
|
||||
file_id, directory, file_name, in_memory, file_size, progress, progress_args = packet
|
||||
|
||||
os.makedirs(directory, exist_ok=True) if not in_memory else None
|
||||
_ = os.makedirs(directory, exist_ok=True) if not in_memory else None
|
||||
temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp"
|
||||
file = BytesIO() if in_memory else open(temp_file_path, "wb")
|
||||
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .connection import Connection
|
||||
|
||||
__all__ = [
|
||||
"Connection"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Connection:
|
|||
self.protocol: Optional[TCP] = None
|
||||
|
||||
async def connect(self) -> None:
|
||||
for i in range(Connection.MAX_CONNECTION_ATTEMPTS):
|
||||
for _ in range(Connection.MAX_CONNECTION_ATTEMPTS):
|
||||
self.protocol = self.protocol_factory(ipv6=self.ipv6, proxy=self.proxy)
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import asyncio
|
|||
import ipaddress
|
||||
import logging
|
||||
import socket
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from typing import Tuple, Dict, TypedDict, Optional
|
||||
|
||||
import socks
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ def unpack(
|
|||
left = [[left[i:i + 8] for i in range(0, len(left), 8)] for left in left]
|
||||
left = "\n".join(" ".join(x for x in left) for left in left)
|
||||
|
||||
raise ValueError("The server sent an unknown constructor: {hex(e.args[0])}\n{left}")
|
||||
raise ValueError(f"The server sent an unknown constructor: {hex(e.args[0])}\n{left}")
|
||||
|
||||
# https://core.telegram.org/mtproto/security_guidelines#checking-sha256-hash-value-of-msg-key
|
||||
# 96 = 88 + 8 (incoming message)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ def decompose(pq: int) -> int:
|
|||
while g == 1:
|
||||
x = y
|
||||
|
||||
for i in range(r):
|
||||
for _ in range(r):
|
||||
y = (pow(y, 2, pq) + c) % pq
|
||||
|
||||
k = 0
|
||||
|
|
@ -63,7 +63,7 @@ def decompose(pq: int) -> int:
|
|||
while k < r and g == 1:
|
||||
ys = y
|
||||
|
||||
for i in range(min(m, r - k)):
|
||||
for _ in range(min(m, r - k)):
|
||||
y = (pow(y, 2, pq) + c) % pq
|
||||
q = q * (abs(x - y)) % pq
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import logging
|
|||
from collections import OrderedDict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import errors, raw, types, utils
|
||||
from pyrogram import raw, types, utils
|
||||
from pyrogram.handlers.handler import Handler
|
||||
from pyrogram.handlers import (
|
||||
BotBusinessConnectHandler,
|
||||
|
|
@ -266,7 +266,7 @@ class Dispatcher:
|
|||
|
||||
async def start(self):
|
||||
if not self.client.no_updates:
|
||||
for i in range(self.client.workers):
|
||||
for _ in range(self.client.workers):
|
||||
self.locks_list.append(asyncio.Lock())
|
||||
|
||||
self.handler_worker_tasks.append(
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ class ChatEventAction(AutoName):
|
|||
"The linked chat has been changed (see ``old_linked_chat`` and ``new_linked_chat``)"
|
||||
|
||||
# LOCATION_CHANGED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
PHOTO_CHANGED = auto()
|
||||
"The chat photo has been changed (see ``old_photo`` and ``new_photo``)"
|
||||
|
||||
# STICKER_SET_CHANGED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
TITLE_CHANGED = auto()
|
||||
"the chat title has been changed (see ``old_title`` and ``new_title``)"
|
||||
|
|
@ -56,7 +56,7 @@ class ChatEventAction(AutoName):
|
|||
"a message has been deleted (see ``deleted_message``)"
|
||||
|
||||
# VOICE_CHAT_DISCARDED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
MESSAGE_EDITED = auto()
|
||||
"a message has been edited (see ``old_message`` and ``new_message``)"
|
||||
|
|
@ -77,13 +77,13 @@ class ChatEventAction(AutoName):
|
|||
"a member joined by themselves. (see ``user``)"
|
||||
|
||||
# MEMBER_JOINED_BY_LINK = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
MEMBER_LEFT = auto()
|
||||
"a member left by themselves. (see ``user``)"
|
||||
|
||||
# MEMBER_MUTED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
ADMINISTRATOR_PRIVILEGES_CHANGED = auto()
|
||||
"a chat member has been promoted/demoted or their administrator privileges has changed (see ``old_administrator_privileges`` and ``new_administrator_privileges``)"
|
||||
|
|
@ -92,19 +92,19 @@ class ChatEventAction(AutoName):
|
|||
"a chat member has been restricted/unrestricted or banned/unbanned, or their permissions has changed (see ``old_member_permissions`` and ``new_member_permissions``)"
|
||||
|
||||
# MEMBER_UNMUTED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
# MEMBER_VOLUME_CHANGED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
# VIDEO_CHAT_STARTED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
POLL_STOPPED = auto()
|
||||
"a poll has been stopped (see ``stopped_poll``)"
|
||||
|
||||
# VOICE_CHAT_SETTINGS_CHANGED = auto()
|
||||
""
|
||||
# ""
|
||||
|
||||
INVITES_ENABLED = auto()
|
||||
"the chat invitation has been enabled or disabled (see ``invites_enabled``)"
|
||||
|
|
|
|||
|
|
@ -65,3 +65,11 @@ class CDNFileHashMismatch(SecurityError):
|
|||
|
||||
def __init__(self, msg: str = None):
|
||||
super().__init__("A CDN file hash mismatch has occurred." if msg is None else msg)
|
||||
|
||||
__all__ = [
|
||||
"BadMsgNotification",
|
||||
"SecurityError",
|
||||
"SecurityCheckMismatch",
|
||||
"CDNFileHashMismatch",
|
||||
"UnknownError"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ from .error_handler import ErrorHandler
|
|||
from .inline_query_handler import InlineQueryHandler
|
||||
from .message_handler import MessageHandler
|
||||
from .poll_handler import PollHandler
|
||||
from .pre_checkout_query_handler import PreCheckoutQueryHandler
|
||||
from .purchased_paid_media_handler import PurchasedPaidMediaHandler
|
||||
from .raw_update_handler import RawUpdateHandler
|
||||
from .user_status_handler import UserStatusHandler
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class ConversationHandler(MessageHandler, CallbackQueryHandler):
|
|||
return True
|
||||
|
||||
@staticmethod
|
||||
# pylint: disable=method-hidden
|
||||
async def callback(_, __):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -58,5 +58,4 @@ class DeletedBotBusinessMessagesHandler(Handler):
|
|||
for message in messages:
|
||||
if await super().check(client, message):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -58,5 +58,4 @@ class DeletedMessagesHandler(Handler):
|
|||
for message in messages:
|
||||
if await super().check(client, message):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -14,3 +14,14 @@ You should have received a copy of the GNU General Public License
|
|||
along with pyromod. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from .helpers import ikb, bki, ntb, btn, kb, kbtn, array_chunk, force_reply
|
||||
|
||||
__all__ = [
|
||||
"ikb",
|
||||
"bki",
|
||||
"ntb",
|
||||
"btn",
|
||||
"kb",
|
||||
"kbtn",
|
||||
"array_chunk",
|
||||
"force_reply"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import inspect
|
|||
import io
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
from hashlib import md5
|
||||
from pathlib import PurePath
|
||||
from typing import Union, BinaryIO, Callable
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class Connect:
|
|||
Raises:
|
||||
ConnectionError: In case you try to connect an already connected client.
|
||||
"""
|
||||
# pylint: disable=access-member-before-definition
|
||||
if self.is_connected:
|
||||
raise ConnectionError("Client is already connected")
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class Disconnect:
|
|||
ConnectionError: In case you try to disconnect an already disconnected client or in case you try to
|
||||
disconnect a client that needs to be terminated first.
|
||||
"""
|
||||
# pylint: disable=access-member-before-definition
|
||||
if not self.is_connected:
|
||||
raise ConnectionError("Client is already disconnected")
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
# 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 List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class Initialize:
|
|||
if not self.is_connected:
|
||||
raise ConnectionError("Can't initialize a disconnected client")
|
||||
|
||||
# pylint: disable=access-member-before-definition
|
||||
if self.is_initialized:
|
||||
raise ConnectionError("Client is already initialized")
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class SendCode:
|
|||
)
|
||||
)
|
||||
except (PhoneMigrate, NetworkMigrate) as e:
|
||||
# pylint: disable=access-member-before-definition
|
||||
await self.session.stop()
|
||||
|
||||
await self.storage.dc_id(e.value)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ class SignInBot:
|
|||
)
|
||||
)
|
||||
except UserMigrate as e:
|
||||
# pylint: disable=access-member-before-definition
|
||||
await self.session.stop()
|
||||
|
||||
await self.storage.dc_id(e.value)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class Terminate:
|
|||
Raises:
|
||||
ConnectionError: In case you try to terminate a client that is already terminated.
|
||||
"""
|
||||
# pylint: disable=access-member-before-definition
|
||||
if not self.is_initialized:
|
||||
raise ConnectionError("Client is already terminated")
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,8 @@
|
|||
# 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 Union, List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import types, utils, raw
|
||||
from pyrogram import types, raw
|
||||
|
||||
|
||||
class GetBusinessConnection:
|
||||
|
|
|
|||
|
|
@ -117,5 +117,4 @@ class BanChatMember:
|
|||
{i.id: i for i in r.users},
|
||||
{i.id: i for i in r.chats}
|
||||
)
|
||||
else:
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ class GetChatMember:
|
|||
else:
|
||||
if member.user.id == user.user_id:
|
||||
return member
|
||||
else:
|
||||
raise UserNotParticipant
|
||||
elif isinstance(chat, raw.types.InputPeerChannel):
|
||||
r = await self.invoke(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from typing import Union, Optional, AsyncGenerator
|
|||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from pyrogram import utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from typing import Union, List, Iterable
|
|||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from pyrogram import utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -63,7 +62,7 @@ class GetForumTopicsByID:
|
|||
Raises:
|
||||
ValueError: In case of invalid arguments.
|
||||
"""
|
||||
ids, ids_type = (
|
||||
ids, _ = (
|
||||
(topic_ids, int) if topic_ids
|
||||
else (None, None)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -164,5 +164,4 @@ class SetChatPhoto:
|
|||
{i.id: i for i in r.users},
|
||||
{i.id: i for i in r.chats}
|
||||
)
|
||||
else:
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
#
|
||||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from typing import Union
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class GetMessages:
|
|||
|
||||
is_iterable = not isinstance(ids, int)
|
||||
ids = list(ids) if is_iterable else [ids]
|
||||
ids = [ids_type(id=i) for i in ids]
|
||||
ids = [ids_type(id=i) for i in ids] # pylint: disable=not-callable
|
||||
|
||||
if replies < 0:
|
||||
replies = (1 << 31) - 1
|
||||
|
|
|
|||
|
|
@ -109,9 +109,11 @@ class SendReaction:
|
|||
add_to_recent=add_to_recent
|
||||
)
|
||||
)
|
||||
users = {i.id: i for i in r.users}
|
||||
chats = {i.id: i for i in r.chats}
|
||||
for i in r.updates:
|
||||
if isinstance(i, raw.types.UpdateMessageReactions):
|
||||
return types.MessageReactions._parse(self, i.reactions)
|
||||
return types.MessageReactions._parse(self, i.reactions, users, chats)
|
||||
elif story_id is not None:
|
||||
await self.invoke(
|
||||
raw.functions.stories.SendReaction(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
# 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 datetime import datetime
|
||||
from typing import Union, List, Optional
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@
|
|||
# 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 Union
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ class SendPaidReaction:
|
|||
)
|
||||
)
|
||||
users = {i.id: i for i in r.users}
|
||||
chats = {i.id: i for i in r.chats}
|
||||
|
||||
for i in r.updates:
|
||||
if isinstance(i, raw.types.UpdateMessageReactions):
|
||||
return types.MessageReactions._parse(self, i.reactions, users)
|
||||
return types.MessageReactions._parse(self, i.reactions, users, chats)
|
||||
|
|
|
|||
|
|
@ -17,11 +17,10 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
from typing import Union, List, Iterable
|
||||
from typing import Union, Iterable
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -222,14 +222,13 @@ class EditStory:
|
|||
if caption:
|
||||
text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities))
|
||||
|
||||
'''
|
||||
if allowed_chats and len(allowed_chats) > 0:
|
||||
chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in allowed_chats]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||
if denied_chats and len(denied_chats) > 0:
|
||||
chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in denied_chats]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||
'''
|
||||
#if allowed_chats and len(allowed_chats) > 0:
|
||||
# chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in allowed_chats]
|
||||
# privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||
#if denied_chats and len(denied_chats) > 0:
|
||||
# chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in denied_chats]
|
||||
# privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||
|
||||
if allowed_users and len(allowed_users) > 0:
|
||||
users = [await self.resolve_peer(user_id) for user_id in allowed_users]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users))
|
||||
|
|
|
|||
|
|
@ -213,14 +213,13 @@ class SendStory:
|
|||
|
||||
text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities))
|
||||
|
||||
'''
|
||||
if allowed_chats and len(allowed_chats) > 0:
|
||||
chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||
if denied_chats and len(denied_chats) > 0:
|
||||
chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||
'''
|
||||
#if allowed_chats and len(allowed_chats) > 0:
|
||||
# chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats]
|
||||
# privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||
#if denied_chats and len(denied_chats) > 0:
|
||||
# chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats]
|
||||
# privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||
|
||||
if allowed_users and len(allowed_users) > 0:
|
||||
users = [await self.resolve_peer(user_id) for user_id in allowed_users]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users))
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .pagination import Pagination
|
||||
|
||||
__all__ = [
|
||||
"Pagination"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .parser import Parser
|
||||
|
||||
__all__ = [
|
||||
"Parser"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ class Markdown:
|
|||
# Handle multiline blockquotes
|
||||
text_subset = text[s:e]
|
||||
lines = text_subset.splitlines()
|
||||
for line_num, line in enumerate(lines):
|
||||
for line_num, _ in enumerate(lines):
|
||||
line_start = s + sum(len(l) + 1 for l in lines[:line_num])
|
||||
if entity.collapsed:
|
||||
insert_at.append((line_start, i, BLOCKQUOTE_EXPANDABLE_DELIM))
|
||||
|
|
|
|||
|
|
@ -25,3 +25,11 @@ from .all import objects
|
|||
for k, v in objects.items():
|
||||
path, name = v.rsplit(".", 1)
|
||||
objects[k] = getattr(import_module(path), name)
|
||||
|
||||
__all__ = [
|
||||
"types",
|
||||
"functions",
|
||||
"base",
|
||||
"core",
|
||||
"objects"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -23,3 +23,17 @@ from .double import Double
|
|||
from .int import Int, Long, Int128, Int256
|
||||
from .string import String
|
||||
from .vector import Vector
|
||||
|
||||
__all__ = [
|
||||
"Bool",
|
||||
"BoolFalse",
|
||||
"BoolTrue",
|
||||
"Bytes",
|
||||
"Double",
|
||||
"Int",
|
||||
"Long",
|
||||
"Int128",
|
||||
"Int256",
|
||||
"String",
|
||||
"Vector"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -19,3 +19,8 @@
|
|||
|
||||
from .auth import Auth
|
||||
from .session import Session
|
||||
|
||||
__all__ = [
|
||||
"Auth",
|
||||
"Session"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -19,10 +19,20 @@
|
|||
|
||||
from .file_storage import FileStorage
|
||||
from .memory_storage import MemoryStorage
|
||||
MONGO_AVAIL = False
|
||||
try:
|
||||
import pymongo
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
MONGO_AVAIL = True
|
||||
from .mongo_storage import MongoStorage
|
||||
from .storage import Storage
|
||||
|
||||
__all__ = [
|
||||
"FileStorage",
|
||||
"MemoryStorage",
|
||||
"Storage"
|
||||
]
|
||||
if MONGO_AVAIL:
|
||||
__all__.append("MongoStorage")
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
import pyrogram
|
||||
from pyrogram import raw, utils
|
||||
from pyrogram import types
|
||||
from typing import Dict
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
@ -52,7 +53,11 @@ class GameHighScore(Object):
|
|||
self.position = position
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, game_high_score: raw.types.HighScore, users: dict) -> "GameHighScore":
|
||||
def _parse(
|
||||
client,
|
||||
game_high_score: raw.types.HighScore,
|
||||
users: Dict[int, "raw.types.User"]
|
||||
) -> "GameHighScore":
|
||||
users = {i.id: i for i in users}
|
||||
|
||||
return GameHighScore(
|
||||
|
|
@ -63,7 +68,11 @@ class GameHighScore(Object):
|
|||
)
|
||||
|
||||
@staticmethod
|
||||
def _parse_action(client, service: raw.types.MessageService, users: dict):
|
||||
def _parse_action(
|
||||
client,
|
||||
service: raw.types.MessageService,
|
||||
users: Dict[int, "raw.types.User"]
|
||||
) -> "GameHighScore":
|
||||
return GameHighScore(
|
||||
user=types.User._parse(client, users[utils.get_raw_peer_id(service.from_id or service.peer_id)]),
|
||||
score=service.action.score,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ..object import Object
|
||||
from pyrogram import enums, raw, types
|
||||
from pyrogram import raw, types
|
||||
from typing import Union, List
|
||||
|
||||
class RequestedChats(Object):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ..object import Object
|
||||
from pyrogram import enums, raw, types
|
||||
from pyrogram import raw, types
|
||||
from typing import Union
|
||||
|
||||
class RequestedUser(Object):
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
from typing import Dict
|
||||
from ..object import Object
|
||||
from ..update import Update
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ class PreCheckoutQuery(Object, Update):
|
|||
async def _parse(
|
||||
client: "pyrogram.Client",
|
||||
pre_checkout_query: "raw.types.UpdateBotPrecheckoutQuery",
|
||||
users
|
||||
users: Dict[int, "raw.types.User"] = None
|
||||
) -> "PreCheckoutQuery":
|
||||
# Try to decode pre-checkout query payload into string. If that fails, fallback to bytes instead of decoding by
|
||||
# ignoring/replacing errors, this way, button clicks will still work.
|
||||
|
|
@ -96,14 +97,7 @@ class PreCheckoutQuery(Object, Update):
|
|||
name=pre_checkout_query.info.name,
|
||||
phone_number=pre_checkout_query.info.phone,
|
||||
email=pre_checkout_query.info.email,
|
||||
shipping_address=types.ShippingAddress(
|
||||
street_line1=pre_checkout_query.info.shipping_address.street_line1,
|
||||
street_line2=pre_checkout_query.info.shipping_address.street_line2,
|
||||
city=pre_checkout_query.info.shipping_address.city,
|
||||
state=pre_checkout_query.info.shipping_address.state,
|
||||
post_code=pre_checkout_query.info.shipping_address.post_code,
|
||||
country_code=pre_checkout_query.info.shipping_address.country_iso2
|
||||
)
|
||||
shipping_address=types.ShippingAddress._parse(pre_checkout_query.info.shipping_address)
|
||||
) if pre_checkout_query.info else None,
|
||||
client=client
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
# 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
|
||||
|
||||
|
||||
|
|
@ -60,3 +62,17 @@ class ShippingAddress(Object):
|
|||
self.state = state
|
||||
self.post_code = post_code
|
||||
self.country_code = country_code
|
||||
|
||||
@staticmethod
|
||||
def _parse(shipping_address: "raw.types.raw.types.PostAddress") -> "ShippingAddress":
|
||||
if shipping_address is None:
|
||||
return None
|
||||
|
||||
return ShippingAddress(
|
||||
street_line1=shipping_address.street_line1,
|
||||
street_line2=shipping_address.street_line2,
|
||||
city=shipping_address.city,
|
||||
state=shipping_address.state,
|
||||
post_code=shipping_address.post_code,
|
||||
country_code=shipping_address.country_code
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@
|
|||
# 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 List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
|
||||
from ..object import Object
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
from typing import Dict
|
||||
|
||||
from ..object import Object
|
||||
from ..update import Update
|
||||
|
|
@ -61,8 +62,8 @@ class ShippingQuery(Object, Update):
|
|||
@staticmethod
|
||||
async def _parse(
|
||||
client: "pyrogram.Client",
|
||||
shipping_query: "raw.types.updateBotShippingQuery",
|
||||
users: dict
|
||||
shipping_query: "raw.types.UpdateBotShippingQuery",
|
||||
users: Dict[int, "raw.types.User"]
|
||||
) -> "types.PreCheckoutQuery":
|
||||
# Try to decode pre-checkout query payload into string. If that fails, fallback to bytes instead of decoding by
|
||||
# ignoring/replacing errors, this way, button clicks will still work.
|
||||
|
|
@ -74,9 +75,9 @@ class ShippingQuery(Object, Update):
|
|||
return ShippingQuery(
|
||||
client=client,
|
||||
id=shipping_query.query_id,
|
||||
from_user=types.User._parse(client, shipping_query.user_id, users),
|
||||
from_user=types.User._parse(client, users.get(shipping_query.user_id)),
|
||||
payload=payload,
|
||||
shipping_address=types.ShippingAddress._parse(client, shipping_query.shipping_address)
|
||||
shipping_address=types.ShippingAddress._parse(shipping_query.shipping_address)
|
||||
)
|
||||
|
||||
async def answer(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# 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, Match
|
||||
from typing import List, Match, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
|
|
@ -78,7 +78,11 @@ class InlineQuery(Object, Update):
|
|||
self.matches = matches
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, inline_query: raw.types.UpdateBotInlineQuery, users: dict) -> "InlineQuery":
|
||||
def _parse(
|
||||
client,
|
||||
inline_query: raw.types.UpdateBotInlineQuery,
|
||||
users: Dict[int, "raw.types.User"]
|
||||
) -> "InlineQuery":
|
||||
peer_type = inline_query.peer_type
|
||||
chat_type = None
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from typing import List
|
|||
import pyrogram
|
||||
from pyrogram import raw, utils
|
||||
from pyrogram import types
|
||||
from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType, ThumbnailSource
|
||||
from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram import raw
|
||||
from typing import List
|
||||
from ..object import Object
|
||||
|
||||
class ExportedStoryLink(Object):
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ class ExternalReplyInfo(Object):
|
|||
giveaway (:obj:`~pyrogram.types.Giveaway`, *optional*):
|
||||
Message is a scheduled giveaway, information about the giveaway.
|
||||
|
||||
giveaway_winners (:obj:`~pyrogram.types.GiveawayWinners`, *optional*):
|
||||
A giveaway with public winners was completed
|
||||
giveaway_result (:obj:`~pyrogram.types.GiveawayResult`, *optional*):
|
||||
Message is a giveaway result, information about the giveaway result.
|
||||
|
||||
invoice (:obj:`~pyrogram.types.Invoice`, *optional*):
|
||||
Message is a invoice, information about the invoice.
|
||||
|
|
@ -130,7 +130,7 @@ class ExternalReplyInfo(Object):
|
|||
dice: Optional["types.Dice"] = None,
|
||||
game: Optional["types.Game"] = None,
|
||||
giveaway: Optional["types.Giveaway"] = None,
|
||||
giveaway_winners: Optional["types.GiveawayWinners"] = None,
|
||||
giveaway_result: Optional["types.GiveawayResult"] = None,
|
||||
invoice: Optional["types.Invoice"] = None,
|
||||
location: Optional["types.Location"] = None,
|
||||
poll: Optional["types.Poll"] = None,
|
||||
|
|
@ -157,7 +157,7 @@ class ExternalReplyInfo(Object):
|
|||
self.dice = dice
|
||||
self.game = game
|
||||
self.giveaway = giveaway
|
||||
self.giveaway_winners = giveaway_winners
|
||||
self.giveaway_result = giveaway_result
|
||||
self.invoice = invoice
|
||||
self.location = location
|
||||
self.poll = poll
|
||||
|
|
@ -190,7 +190,7 @@ class ExternalReplyInfo(Object):
|
|||
dice = None
|
||||
game = None
|
||||
giveaway = None
|
||||
giveaway_winners = None
|
||||
giveaway_result = None
|
||||
invoice = None
|
||||
location = None
|
||||
poll = None
|
||||
|
|
@ -218,16 +218,16 @@ class ExternalReplyInfo(Object):
|
|||
game = types.Game._parse(client, media)
|
||||
media_type = enums.MessageMediaType.GAME
|
||||
elif isinstance(media, raw.types.MessageMediaGiveaway):
|
||||
giveaway = types.Giveaway._parse(client, media, chats)
|
||||
giveaway = types.Giveaway._parse(client, reply, chats)
|
||||
media_type = enums.MessageMediaType.GIVEAWAY
|
||||
elif isinstance(media, raw.types.MessageMediaGiveawayResults):
|
||||
giveaway_winners = await types.GiveawayWinners._parse(client, media, users, chats)
|
||||
media_type = enums.MessageMediaType.GIVEAWAY_WINNERS
|
||||
giveaway_result = await types.GiveawayResult._parse(client, media, users, chats)
|
||||
media_type = enums.MessageMediaType.GIVEAWAY_RESULT
|
||||
elif isinstance(media, raw.types.MessageMediaInvoice):
|
||||
invoice = types.Invoice._parse(media)
|
||||
media_type = enums.MessageMediaType.INVOICE
|
||||
elif isinstance(media, raw.types.MessageMediaStory):
|
||||
story = await types.Story._parse(client, media, media.peer, users, chats)
|
||||
story = await types.Story._parse(client, media, media.peer)
|
||||
media_type = enums.MessageMediaType.STORY
|
||||
elif isinstance(media, raw.types.MessageMediaDocument):
|
||||
doc = media.document
|
||||
|
|
@ -253,17 +253,25 @@ class ExternalReplyInfo(Object):
|
|||
video_attributes = attributes[raw.types.DocumentAttributeVideo]
|
||||
|
||||
if video_attributes.round_message:
|
||||
video_note = types.VideoNote._parse(client, doc, video_attributes, media.ttl_seconds)
|
||||
video_note = types.VideoNote._parse(client, doc, video_attributes)
|
||||
media_type = enums.MessageMediaType.VIDEO_NOTE
|
||||
else:
|
||||
video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds, media.video_cover, media.video_timestamp, media.alt_documents)
|
||||
video = types.Video._parse(
|
||||
client,
|
||||
doc,
|
||||
video_attributes,
|
||||
file_name,
|
||||
media.ttl_seconds,
|
||||
media.video_cover,
|
||||
media.video_timestamp
|
||||
)
|
||||
media_type = enums.MessageMediaType.VIDEO
|
||||
has_media_spoiler = media.spoiler
|
||||
elif raw.types.DocumentAttributeAudio in attributes:
|
||||
audio_attributes = attributes[raw.types.DocumentAttributeAudio]
|
||||
|
||||
if audio_attributes.voice:
|
||||
voice = types.Voice._parse(client, doc, audio_attributes, media.ttl_seconds)
|
||||
voice = types.Voice._parse(client, doc, audio_attributes)
|
||||
media_type = enums.MessageMediaType.VOICE
|
||||
else:
|
||||
audio = types.Audio._parse(client, doc, audio_attributes, file_name)
|
||||
|
|
@ -278,7 +286,7 @@ class ExternalReplyInfo(Object):
|
|||
dice = types.Dice._parse(client, media)
|
||||
media_type = enums.MessageMediaType.DICE
|
||||
elif isinstance(media, raw.types.MessageMediaPaidMedia):
|
||||
paid_media = types.PaidMediaInfo._parse(client, media)
|
||||
paid_media = types.PaidMedia._parse(client, media)
|
||||
media_type = enums.MessageMediaType.PAID_MEDIA
|
||||
else:
|
||||
media = None
|
||||
|
|
@ -311,7 +319,7 @@ class ExternalReplyInfo(Object):
|
|||
dice=dice,
|
||||
game=game,
|
||||
giveaway=giveaway,
|
||||
giveaway_winners=giveaway_winners,
|
||||
giveaway_result=giveaway_result,
|
||||
invoice=invoice,
|
||||
location=location,
|
||||
poll=poll,
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@
|
|||
# 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 asyncio
|
||||
import pyrogram
|
||||
|
||||
from datetime import datetime
|
||||
from pyrogram import raw, types, utils
|
||||
from pyrogram.errors import FloodWait
|
||||
from ..object import Object
|
||||
from typing import List
|
||||
from typing import List, Dict
|
||||
|
||||
|
||||
class Giveaway(Object):
|
||||
|
|
@ -88,7 +86,11 @@ class Giveaway(Object):
|
|||
self.is_winners_hidden = is_winners_hidden
|
||||
|
||||
@staticmethod
|
||||
async def _parse(client, message: "raw.types.Message", chats: dict) -> "Giveaway":
|
||||
async def _parse(
|
||||
client,
|
||||
message: "raw.types.Message",
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> "Giveaway":
|
||||
giveaway: "raw.types.MessageMediaGiveaway" = message.media
|
||||
chats = types.List([types.Chat._parse_channel_chat(client, chats.get(i)) for i in giveaway.channels])
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import pyrogram
|
|||
from datetime import datetime
|
||||
from pyrogram import raw, types, utils
|
||||
from ..object import Object
|
||||
from typing import List, Union
|
||||
from typing import List, Union, Dict
|
||||
|
||||
|
||||
class GiveawayResult(Object):
|
||||
|
|
@ -104,7 +104,9 @@ class GiveawayResult(Object):
|
|||
"raw.types.MessageActionGiveawayResults",
|
||||
"raw.types.MessageMediaGiveawayResults"
|
||||
],
|
||||
hide_winners: bool = False
|
||||
hide_winners: bool = False,
|
||||
users: Dict[int, "raw.types.User"] = None,
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> "GiveawayResult":
|
||||
chat = None
|
||||
giveaway_message = None
|
||||
|
|
@ -112,17 +114,12 @@ class GiveawayResult(Object):
|
|||
winners = None
|
||||
if not hide_winners:
|
||||
chat_id = utils.get_channel_id(giveaway_result.channel_id)
|
||||
chat = await client.invoke(
|
||||
raw.functions.channels.GetChannels(
|
||||
id=[await client.resolve_peer(chat_id)]
|
||||
)
|
||||
)
|
||||
chat = types.Chat._parse_chat(client, chat.chats[0])
|
||||
chat = types.Chat._parse_channel_chat(client, chats.get(giveaway_result.channel_id))
|
||||
giveaway_message = await client.get_messages(chat_id, giveaway_result.launch_msg_id)
|
||||
expired_date = utils.timestamp_to_datetime(giveaway_result.until_date)
|
||||
winners = []
|
||||
for winner in giveaway_result.winners:
|
||||
winners.append(await client.get_users(winner))
|
||||
winners.append(types.User._parse(client, users.get(winner, None)))
|
||||
|
||||
stars = getattr(giveaway_result, "stars", None)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# 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 types, raw
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
import logging
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
from typing import List, Match, Union, BinaryIO, Optional, Callable
|
||||
from typing import List, Match, Union, BinaryIO, Optional, Callable, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import enums, raw, types, utils
|
||||
|
|
@ -690,9 +690,9 @@ class Message(Object, Update):
|
|||
async def _parse(
|
||||
client: "pyrogram.Client",
|
||||
message: raw.base.Message,
|
||||
users: dict,
|
||||
chats: dict,
|
||||
topics: dict = None,
|
||||
users: Dict[int, "raw.types.User"],
|
||||
chats: Dict[int, "raw.types.Chat"],
|
||||
topics: Dict[int, "raw.types.ForumTopic"] = None,
|
||||
is_scheduled: bool = False,
|
||||
business_connection_id: str = None,
|
||||
replies: int = 1
|
||||
|
|
@ -852,7 +852,7 @@ class Message(Object, Update):
|
|||
giveaway_launched = types.GiveawayLaunched._parse(client, action)
|
||||
service_type = enums.MessageServiceType.GIVEAWAY_LAUNCHED
|
||||
elif isinstance(action, raw.types.MessageActionGiveawayResults):
|
||||
giveaway_result = await types.GiveawayResult._parse(client, action, True)
|
||||
giveaway_result = await types.GiveawayResult._parse(client, action, True, users, chats)
|
||||
service_type = enums.MessageServiceType.GIVEAWAY_RESULT
|
||||
elif isinstance(action, raw.types.MessageActionBoostApply):
|
||||
boosts_applied = action.boosts
|
||||
|
|
@ -1042,7 +1042,7 @@ class Message(Object, Update):
|
|||
giveaway = await types.Giveaway._parse(client, message, chats)
|
||||
media_type = enums.MessageMediaType.GIVEAWAY
|
||||
elif isinstance(media, raw.types.MessageMediaGiveawayResults):
|
||||
giveaway_result = await types.GiveawayResult._parse(client, message.media)
|
||||
giveaway_result = await types.GiveawayResult._parse(client, message.media, users=users, chats=chats)
|
||||
media_type = enums.MessageMediaType.GIVEAWAY_RESULT
|
||||
elif isinstance(media, raw.types.MessageMediaStory):
|
||||
story = await types.MessageStory._parse(client, media)
|
||||
|
|
@ -1143,7 +1143,7 @@ class Message(Object, Update):
|
|||
from_user = types.User._parse(client, users.get(user_id, None))
|
||||
sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
|
||||
|
||||
reactions = types.MessageReactions._parse(client, message.reactions, users)
|
||||
reactions = types.MessageReactions._parse(client, message.reactions, users, chats)
|
||||
|
||||
if message.via_business_bot_id:
|
||||
sender_business_bot = types.User._parse(client, users.get(message.via_business_bot_id, None))
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# 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
|
||||
from typing import Optional, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, enums
|
||||
|
|
@ -82,7 +82,11 @@ class MessageEntity(Object):
|
|||
self.collapsed = collapsed
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, entity: "raw.base.MessageEntity", users: dict) -> Optional["MessageEntity"]:
|
||||
def _parse(
|
||||
client,
|
||||
entity: "raw.base.MessageEntity",
|
||||
users: Dict[int, "raw.types.User"] = None
|
||||
) -> Optional["MessageEntity"]:
|
||||
# Special case for InputMessageEntityMentionName -> MessageEntityType.TEXT_MENTION
|
||||
# This happens in case of UpdateShortSentMessage inside send_message() where entities are parsed from the input
|
||||
if isinstance(entity, raw.types.InputMessageEntityMentionName):
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ class MessageReactions(Object):
|
|||
def _parse(
|
||||
client: "pyrogram.Client",
|
||||
message_reactions: Optional["raw.base.MessageReactions"] = None,
|
||||
users: Optional[Dict[int, "raw.types.User"]] = None
|
||||
users: Optional[Dict[int, "raw.types.User"]] = None,
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> Optional["MessageReactions"]:
|
||||
if not message_reactions:
|
||||
return None
|
||||
|
|
@ -63,7 +64,7 @@ class MessageReactions(Object):
|
|||
for reaction in message_reactions.results
|
||||
],
|
||||
top_reactors=[
|
||||
types.MessageReactor._parse(client, reactor, users)
|
||||
types.MessageReactor._parse(client, reactor, users, chats)
|
||||
for reactor in message_reactions.top_reactors
|
||||
]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class MessageReactor(Object):
|
|||
|
||||
from_user (:obj:`~pyrogram.types.User`, *optional*):
|
||||
Information about the reactor.
|
||||
|
||||
sender_chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||
Information about the sender chat.
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
|
|
@ -51,7 +54,8 @@ class MessageReactor(Object):
|
|||
is_top: bool = None,
|
||||
is_my: bool = None,
|
||||
is_anonymous: bool = None,
|
||||
from_user: "types.User" = None
|
||||
from_user: "types.User" = None,
|
||||
sender_chat: "types.Chat" = None
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
|
|
@ -60,20 +64,32 @@ class MessageReactor(Object):
|
|||
self.is_my = is_my
|
||||
self.is_anonymous = is_anonymous
|
||||
self.from_user = from_user
|
||||
self.sender_chat = sender_chat
|
||||
|
||||
@staticmethod
|
||||
def _parse(
|
||||
client: "pyrogram.Client",
|
||||
message_reactor: Optional["raw.base.MessageReactor"] = None,
|
||||
users: Dict[int, "raw.types.User"] = None
|
||||
users: Dict[int, "raw.types.User"] = None,
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> Optional["MessageReactor"]:
|
||||
if not message_reactor:
|
||||
return None
|
||||
|
||||
is_anonymous = message_reactor.anonymous
|
||||
from_user = None
|
||||
sender_chat = None
|
||||
if not is_anonymous:
|
||||
from_user = types.User._parse(client, users.get(message_reactor.peer_id.user_id))
|
||||
if isinstance(message_reactor.peer, raw.types.PeerUser):
|
||||
from_user = types.User._parse(
|
||||
client,
|
||||
users.get(message_reactor.peer_id.user_id)
|
||||
)
|
||||
elif isinstance(message_reactor.peer, raw.types.PeerChannel):
|
||||
sender_chat = types.Chat._parse_channel_chat(
|
||||
client,
|
||||
chats.get(message_reactor.peer_id.channel_id)
|
||||
)
|
||||
|
||||
return MessageReactor(
|
||||
client=client,
|
||||
|
|
@ -81,5 +97,6 @@ class MessageReactor(Object):
|
|||
is_top=message_reactor.top,
|
||||
is_my=message_reactor.my,
|
||||
is_anonymous=is_anonymous,
|
||||
from_user=from_user
|
||||
from_user=from_user,
|
||||
sender_chat=sender_chat
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# along with PyroFork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types, utils
|
||||
from pyrogram import raw, utils
|
||||
from datetime import datetime
|
||||
from ..object import Object
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class Sticker(Object):
|
|||
Sticker.cache[(set_id, set_access_hash)] = name
|
||||
|
||||
if len(Sticker.cache) > 250:
|
||||
for i in range(50):
|
||||
for _ in range(50):
|
||||
Sticker.cache.pop(next(iter(Sticker.cache)))
|
||||
|
||||
return name
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ class Story(Object, Update):
|
|||
animation = None
|
||||
photo = None
|
||||
video = None
|
||||
media_type = None
|
||||
chat = None
|
||||
from_user = None
|
||||
sender_chat = None
|
||||
|
|
@ -268,14 +269,13 @@ class Story(Object, Update):
|
|||
elif isinstance(priv, raw.types.PrivacyValueDisallowContacts):
|
||||
privacy = enums.StoryPrivacy.NO_CONTACTS
|
||||
|
||||
'''
|
||||
if allowed_chats and len(allowed_chats) > 0:
|
||||
chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in allowed_chats]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||
if denied_chats and len(denied_chats) > 0:
|
||||
chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in denied_chats]
|
||||
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||
'''
|
||||
#if allowed_chats and len(allowed_chats) > 0:
|
||||
# chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in allowed_chats]
|
||||
# privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||
#if denied_chats and len(denied_chats) > 0:
|
||||
# chats = [int(str(chat_id)[3:]) if str(chat_id).startswith("-100") else chat_id for chat_id in denied_chats]
|
||||
# privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||
|
||||
if isinstance(priv, raw.types.PrivacyValueAllowUsers):
|
||||
allowed_users = priv.users
|
||||
if isinstance(priv, raw.types.PrivacyValueDisallowUsers):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
from typing import List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
|
||||
from ..object import Object
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from typing import List
|
|||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types, utils
|
||||
from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType, ThumbnailSource
|
||||
from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
# 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 pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from ..object import Object
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Optional, Union, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types, utils
|
||||
|
|
@ -226,7 +226,7 @@ class Gift(Object):
|
|||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
async def _parse(client, gift, users={}, chats={}):
|
||||
async def _parse(client, gift, users=None, chats=None):
|
||||
if isinstance(gift, raw.types.StarGift):
|
||||
return await Gift._parse_regular(client, gift)
|
||||
elif isinstance(gift, raw.types.StarGiftUnique):
|
||||
|
|
@ -263,8 +263,8 @@ class Gift(Object):
|
|||
async def _parse_unique(
|
||||
client,
|
||||
star_gift: "raw.types.StarGiftUnique",
|
||||
users: dict = {},
|
||||
chats: dict = {}
|
||||
users: Dict[int, "raw.types.User"] = None,
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> "Gift":
|
||||
owner_id = utils.get_raw_peer_id(getattr(star_gift, "owner_id", None))
|
||||
return Gift(
|
||||
|
|
@ -273,7 +273,7 @@ class Gift(Object):
|
|||
title=star_gift.title,
|
||||
collectible_id=star_gift.num,
|
||||
attributes=types.List(
|
||||
[await types.GiftAttribute._parse(client, attr, users, chats) for attr in star_gift.attributes]
|
||||
[await types.GiftAttribute._parse(client, attr, users) for attr in star_gift.attributes]
|
||||
) or None,
|
||||
available_amount=getattr(star_gift, "availability_issued", None),
|
||||
total_amount=getattr(star_gift, "availability_total", None),
|
||||
|
|
@ -289,8 +289,8 @@ class Gift(Object):
|
|||
async def _parse_saved(
|
||||
client,
|
||||
saved_gift: "raw.types.SavedStarGift",
|
||||
users: dict = {},
|
||||
chats: dict = {}
|
||||
users: Dict[int, "raw.types.User"] = None,
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> "Gift":
|
||||
caption, caption_entities = (
|
||||
utils.parse_text_with_entities(
|
||||
|
|
@ -324,8 +324,8 @@ class Gift(Object):
|
|||
async def _parse_action(
|
||||
client,
|
||||
message: "raw.base.Message",
|
||||
users: dict = {},
|
||||
chats: dict = {}
|
||||
users: Dict[int, "raw.types.User"] = None,
|
||||
chats: Dict[int, "raw.types.Chat"] = None
|
||||
) -> "Gift":
|
||||
action = message.action # type: raw.types.MessageActionStarGift
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import enums, raw, types, utils
|
||||
|
|
@ -119,8 +119,7 @@ class GiftAttribute(Object):
|
|||
async def _parse(
|
||||
client,
|
||||
attr: "raw.base.StarGiftAttribute",
|
||||
users: dict,
|
||||
chats: dict
|
||||
users: Dict[int, "raw.types.User"]
|
||||
) -> "GiftAttribute":
|
||||
caption = None
|
||||
caption_entities = None
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
import pyrogram
|
||||
|
||||
from ..object import Object
|
||||
from pyrogram import types, utils
|
||||
from pyrogram import raw, types, utils
|
||||
from typing import Dict
|
||||
|
||||
|
||||
class GiftCode(Object):
|
||||
|
|
@ -78,7 +79,11 @@ class GiftCode(Object):
|
|||
self.crypto_amount = crypto_amount
|
||||
|
||||
@staticmethod
|
||||
def _parse(client: "pyrogram.Client", gift_code: "types.GiftCode", chats: dict,) -> "GiftCode":
|
||||
def _parse(
|
||||
client: "pyrogram.Client",
|
||||
gift_code: "types.GiftCode",
|
||||
chats: Dict[int, "raw.types.Chat"]
|
||||
) -> "GiftCode":
|
||||
boosted_chat = None
|
||||
boosted_chat_raw = chats.get(utils.get_raw_peer_id(gift_code.boost_peer), None)
|
||||
if boosted_chat_raw:
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
# 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 random import choice
|
||||
|
||||
from pyrogram import raw, types
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@
|
|||
# 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 pyrogram
|
||||
|
||||
from pyrogram import raw, types, utils
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class PaymentForm(Object):
|
|||
bot=types.User._parse(client, users.get(payment_form.bot_id)),
|
||||
title=payment_form.title,
|
||||
description=payment_form.description,
|
||||
invoice=types.Invoice._parse(client, payment_form.invoice),
|
||||
invoice=types.Invoice._parse(payment_form.invoice),
|
||||
provider=types.User._parse(client, users.get(getattr(payment_form, "provider_id", None))),
|
||||
url=getattr(payment_form, "url", None),
|
||||
can_save_credentials=getattr(payment_form, "can_save_credentials", None),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
# 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 types
|
||||
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
from datetime import datetime
|
||||
from pyrogram import raw, types, utils
|
||||
from typing import Dict
|
||||
from ..object import Object
|
||||
|
||||
class StarsTransaction(Object):
|
||||
|
|
@ -100,7 +101,7 @@ class StarsTransaction(Object):
|
|||
def _parse(
|
||||
client,
|
||||
transaction: "raw.types.StarsTransaction",
|
||||
users: dict
|
||||
users: Dict[int, "raw.types.User"]
|
||||
) -> "StarsTransaction":
|
||||
chat_id = utils.get_raw_peer_id(transaction.peer.peer)
|
||||
chat = types.User._parse(client, users.get(chat_id, None))
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
# 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 pyrogram
|
||||
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from ..object import Object
|
||||
|
|
|
|||
|
|
@ -16,10 +16,7 @@
|
|||
# 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
|
||||
|
||||
from pyrogram import raw
|
||||
from pyrogram import enums
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# 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
|
||||
from typing import Optional, Dict
|
||||
|
||||
from pyrogram import types, raw
|
||||
from ..object import Object
|
||||
|
|
@ -62,7 +62,7 @@ class BusinessInfo(Object):
|
|||
def _parse(
|
||||
client,
|
||||
user: "raw.types.UserFull" = None,
|
||||
users: dict = None
|
||||
users: Dict[int, "raw.types.User"] = None
|
||||
) -> Optional["BusinessInfo"]:
|
||||
working_hours = getattr(user, "business_work_hours", None)
|
||||
location = getattr(user, "business_location", None)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional, Union, List
|
||||
from typing import Optional, Union, List, Dict
|
||||
|
||||
from pyrogram import types, enums, raw, utils
|
||||
from ..object import Object
|
||||
|
|
@ -83,7 +83,7 @@ class BusinessMessage(Object):
|
|||
def _parse(
|
||||
client,
|
||||
message: Union["raw.types.BusinessGreetingMessage", "raw.types.BusinessAwayMessage"] = None,
|
||||
users: dict = None
|
||||
users: Dict[int, "raw.types.User"] = None
|
||||
) -> Optional["BusinessMessage"]:
|
||||
if not message:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# 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
|
||||
from typing import List, Dict
|
||||
|
||||
from pyrogram import types, raw
|
||||
from ..object import Object
|
||||
|
|
@ -66,7 +66,7 @@ class BusinessRecipients(Object):
|
|||
def _parse(
|
||||
client,
|
||||
recipients: "raw.types.BusinessRecipients",
|
||||
users: dict = None
|
||||
users: Dict[int, "raw.types.User"] = None
|
||||
) -> "BusinessRecipients":
|
||||
return BusinessRecipients(
|
||||
existing_chats=getattr(recipients, "existing_chats", None),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Union, List, Optional, AsyncGenerator, BinaryIO
|
||||
from typing import Union, List, Optional, AsyncGenerator, BinaryIO, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, enums
|
||||
|
|
@ -434,8 +434,8 @@ class Chat(Object):
|
|||
def _parse(
|
||||
client,
|
||||
message: Union[raw.types.Message, raw.types.MessageService],
|
||||
users: dict,
|
||||
chats: dict,
|
||||
users: Dict[int, "raw.types.User"],
|
||||
chats: Dict[int, "raw.types.Chat"],
|
||||
is_chat: bool
|
||||
) -> "Chat":
|
||||
from_id = utils.get_raw_peer_id(message.from_id)
|
||||
|
|
@ -451,7 +451,16 @@ class Chat(Object):
|
|||
return Chat._parse_channel_chat(client, chats[chat_id])
|
||||
|
||||
@staticmethod
|
||||
def _parse_dialog(client, peer, users: dict, chats: dict):
|
||||
def _parse_dialog(
|
||||
client,
|
||||
peer: Union[
|
||||
raw.types.PeerUser,
|
||||
raw.types.PeerChat,
|
||||
raw.types.PeerChannel
|
||||
],
|
||||
users: Dict[int, "raw.types.User"],
|
||||
chats: Dict[int, "raw.types.Chat"]
|
||||
) -> "Chat":
|
||||
if isinstance(peer, raw.types.PeerUser):
|
||||
return Chat._parse_user_chat(client, users[peer.user_id])
|
||||
elif isinstance(peer, raw.types.PeerChat):
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
# 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, types
|
||||
from typing import Union
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue