mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Compare commits
6 commits
28f7137828
...
7fabbd8c14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fabbd8c14 | ||
|
|
588a9d2ec6 | ||
|
|
9a8fcec0dc | ||
|
|
4df8138e79 | ||
|
|
6835bccf11 | ||
|
|
c7f7707fc6 |
10 changed files with 97 additions and 12 deletions
|
|
@ -605,6 +605,7 @@ def pyrogram_api():
|
|||
Invoice
|
||||
LabeledPrice
|
||||
PaidMedia
|
||||
PaidMessagePriceChanged
|
||||
PaymentForm
|
||||
PaymentInfo
|
||||
PaymentRefunded
|
||||
|
|
|
|||
|
|
@ -503,3 +503,4 @@ BOOSTS_EMPTY You can't modify the icon of the General topic.
|
|||
BOOST_NOT_MODIFIED You're already boosting the specified channel.
|
||||
PAYMENT_REQUIRED The payment is required
|
||||
BOOST_PEER_INVALID The specified `boost_peer` is invalid.
|
||||
STARS_AMOUNT_INVALID The specified `amount` is invalid.
|
||||
|
|
|
@ -44,3 +44,4 @@ GROUPCALL_ALREADY_STARTED The groupcall has already started, you can join direct
|
|||
GROUPCALL_FORBIDDEN The group call has already ended
|
||||
LIVE_DISABLED Story is disabled server-side
|
||||
CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commenting
|
||||
ALLOW_PAYMENT_REQUIRED_X Payment of {value} stars is required to perform this action
|
||||
|
|
|
@ -39,3 +39,9 @@ class ChatType(AutoName):
|
|||
|
||||
CHANNEL = auto()
|
||||
"Chat is a channel"
|
||||
|
||||
FORUM = auto()
|
||||
"Chat is a forum"
|
||||
|
||||
MONOFORUM = auto()
|
||||
"Chat is a monoforum"
|
||||
|
|
|
|||
|
|
@ -132,3 +132,6 @@ class MessageServiceType(AutoName):
|
|||
|
||||
SCREENSHOT_TAKEN = auto()
|
||||
"Screenshot taken"
|
||||
|
||||
PAID_MESSAGE_PRICE_CHANGED = auto()
|
||||
"Paid message price changed"
|
||||
|
|
|
|||
|
|
@ -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 pyrogram import raw, types
|
||||
from pyrogram import enums, raw, types
|
||||
from ..object import Object
|
||||
from typing import Union
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ class KeyboardButton(Object):
|
|||
is_creator=b.peer_type.creator,
|
||||
is_bot_participant=b.peer_type.bot_participant,
|
||||
is_username=b.peer_type.has_username,
|
||||
is_forum=b.peer_type.forum,
|
||||
is_forum=True if b.peer_type.type == enums.ChatType.FORUM else False,
|
||||
max=b.max_quantity
|
||||
)
|
||||
)
|
||||
|
|
@ -155,7 +155,7 @@ class KeyboardButton(Object):
|
|||
creator=self.request_chat.is_creator,
|
||||
bot_participant=self.request_chat.is_bot_participant,
|
||||
has_username=self.request_chat.is_username,
|
||||
forum=self.request_chat.is_forum
|
||||
forum=True if self.request_chat.type == enums.ChatType.FORUM else False
|
||||
),
|
||||
max_quantity=self.request_chat.max,
|
||||
name_requested=self.request_chat.is_name_requested,
|
||||
|
|
|
|||
|
|
@ -480,6 +480,7 @@ class Message(Object, Update):
|
|||
gift_code: "types.GiftCode" = None,
|
||||
gift: "types.Gift" = None,
|
||||
screenshot_taken: "types.ScreenshotTaken" = None,
|
||||
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
|
||||
invoice: "types.Invoice" = None,
|
||||
story: Union["types.MessageStory", "types.Story"] = None,
|
||||
alternative_videos: List["types.AlternativeVideo"] = None,
|
||||
|
|
@ -596,6 +597,7 @@ class Message(Object, Update):
|
|||
self.gift_code = gift_code
|
||||
self.gift = gift
|
||||
self.screenshot_taken = screenshot_taken
|
||||
self.paid_message_price_changed = paid_message_price_changed
|
||||
self.invoice = invoice
|
||||
self.story = story
|
||||
self.video = video
|
||||
|
|
@ -760,6 +762,7 @@ class Message(Object, Update):
|
|||
gift_code = None
|
||||
gift = None
|
||||
screenshot_taken = None
|
||||
paid_message_price_changed = None
|
||||
|
||||
service_type = None
|
||||
chat_join_type = None
|
||||
|
|
@ -881,6 +884,9 @@ class Message(Object, Update):
|
|||
elif isinstance(action, raw.types.MessageActionScreenshotTaken):
|
||||
screenshot_taken = types.ScreenshotTaken()
|
||||
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
|
||||
elif isinstance(action, raw.types.MessageActionPaidMessagesPrice):
|
||||
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
|
||||
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
|
||||
|
||||
parsed_message = Message(
|
||||
id=message.id,
|
||||
|
|
@ -926,6 +932,7 @@ class Message(Object, Update):
|
|||
contact_registered=contact_registered,
|
||||
gift_code=gift_code,
|
||||
screenshot_taken=screenshot_taken,
|
||||
paid_message_price_changed=paid_message_price_changed,
|
||||
raw=message,
|
||||
chat_join_type=chat_join_type,
|
||||
client=client
|
||||
|
|
@ -970,7 +977,7 @@ class Message(Object, Update):
|
|||
else:
|
||||
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
|
||||
parsed_message.is_topic_message = True
|
||||
elif parsed_message.chat.is_forum and parsed_message.message_thread_id is None:
|
||||
elif parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
|
||||
parsed_message.message_thread_id = 1
|
||||
parsed_message.is_topic_message = True
|
||||
|
||||
|
|
@ -1299,7 +1306,7 @@ class Message(Object, Update):
|
|||
pass
|
||||
else:
|
||||
parsed_message.reply_to_story = reply_to_story
|
||||
if parsed_message.chat.is_forum and parsed_message.message_thread_id is None:
|
||||
if parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
|
||||
parsed_message.message_thread_id = 1
|
||||
parsed_message.is_topic_message = True
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ from .input_stars_transaction import InputStarsTransaction
|
|||
from .invoice import Invoice
|
||||
from .labeled_price import LabeledPrice
|
||||
from .paid_media import PaidMedia
|
||||
from .paid_message_price_changed import PaidMessagePriceChanged
|
||||
from .payment_form import PaymentForm
|
||||
from .payment_info import PaymentInfo
|
||||
from .payment_refunded import PaymentRefunded
|
||||
|
|
@ -46,6 +47,7 @@ __all__ = [
|
|||
"Invoice",
|
||||
"LabeledPrice",
|
||||
"PaidMedia",
|
||||
"PaidMessagePriceChanged",
|
||||
"PaymentForm",
|
||||
"PaymentInfo",
|
||||
"PaymentRefunded",
|
||||
|
|
|
|||
49
pyrogram/types/payments/paid_message_price_changed.py
Normal file
49
pyrogram/types/payments/paid_message_price_changed.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||
#
|
||||
# This file is part of Pyrofork.
|
||||
#
|
||||
# Pyrofork is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrofork is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import List, Union
|
||||
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class PaidMessagePriceChanged(Object):
|
||||
"""A PaidMessagePriceChanged.
|
||||
|
||||
Parameters:
|
||||
stars_amount (``int``):
|
||||
Amount of stars.
|
||||
|
||||
extended_media (List of :obj:`~pyrogram.types.Animation` | :obj:`~pyrogram.types.ExtendedMediaPreview` | :obj:`~pyrogram.types.Photo` | :obj:`~pyrogram.types.Video`, *optional*):
|
||||
Extended media.
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
stars_amount: int,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.stars_amount = stars_amount
|
||||
|
||||
@staticmethod
|
||||
def _parse(action: "raw.types.MessageActionPaidMessagesPrice") -> "PaidMessagePriceChanged":
|
||||
return PaidMessagePriceChanged(
|
||||
stars_amount=action.stars
|
||||
)
|
||||
|
|
@ -56,9 +56,6 @@ class Chat(Object):
|
|||
is_support (``bool``):
|
||||
True, if this chat is part of the Telegram support team. Users and bots only.
|
||||
|
||||
is_forum (``bool``, *optional*):
|
||||
True, if the supergroup chat is a forum
|
||||
|
||||
is_participants_hidden (``bool``, *optional*):
|
||||
True, if the chat members are hidden.
|
||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||
|
|
@ -170,6 +167,10 @@ class Chat(Object):
|
|||
The linked discussion group (in case of channels) or the linked channel (in case of supergroups).
|
||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||
|
||||
linked_forum (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||
The linked monoforum (in case of channels) or the linked channel (in case of monoforum).
|
||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||
|
||||
send_as_chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||
The default "send_as" chat.
|
||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||
|
|
@ -231,7 +232,6 @@ class Chat(Object):
|
|||
is_scam: bool = None,
|
||||
is_fake: bool = None,
|
||||
is_support: bool = None,
|
||||
is_forum: bool = None,
|
||||
is_participants_hidden: bool = None,
|
||||
is_join_request: bool = None,
|
||||
is_join_to_send: bool = None,
|
||||
|
|
@ -263,6 +263,7 @@ class Chat(Object):
|
|||
permissions: "types.ChatPermissions" = None,
|
||||
distance: int = None,
|
||||
linked_chat: "types.Chat" = None,
|
||||
linked_forum: "types.Chat" = None,
|
||||
send_as_chat: "types.Chat" = None,
|
||||
available_reactions: Optional["types.ChatReactions"] = None,
|
||||
usernames: List["types.Username"] = None,
|
||||
|
|
@ -286,7 +287,6 @@ class Chat(Object):
|
|||
self.is_scam = is_scam
|
||||
self.is_fake = is_fake
|
||||
self.is_support = is_support
|
||||
self.is_forum = is_forum
|
||||
self.is_participants_hidden = is_participants_hidden
|
||||
self.is_join_request = is_join_request
|
||||
self.is_join_to_send = is_join_to_send
|
||||
|
|
@ -318,6 +318,7 @@ class Chat(Object):
|
|||
self.permissions = permissions
|
||||
self.distance = distance
|
||||
self.linked_chat = linked_chat
|
||||
self.linked_forum = linked_forum
|
||||
self.send_as_chat = send_as_chat
|
||||
self.available_reactions = available_reactions
|
||||
self.usernames = usernames
|
||||
|
|
@ -394,6 +395,16 @@ class Chat(Object):
|
|||
restriction_reason = getattr(channel, "restriction_reason", [])
|
||||
user_name = getattr(channel, "username", None)
|
||||
active_usernames = getattr(channel, "usernames", [])
|
||||
if getattr(channel, "monoforum", None):
|
||||
chat_type = enums.ChatType.MONOFORUM
|
||||
elif getattr(channel, "forum", None):
|
||||
chat_type = enums.ChatType.FORUM
|
||||
elif getattr(channel, "megagroup", None):
|
||||
chat_type = enums.ChatType.SUPERGROUP
|
||||
elif getattr(channel, "broadcast", None):
|
||||
chat_type = enums.ChatType.CHANNEL
|
||||
else:
|
||||
chat_type = enums.ChatType.GROUP
|
||||
usernames = None
|
||||
if len(active_usernames) >= 1:
|
||||
usernames = []
|
||||
|
|
@ -410,13 +421,12 @@ class Chat(Object):
|
|||
|
||||
return Chat(
|
||||
id=peer_id,
|
||||
type=enums.ChatType.SUPERGROUP if getattr(channel, "megagroup", None) else enums.ChatType.CHANNEL,
|
||||
type=chat_type,
|
||||
is_verified=getattr(channel, "verified", None),
|
||||
is_restricted=getattr(channel, "restricted", None),
|
||||
is_creator=getattr(channel, "creator", None),
|
||||
is_scam=getattr(channel, "scam", None),
|
||||
is_fake=getattr(channel, "fake", None),
|
||||
is_forum=getattr(channel, "forum", None),
|
||||
is_join_request=getattr(channel, "join_request", None),
|
||||
is_join_to_send=getattr(channel, "join_to_send", None),
|
||||
is_slowmode_enabled=getattr(channel, "slowmode_enabled", None),
|
||||
|
|
@ -546,9 +556,14 @@ class Chat(Object):
|
|||
|
||||
linked_chat_raw = chats.get(full_chat.linked_chat_id, None)
|
||||
|
||||
linked_forum_raw = chats.get(getattr(chat_raw, "linked_monoforum_id"), None)
|
||||
|
||||
if linked_chat_raw:
|
||||
parsed_chat.linked_chat = Chat._parse_channel_chat(client, linked_chat_raw)
|
||||
|
||||
if linked_forum_raw:
|
||||
parsed_chat.linked_forum = Chat._parse_channel_chat(client, linked_forum_raw)
|
||||
|
||||
default_send_as = full_chat.default_send_as
|
||||
|
||||
if default_send_as:
|
||||
|
|
|
|||
Loading…
Reference in a new issue