Compare commits

...

6 commits

Author SHA1 Message Date
wulan17
7fabbd8c14
pyrofork: Add STARS_AMOUNT_INVALID exception
Some checks are pending
Build-docs / build (push) Waiting to run
Pyrofork / build (macos-latest, 3.10) (push) Waiting to run
Pyrofork / build (macos-latest, 3.11) (push) Waiting to run
Pyrofork / build (macos-latest, 3.12) (push) Waiting to run
Pyrofork / build (macos-latest, 3.13) (push) Waiting to run
Pyrofork / build (macos-latest, 3.9) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.10) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.11) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.12) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.13) (push) Waiting to run
Pyrofork / build (ubuntu-latest, 3.9) (push) Waiting to run
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-09 22:44:59 +07:00
wulan17
588a9d2ec6
pyrofork: Add paid_message_price_changed field to Message
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-09 22:36:11 +07:00
wulan17
9a8fcec0dc
pyrofork: Add ALLOW_PAYMENT_REQUIRED_X exception
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-09 22:26:27 +07:00
wulan17
4df8138e79
pyrofork: Add linked_forum field to Chat
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-09 22:04:45 +07:00
wulan17
6835bccf11
pyrofork: Drop Chat.is_forum and add new ChatType (FORUM)
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-09 22:00:51 +07:00
wulan17
c7f7707fc6
pyrofork: Add new ChatType (MONOFORUM)
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-09 22:00:17 +07:00
10 changed files with 97 additions and 12 deletions

View file

@ -605,6 +605,7 @@ def pyrogram_api():
Invoice Invoice
LabeledPrice LabeledPrice
PaidMedia PaidMedia
PaidMessagePriceChanged
PaymentForm PaymentForm
PaymentInfo PaymentInfo
PaymentRefunded PaymentRefunded

View file

@ -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. BOOST_NOT_MODIFIED You're already boosting the specified channel.
PAYMENT_REQUIRED The payment is required PAYMENT_REQUIRED The payment is required
BOOST_PEER_INVALID The specified `boost_peer` is invalid. BOOST_PEER_INVALID The specified `boost_peer` is invalid.
STARS_AMOUNT_INVALID The specified `amount` is invalid.
1 id message
503 BOOST_NOT_MODIFIED You're already boosting the specified channel.
504 PAYMENT_REQUIRED The payment is required
505 BOOST_PEER_INVALID The specified `boost_peer` is invalid.
506 STARS_AMOUNT_INVALID The specified `amount` is invalid.

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from pyrogram import raw, types from pyrogram import enums, raw, types
from ..object import Object from ..object import Object
from typing import Union from typing import Union
@ -114,7 +114,7 @@ class KeyboardButton(Object):
is_creator=b.peer_type.creator, is_creator=b.peer_type.creator,
is_bot_participant=b.peer_type.bot_participant, is_bot_participant=b.peer_type.bot_participant,
is_username=b.peer_type.has_username, is_username=b.peer_type.has_username,
is_forum=b.peer_type.forum, is_forum=True if b.peer_type.type == enums.ChatType.FORUM else False,
max=b.max_quantity max=b.max_quantity
) )
) )
@ -155,7 +155,7 @@ class KeyboardButton(Object):
creator=self.request_chat.is_creator, creator=self.request_chat.is_creator,
bot_participant=self.request_chat.is_bot_participant, bot_participant=self.request_chat.is_bot_participant,
has_username=self.request_chat.is_username, has_username=self.request_chat.is_username,
forum=self.request_chat.is_forum forum=True if self.request_chat.type == enums.ChatType.FORUM else False
), ),
max_quantity=self.request_chat.max, max_quantity=self.request_chat.max,
name_requested=self.request_chat.is_name_requested, name_requested=self.request_chat.is_name_requested,

View file

@ -480,6 +480,7 @@ class Message(Object, Update):
gift_code: "types.GiftCode" = None, gift_code: "types.GiftCode" = None,
gift: "types.Gift" = None, gift: "types.Gift" = None,
screenshot_taken: "types.ScreenshotTaken" = None, screenshot_taken: "types.ScreenshotTaken" = None,
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
invoice: "types.Invoice" = None, invoice: "types.Invoice" = None,
story: Union["types.MessageStory", "types.Story"] = None, story: Union["types.MessageStory", "types.Story"] = None,
alternative_videos: List["types.AlternativeVideo"] = None, alternative_videos: List["types.AlternativeVideo"] = None,
@ -596,6 +597,7 @@ class Message(Object, Update):
self.gift_code = gift_code self.gift_code = gift_code
self.gift = gift self.gift = gift
self.screenshot_taken = screenshot_taken self.screenshot_taken = screenshot_taken
self.paid_message_price_changed = paid_message_price_changed
self.invoice = invoice self.invoice = invoice
self.story = story self.story = story
self.video = video self.video = video
@ -760,6 +762,7 @@ class Message(Object, Update):
gift_code = None gift_code = None
gift = None gift = None
screenshot_taken = None screenshot_taken = None
paid_message_price_changed = None
service_type = None service_type = None
chat_join_type = None chat_join_type = None
@ -881,6 +884,9 @@ class Message(Object, Update):
elif isinstance(action, raw.types.MessageActionScreenshotTaken): elif isinstance(action, raw.types.MessageActionScreenshotTaken):
screenshot_taken = types.ScreenshotTaken() screenshot_taken = types.ScreenshotTaken()
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
elif isinstance(action, raw.types.MessageActionPaidMessagesPrice):
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
parsed_message = Message( parsed_message = Message(
id=message.id, id=message.id,
@ -926,6 +932,7 @@ class Message(Object, Update):
contact_registered=contact_registered, contact_registered=contact_registered,
gift_code=gift_code, gift_code=gift_code,
screenshot_taken=screenshot_taken, screenshot_taken=screenshot_taken,
paid_message_price_changed=paid_message_price_changed,
raw=message, raw=message,
chat_join_type=chat_join_type, chat_join_type=chat_join_type,
client=client client=client
@ -970,7 +977,7 @@ class Message(Object, Update):
else: else:
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
parsed_message.is_topic_message = True parsed_message.is_topic_message = True
elif parsed_message.chat.is_forum and parsed_message.message_thread_id is None: elif parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
parsed_message.message_thread_id = 1 parsed_message.message_thread_id = 1
parsed_message.is_topic_message = True parsed_message.is_topic_message = True
@ -1299,7 +1306,7 @@ class Message(Object, Update):
pass pass
else: else:
parsed_message.reply_to_story = reply_to_story parsed_message.reply_to_story = reply_to_story
if parsed_message.chat.is_forum and parsed_message.message_thread_id is None: if parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
parsed_message.message_thread_id = 1 parsed_message.message_thread_id = 1
parsed_message.is_topic_message = True parsed_message.is_topic_message = True

View file

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

View file

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

View file

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