mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
Compare commits
9 commits
86ac12c213
...
7fabbd8c14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fabbd8c14 | ||
|
|
588a9d2ec6 | ||
|
|
9a8fcec0dc | ||
|
|
4df8138e79 | ||
|
|
6835bccf11 | ||
|
|
c7f7707fc6 | ||
|
|
28f7137828 | ||
|
|
7c94fc8009 | ||
|
|
969a2c0f55 |
15 changed files with 133 additions and 23 deletions
|
|
@ -605,6 +605,7 @@ def pyrogram_api():
|
||||||
Invoice
|
Invoice
|
||||||
LabeledPrice
|
LabeledPrice
|
||||||
PaidMedia
|
PaidMedia
|
||||||
|
PaidMessagePriceChanged
|
||||||
PaymentForm
|
PaymentForm
|
||||||
PaymentInfo
|
PaymentInfo
|
||||||
PaymentRefunded
|
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.
|
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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ class SendMediaGroup:
|
||||||
w=i.width,
|
w=i.width,
|
||||||
h=i.height
|
h=i.height
|
||||||
),
|
),
|
||||||
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)),
|
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media)),
|
||||||
]
|
]
|
||||||
if is_animation:
|
if is_animation:
|
||||||
attributes.append(raw.types.DocumentAttributeAnimated())
|
attributes.append(raw.types.DocumentAttributeAnimated())
|
||||||
|
|
@ -339,7 +339,7 @@ class SendMediaGroup:
|
||||||
w=i.width,
|
w=i.width,
|
||||||
h=i.height
|
h=i.height
|
||||||
),
|
),
|
||||||
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "video.mp4")),
|
raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "video.mp4")),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -371,7 +371,7 @@ class SendMediaGroup:
|
||||||
performer=i.performer,
|
performer=i.performer,
|
||||||
title=i.title
|
title=i.title
|
||||||
),
|
),
|
||||||
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)),
|
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -419,7 +419,7 @@ class SendMediaGroup:
|
||||||
performer=i.performer,
|
performer=i.performer,
|
||||||
title=i.title
|
title=i.title
|
||||||
),
|
),
|
||||||
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "audio.mp3")),
|
raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "audio.mp3")),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -445,7 +445,7 @@ class SendMediaGroup:
|
||||||
file=file,
|
file=file,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)),
|
raw.types.DocumentAttributeFilename(file_name=i.file_name or os.path.basename(i.media)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -490,7 +490,7 @@ class SendMediaGroup:
|
||||||
file=file,
|
file=file,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "file.zip")),
|
raw.types.DocumentAttributeFilename(file_name=i.file_name or getattr(i.media, "name", "file.zip")),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,10 @@ class RequestedChat(Object):
|
||||||
"raw.types.PeerChannel"
|
"raw.types.PeerChannel"
|
||||||
]
|
]
|
||||||
) -> "RequestedChat":
|
) -> "RequestedChat":
|
||||||
if isinstance(request, raw.types.RequestedPeerChannel) or isinstance(request, raw.types.PeerChannel):
|
if getattr(request, "broadcast", None):
|
||||||
type = enums.ChatType.CHANNEL
|
type = enums.ChatType.CHANNEL
|
||||||
|
elif getattr(request, "megagroup", None):
|
||||||
|
type = enums.ChatType.SUPERGROUP
|
||||||
else:
|
else:
|
||||||
type = enums.ChatType.GROUP
|
type = enums.ChatType.GROUP
|
||||||
photo = None
|
photo = None
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@ class InputMediaAudio(InputMedia):
|
||||||
|
|
||||||
title (``str``, *optional*):
|
title (``str``, *optional*):
|
||||||
Title of the audio
|
Title of the audio
|
||||||
|
|
||||||
|
file_name (``str``, *optional*):
|
||||||
|
File name of the audio sent.
|
||||||
|
Defaults to file's path basename.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -73,7 +77,8 @@ class InputMediaAudio(InputMedia):
|
||||||
caption_entities: List[MessageEntity] = None,
|
caption_entities: List[MessageEntity] = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
performer: str = "",
|
performer: str = "",
|
||||||
title: str = ""
|
title: str = "",
|
||||||
|
file_name: str = None
|
||||||
):
|
):
|
||||||
super().__init__(media, caption, parse_mode, caption_entities)
|
super().__init__(media, caption, parse_mode, caption_entities)
|
||||||
|
|
||||||
|
|
@ -81,3 +86,4 @@ class InputMediaAudio(InputMedia):
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.performer = performer
|
self.performer = performer
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.file_name = file_name
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@ class InputMediaDocument(InputMedia):
|
||||||
|
|
||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
||||||
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
|
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
|
||||||
|
|
||||||
|
file_name (``str``, *optional*):
|
||||||
|
File name of the document sent.
|
||||||
|
Defaults to file's path basename.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -59,8 +63,10 @@ class InputMediaDocument(InputMedia):
|
||||||
thumb: str = None,
|
thumb: str = None,
|
||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List[MessageEntity] = None
|
caption_entities: List[MessageEntity] = None,
|
||||||
|
file_name: str = None
|
||||||
):
|
):
|
||||||
super().__init__(media, caption, parse_mode, caption_entities)
|
super().__init__(media, caption, parse_mode, caption_entities)
|
||||||
|
|
||||||
self.thumb = thumb
|
self.thumb = thumb
|
||||||
|
self.file_name = file_name
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@ class InputMediaVideo(InputMedia):
|
||||||
duration (``int``, *optional*):
|
duration (``int``, *optional*):
|
||||||
Video duration.
|
Video duration.
|
||||||
|
|
||||||
|
file_name (``str``, *optional*):
|
||||||
|
File name of the video sent.
|
||||||
|
Defaults to file's path basename.
|
||||||
|
|
||||||
supports_streaming (``bool``, *optional*):
|
supports_streaming (``bool``, *optional*):
|
||||||
Pass True, if the uploaded video is suitable for streaming.
|
Pass True, if the uploaded video is suitable for streaming.
|
||||||
|
|
||||||
|
|
@ -79,6 +83,7 @@ class InputMediaVideo(InputMedia):
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
height: int = 0,
|
height: int = 0,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
|
file_name: str = None,
|
||||||
supports_streaming: bool = True,
|
supports_streaming: bool = True,
|
||||||
has_spoiler: bool = None,
|
has_spoiler: bool = None,
|
||||||
):
|
):
|
||||||
|
|
@ -88,5 +93,6 @@ class InputMediaVideo(InputMedia):
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
|
self.file_name = file_name
|
||||||
self.supports_streaming = supports_streaming
|
self.supports_streaming = supports_streaming
|
||||||
self.has_spoiler = has_spoiler
|
self.has_spoiler = has_spoiler
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,7 @@ class Message(Object, Update):
|
||||||
gift_code: "types.GiftCode" = None,
|
gift_code: "types.GiftCode" = None,
|
||||||
gift: "types.Gift" = None,
|
gift: "types.Gift" = None,
|
||||||
screenshot_taken: "types.ScreenshotTaken" = None,
|
screenshot_taken: "types.ScreenshotTaken" = None,
|
||||||
|
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
|
||||||
invoice: "types.Invoice" = None,
|
invoice: "types.Invoice" = None,
|
||||||
story: Union["types.MessageStory", "types.Story"] = None,
|
story: Union["types.MessageStory", "types.Story"] = None,
|
||||||
alternative_videos: List["types.AlternativeVideo"] = None,
|
alternative_videos: List["types.AlternativeVideo"] = None,
|
||||||
|
|
@ -596,6 +597,7 @@ class Message(Object, Update):
|
||||||
self.gift_code = gift_code
|
self.gift_code = gift_code
|
||||||
self.gift = gift
|
self.gift = gift
|
||||||
self.screenshot_taken = screenshot_taken
|
self.screenshot_taken = screenshot_taken
|
||||||
|
self.paid_message_price_changed = paid_message_price_changed
|
||||||
self.invoice = invoice
|
self.invoice = invoice
|
||||||
self.story = story
|
self.story = story
|
||||||
self.video = video
|
self.video = video
|
||||||
|
|
@ -760,6 +762,7 @@ class Message(Object, Update):
|
||||||
gift_code = None
|
gift_code = None
|
||||||
gift = None
|
gift = None
|
||||||
screenshot_taken = None
|
screenshot_taken = None
|
||||||
|
paid_message_price_changed = None
|
||||||
|
|
||||||
service_type = None
|
service_type = None
|
||||||
chat_join_type = None
|
chat_join_type = None
|
||||||
|
|
@ -881,6 +884,9 @@ class Message(Object, Update):
|
||||||
elif isinstance(action, raw.types.MessageActionScreenshotTaken):
|
elif isinstance(action, raw.types.MessageActionScreenshotTaken):
|
||||||
screenshot_taken = types.ScreenshotTaken()
|
screenshot_taken = types.ScreenshotTaken()
|
||||||
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
|
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
|
||||||
|
elif isinstance(action, raw.types.MessageActionPaidMessagesPrice):
|
||||||
|
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
|
||||||
|
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
|
||||||
|
|
||||||
parsed_message = Message(
|
parsed_message = Message(
|
||||||
id=message.id,
|
id=message.id,
|
||||||
|
|
@ -926,6 +932,7 @@ class Message(Object, Update):
|
||||||
contact_registered=contact_registered,
|
contact_registered=contact_registered,
|
||||||
gift_code=gift_code,
|
gift_code=gift_code,
|
||||||
screenshot_taken=screenshot_taken,
|
screenshot_taken=screenshot_taken,
|
||||||
|
paid_message_price_changed=paid_message_price_changed,
|
||||||
raw=message,
|
raw=message,
|
||||||
chat_join_type=chat_join_type,
|
chat_join_type=chat_join_type,
|
||||||
client=client
|
client=client
|
||||||
|
|
@ -970,7 +977,7 @@ class Message(Object, Update):
|
||||||
else:
|
else:
|
||||||
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
|
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
|
||||||
parsed_message.is_topic_message = True
|
parsed_message.is_topic_message = True
|
||||||
elif parsed_message.chat.is_forum and parsed_message.message_thread_id is None:
|
elif parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
|
||||||
parsed_message.message_thread_id = 1
|
parsed_message.message_thread_id = 1
|
||||||
parsed_message.is_topic_message = True
|
parsed_message.is_topic_message = True
|
||||||
|
|
||||||
|
|
@ -1299,7 +1306,7 @@ class Message(Object, Update):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
parsed_message.reply_to_story = reply_to_story
|
parsed_message.reply_to_story = reply_to_story
|
||||||
if parsed_message.chat.is_forum and parsed_message.message_thread_id is None:
|
if parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None:
|
||||||
parsed_message.message_thread_id = 1
|
parsed_message.message_thread_id = 1
|
||||||
parsed_message.is_topic_message = True
|
parsed_message.is_topic_message = True
|
||||||
|
|
||||||
|
|
@ -1314,8 +1321,13 @@ class Message(Object, Update):
|
||||||
self.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)
|
self.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)
|
||||||
and self.chat.username
|
and self.chat.username
|
||||||
):
|
):
|
||||||
|
if self.chat.type == enums.ChatType.SUPERGROUP and self.message_thread_id:
|
||||||
|
return f"https://t.me/{self.chat.username}/{self.message_thread_id}/{self.id}"
|
||||||
return f"https://t.me/{self.chat.username}/{self.id}"
|
return f"https://t.me/{self.chat.username}/{self.id}"
|
||||||
else:
|
if self.chat.type == enums.ChatType.PRIVATE:
|
||||||
|
return f"tg://openmessage?user_id={self.from_user.id}&message_id={self.id}"
|
||||||
|
if self.message_thread_id:
|
||||||
|
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.message_thread_id}/{self.id}"
|
||||||
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.id}"
|
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
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``):
|
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:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue