Merge branch 'Mayuri-Chan:main' into main

This commit is contained in:
naya1503 2024-07-12 16:36:44 +07:00 committed by GitHub
commit 3c39556a42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 114 additions and 6 deletions

View file

@ -111,7 +111,7 @@ channel#aadfc8f flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5
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;
channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull;
chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant;
chatParticipantCreator#e46bcee4 user_id:long = ChatParticipant; chatParticipantCreator#e46bcee4 user_id:long = ChatParticipant;
@ -188,6 +188,7 @@ messageActionGiveawayLaunch#332ba9ed = MessageAction;
messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction; messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction;
messageActionBoostApply#cc02aa6d boosts:int = MessageAction; messageActionBoostApply#cc02aa6d boosts:int = MessageAction;
messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector<RequestedPeer> = MessageAction; messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector<RequestedPeer> = MessageAction;
messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_amount:long payload:flags.0?bytes charge:PaymentCharge = 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;
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; 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;
@ -2502,4 +2503,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 183 // LAYER 184

View file

@ -550,6 +550,7 @@ def pyrogram_api():
BotApp BotApp
BotBusinessConnection BotBusinessConnection
PaymentInfo PaymentInfo
PaymentRefunded
ShippingAddress ShippingAddress
ShippingOption ShippingOption
ShippingQuery ShippingQuery

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.31" __version__ = "2.3.32"
__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

@ -115,5 +115,8 @@ class MessageServiceType(AutoName):
SUCCESSFUL_PAYMENT = auto() SUCCESSFUL_PAYMENT = auto()
"Successful payment" "Successful payment"
PAYMENT_REFUNDED = auto()
"Payment refunded"
BOT_ALLOWED = auto() BOT_ALLOWED = auto()
"Bot allowed" "Bot allowed"

View file

@ -30,6 +30,7 @@ class SendInvoice:
prices: List["types.LabeledPrice"], prices: List["types.LabeledPrice"],
provider: str = None, provider: str = None,
provider_data: str = None, provider_data: str = None,
payload: str = None,
photo_url: str = None, photo_url: str = None,
photo_size: int = None, photo_size: int = None,
photo_mime_type: str = None, photo_mime_type: str = None,
@ -69,6 +70,10 @@ class SendInvoice:
provider_data (``str``, *optional*): provider_data (``str``, *optional*):
Provider data in json format. Provider data in json format.
payload (``str``, *optional*):
Bot-defined invoice payload, 1-128 bytes.
This will not be displayed to the user, use for your internal processes.
photo_url (``str``, *optional*): photo_url (``str``, *optional*):
Photo URL. Photo URL.
@ -151,6 +156,10 @@ class SendInvoice:
quote_entities=quote_entities quote_entities=quote_entities
) )
if payload is not None:
encoded_payload = payload.encode()
else:
encoded_payload = f"{(title)}".encode()
r = await self.invoke( r = await self.invoke(
raw.functions.messages.SendMedia( raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
@ -161,7 +170,7 @@ class SendInvoice:
currency=currency, currency=currency,
prices=[price.write() for price in prices] prices=[price.write() for price in prices]
), ),
payload=f"{(title)}".encode(), payload=encoded_payload,
provider=provider, provider=provider,
provider_data=raw.types.DataJSON(data=provider_data if provider_data else "{}"), provider_data=raw.types.DataJSON(data=provider_data if provider_data else "{}"),
photo=raw.types.InputWebDocument( photo=raw.types.InputWebDocument(

View file

@ -45,6 +45,7 @@ from .menu_button_commands import MenuButtonCommands
from .menu_button_default import MenuButtonDefault from .menu_button_default import MenuButtonDefault
from .menu_button_web_app import MenuButtonWebApp from .menu_button_web_app import MenuButtonWebApp
from .payment_info import PaymentInfo from .payment_info import PaymentInfo
from .payment_refunded import PaymentRefunded
from .pre_checkout_query import PreCheckoutQuery from .pre_checkout_query import PreCheckoutQuery
from .reply_keyboard_markup import ReplyKeyboardMarkup from .reply_keyboard_markup import ReplyKeyboardMarkup
from .reply_keyboard_remove import ReplyKeyboardRemove from .reply_keyboard_remove import ReplyKeyboardRemove
@ -97,6 +98,7 @@ __all__ = [
"ShippingOption", "ShippingOption",
"ShippingQuery", "ShippingQuery",
"PaymentInfo", "PaymentInfo",
"PaymentRefunded",
"PreCheckoutQuery", "PreCheckoutQuery",
"SuccessfulPayment" "SuccessfulPayment"
] ]

View file

@ -0,0 +1,82 @@
# 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/>.
import pyrogram
from pyrogram import raw
from pyrogram import types
from ..object import Object
class PaymentRefunded(Object):
"""Contains information about a refunded payment.
Parameters:
user (:obj:`~pyrogram.types.User`):
The user that refunded the payment.
currency (``str``):
Three-letter ISO 4217 currency code.
total_amount (``int``):
Total price in the smallest units of the currency.
payload (``str``, *optional*):
Bot specified invoice payload. Only available to the bot that received the payment.
telegram_payment_charge_id (``str``, *optional*):
Telegram payment identifier.
provider_payment_charge_id (``str``, *optional*):
Provider payment identifier.
"""
def __init__(
self, *,
user: "types.User",
currency: str,
total_amount: str,
telegram_payment_charge_id: str,
provider_payment_charge_id: str,
payload: str = None
):
self.user = user
self.currency = currency
self.total_amount = total_amount
self.telegram_payment_charge_id = telegram_payment_charge_id
self.provider_payment_charge_id = provider_payment_charge_id
self.payload = payload
@staticmethod
async def _parse(
client: "pyrogram.Client",
payment_refunded: "raw.types.MessageActionPaymentRefunded"
) -> "PaymentRefunded":
try:
payload = payment_refunded.payload.decode()
except (UnicodeDecodeError, AttributeError):
payload = payment_refunded.payload
return PaymentRefunded(
user=await client.get_users(payment_refunded.peer.user_id),
currency=payment_refunded.currency,
total_amount=payment_refunded.total_amount,
telegram_payment_charge_id=payment_refunded.charge.id if payment_refunded.charge.id != "" else None,
provider_payment_charge_id=payment_refunded.charge.provider_charge_id if payment_refunded.charge.provider_charge_id != "" else None,
payload=payload
)

View file

@ -106,7 +106,7 @@ class SuccessfulPayment(Object):
total_amount=successful_payment.total_amount, total_amount=successful_payment.total_amount,
payload=payload, payload=payload,
telegram_payment_charge_id=telegram_payment_charge_id, telegram_payment_charge_id=telegram_payment_charge_id,
provider_payment_charge_id=shipping_option_id, provider_payment_charge_id=provider_payment_charge_id,
shipping_option_id=shipping_option_id, shipping_option_id=shipping_option_id,
payment_info=payment_info payment_info=payment_info
) )

View file

@ -395,6 +395,9 @@ class Message(Object, Update):
successful_payment (:obj:`~pyrogram.types.SuccessfulPayment`, *optional*): successful_payment (:obj:`~pyrogram.types.SuccessfulPayment`, *optional*):
Service message: successful payment. Service message: successful payment.
payment_refunded (:obj:`~pyrogram.types.PaymentRefunded`, *optional*):
Service message: payment refunded.
boosts_applied (``int``, *optional*): boosts_applied (``int``, *optional*):
Service message: how many boosts were applied. Service message: how many boosts were applied.
@ -424,7 +427,7 @@ class Message(Object, Update):
Message is a scheduled message and has been sent. Message is a scheduled message and has been sent.
""" """
# TODO: Add game missing field. Also invoice, successful_payment, connected_website # TODO: Add game missing field, Also connected_website
def __init__( def __init__(
self, self,
@ -530,6 +533,7 @@ class Message(Object, Update):
video_chat_members_invited: "types.VideoChatMembersInvited" = None, video_chat_members_invited: "types.VideoChatMembersInvited" = None,
web_app_data: "types.WebAppData" = None, web_app_data: "types.WebAppData" = None,
successful_payment: "types.SuccessfulPayment" = None, successful_payment: "types.SuccessfulPayment" = None,
payment_refunded: "types.PaymentRefunded" = None,
reply_markup: Union[ reply_markup: Union[
"types.InlineKeyboardMarkup", "types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup", "types.ReplyKeyboardMarkup",
@ -642,6 +646,7 @@ class Message(Object, Update):
self.video_chat_members_invited = video_chat_members_invited self.video_chat_members_invited = video_chat_members_invited
self.web_app_data = web_app_data self.web_app_data = web_app_data
self.successful_payment = successful_payment self.successful_payment = successful_payment
self.payment_refunded = payment_refunded
self.reactions = reactions self.reactions = reactions
self.raw = raw self.raw = raw
@ -749,6 +754,7 @@ class Message(Object, Update):
giveaway_launched = None giveaway_launched = None
giveaway_result = None giveaway_result = None
successful_payment = None successful_payment = None
payment_refunded = None
boosts_applied = None boosts_applied = None
service_type = None service_type = None
@ -856,6 +862,9 @@ class Message(Object, Update):
elif isinstance(action, (raw.types.MessageActionPaymentSent, raw.types.MessageActionPaymentSentMe)): elif isinstance(action, (raw.types.MessageActionPaymentSent, raw.types.MessageActionPaymentSentMe)):
successful_payment = types.SuccessfulPayment._parse(client, action) successful_payment = types.SuccessfulPayment._parse(client, action)
service_type = enums.MessageServiceType.SUCCESSFUL_PAYMENT service_type = enums.MessageServiceType.SUCCESSFUL_PAYMENT
elif isinstance(action, raw.types.MessageActionPaymentRefunded):
payment_refunded = await types.PaymentRefunded._parse(client, action)
service_type = enums.MessageServiceType.PAYMENT_REFUNDED
parsed_message = Message( parsed_message = Message(
id=message.id, id=message.id,
@ -894,6 +903,7 @@ class Message(Object, Update):
giveaway_launched=giveaway_launched, giveaway_launched=giveaway_launched,
giveaway_result=giveaway_result, giveaway_result=giveaway_result,
successful_payment=successful_payment, successful_payment=successful_payment,
payment_refunded=payment_refunded,
boosts_applied=boosts_applied, boosts_applied=boosts_applied,
raw=message, raw=message,
client=client client=client