mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 16:45:19 +00:00
Refactor ForumTopic
This commit is contained in:
parent
8a39fe49e1
commit
8064b24143
@ -66,8 +66,13 @@ class Dispatcher:
|
||||
|
||||
async def message_parser(update, users, chats):
|
||||
return (
|
||||
await pyrogram.types.Message._parse(self.client, update.message, users, chats, None,
|
||||
isinstance(update, UpdateNewScheduledMessage)),
|
||||
await pyrogram.types.Message._parse(
|
||||
self.client,
|
||||
update.message,
|
||||
users,
|
||||
chats,
|
||||
is_scheduled=isinstance(update, UpdateNewScheduledMessage)
|
||||
),
|
||||
MessageHandler
|
||||
)
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SendGame:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
for supergroups only
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -60,7 +60,7 @@ class SendInlineBotResult:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
for supergroups only
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``bool``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -74,7 +74,7 @@ class CopyMediaGroup:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -87,7 +87,7 @@ class CopyMessage:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -54,7 +54,8 @@ class ForwardMessages:
|
||||
An iterable of message identifiers in the chat specified in *from_chat_id* or a single message id.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
disable_notification (``bool``, *optional*):
|
||||
Sends the message silently.
|
||||
|
@ -122,7 +122,7 @@ class SendAnimation:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -115,7 +115,7 @@ class SendAudio:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -84,7 +84,7 @@ class SendCachedMedia:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -78,7 +78,7 @@ class SendContact:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -69,7 +69,7 @@ class SendDice:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -107,7 +107,7 @@ class SendDocument:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -68,7 +68,7 @@ class SendLocation:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
|
@ -74,7 +74,7 @@ class SendMediaGroup:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -77,7 +77,7 @@ class SendMessage:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -98,7 +98,7 @@ class SendPhoto:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -121,7 +121,7 @@ class SendPoll:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -78,7 +78,7 @@ class SendSticker:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -85,7 +85,7 @@ class SendVenue:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
|
@ -128,7 +128,7 @@ class SendVideo:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
|
@ -92,7 +92,7 @@ class SendVideoNote:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
|
@ -93,7 +93,7 @@ class SendVoice:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
|
@ -58,7 +58,7 @@ class ForwardStory:
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||
Date when the message will be automatically sent.
|
||||
|
@ -17,10 +17,8 @@
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .input_message_content import InputMessageContent
|
||||
from .input_reply_to_message import InputReplyToMessage
|
||||
from .input_reply_to_story import InputReplyToStory
|
||||
from .input_text_message_content import InputTextMessageContent
|
||||
|
||||
__all__ = [
|
||||
"InputMessageContent", "InputReplyToMessage", "InputReplyToStory", "InputTextMessageContent"
|
||||
"InputMessageContent", "InputTextMessageContent"
|
||||
]
|
||||
|
@ -1,52 +0,0 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram 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.
|
||||
#
|
||||
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class InputReplyToMessage(Object):
|
||||
"""Contains information about a target replied message.
|
||||
|
||||
Parameters:
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
ID of the original message you want to reply.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
reply_to_message_id: int = None,
|
||||
message_thread_id: int = None
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.reply_to_message_id = reply_to_message_id
|
||||
self.message_thread_id = message_thread_id
|
||||
|
||||
def write(self):
|
||||
if not any((self.reply_to_message_id, self.message_thread_id)):
|
||||
return None
|
||||
|
||||
return raw.types.InputReplyToMessage(
|
||||
reply_to_msg_id=self.reply_to_message_id or message_thread_id, # type: ignore[arg-type]
|
||||
top_msg_id=self.message_thread_id if self.reply_to_message_id else None,
|
||||
).write()
|
@ -1,48 +0,0 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram 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.
|
||||
#
|
||||
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class InputReplyToStory(Object):
|
||||
"""Contains information about a target replied story.
|
||||
|
||||
Parameters:
|
||||
user_id (:obj:`~pyrogram.raw.types.InputUser`):
|
||||
An InputUser.
|
||||
|
||||
story_id (``int``):
|
||||
Unique identifier for the target story.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
user_id: "raw.types.InputUser" = None,
|
||||
story_id: int = None
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.user_id = user_id
|
||||
self.story_id = story_id
|
||||
|
||||
def write(self):
|
||||
return raw.types.InputReplyToStory(
|
||||
user_id=self.user_id,
|
||||
story_id=self.story_id
|
||||
).write()
|
@ -16,65 +16,49 @@
|
||||
# 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 pyrogram import raw, types
|
||||
from typing import Union
|
||||
from pyrogram import raw, utils
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class ForumTopic(Object):
|
||||
# todo
|
||||
# notify_settings: `~pyrogram.types.PeerNotifySettings`
|
||||
# draft: `~pyrogram.types.DraftMessage`
|
||||
"""A forum topic.
|
||||
|
||||
Parameters:
|
||||
id (``Integer``):
|
||||
Id of the topic
|
||||
id (``int``):
|
||||
Unique topic identifier inside this chat.
|
||||
|
||||
date (``Integer``):
|
||||
Date topic created
|
||||
date (``int``):
|
||||
Date when the topic was created.
|
||||
|
||||
title (``String``):
|
||||
Name of the topic
|
||||
title (``str``):
|
||||
The topic title.
|
||||
|
||||
icon_color (``Integer``):
|
||||
icon_color (``int``):
|
||||
Color of the topic icon in RGB format
|
||||
|
||||
top_message (``Integer``):
|
||||
N/A
|
||||
|
||||
read_inbox_max_id (``Integer``):
|
||||
N/A
|
||||
|
||||
read_outbox_max_id (``Integer``):
|
||||
N/A
|
||||
|
||||
unread_count (``Integer``):
|
||||
N/A
|
||||
|
||||
unread_mentions_count (``Integer``):
|
||||
N/A
|
||||
|
||||
unread_reactions_count (``Integer``):
|
||||
N/A
|
||||
|
||||
from_id (:obj:`~pyrogram.types.PeerChannel` | :obj:`~pyrogram.types.PeerUser`):
|
||||
Topic creator.
|
||||
|
||||
my (``Boolean``, *optional*):
|
||||
N/A
|
||||
|
||||
closed (``Boolean``, *optional*):
|
||||
N/A
|
||||
|
||||
pinned (``Boolean``, *optional*):
|
||||
N/A
|
||||
|
||||
short (``Boolean``, *optional*):
|
||||
N/A
|
||||
|
||||
icon_emoji_id (``Integer``, *optional*):
|
||||
icon_emoji_id (``int``, *optional*):
|
||||
Unique identifier of the custom emoji shown as the topic icon
|
||||
|
||||
top_message (``int``):
|
||||
The last message sent in the topic at this time.
|
||||
|
||||
unread_count (``int``):
|
||||
Amount of unread messages in this topic.
|
||||
|
||||
unread_mentions_count (``int``):
|
||||
Amount of unread messages containing a mention in this topic.
|
||||
|
||||
unread_reactions_count (``int``):
|
||||
Amount of unread messages containing a reaction in this topic.
|
||||
|
||||
is_my (``bool``, *optional*):
|
||||
True, if you are creator of topic.
|
||||
|
||||
is_closed (``bool``, *optional*):
|
||||
True, if the topic is closed.
|
||||
|
||||
is_pinned (``bool``, *optional*):
|
||||
True, if the topic is pinned.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@ -84,20 +68,14 @@ class ForumTopic(Object):
|
||||
date: int,
|
||||
title: str,
|
||||
icon_color: int,
|
||||
icon_emoji_id: int = None,
|
||||
top_message: int,
|
||||
read_inbox_max_id: int,
|
||||
read_outbox_max_id: int,
|
||||
unread_count: int,
|
||||
unread_mentions_count: int,
|
||||
unread_reactions_count: int,
|
||||
from_id: Union["types.PeerChannel", "types.PeerUser"],
|
||||
# notify_settings: "types.PeerNotifySettings", //todo
|
||||
my: bool = None,
|
||||
closed: bool = None,
|
||||
pinned: bool = None,
|
||||
short: bool = None,
|
||||
icon_emoji_id: int = None,
|
||||
# draft: "types.DraftMessage" = None //todo
|
||||
is_my: bool = None,
|
||||
is_closed: bool = None,
|
||||
is_pinned: bool = None,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
@ -105,46 +83,28 @@ class ForumTopic(Object):
|
||||
self.date = date
|
||||
self.title = title
|
||||
self.icon_color = icon_color
|
||||
self.icon_emoji_id = icon_emoji_id
|
||||
self.top_message = top_message
|
||||
self.read_inbox_max_id = read_inbox_max_id
|
||||
self.read_outbox_max_id = read_outbox_max_id
|
||||
self.unread_count = unread_count
|
||||
self.unread_mentions_count = unread_mentions_count
|
||||
self.unread_reactions_count = unread_reactions_count
|
||||
self.from_id = from_id
|
||||
# self.notify_settings = notify_settings //todo
|
||||
self.my = my
|
||||
self.closed = closed
|
||||
self.pinned = pinned
|
||||
self.short = short
|
||||
self.icon_emoji_id = icon_emoji_id
|
||||
# self.draft = draft //todo
|
||||
self.is_my = is_my
|
||||
self.is_closed = is_closed
|
||||
self.is_pinned = is_pinned
|
||||
|
||||
@staticmethod
|
||||
def _parse(forum_topic: "raw.types.forum_topic") -> "ForumTopic":
|
||||
from_id = forum_topic.from_id
|
||||
if isinstance(from_id, raw.types.PeerChannel):
|
||||
peer = types.PeerChannel._parse(from_id)
|
||||
if isinstance(from_id, raw.types.PeerUser):
|
||||
peer = types.PeerUser._parse(from_id)
|
||||
|
||||
def _parse(forum_topic: "raw.types.ForumTopic") -> "ForumTopic":
|
||||
return ForumTopic(
|
||||
id=getattr(forum_topic, "id", None),
|
||||
date=getattr(forum_topic, "date", None),
|
||||
title=getattr(forum_topic, "title", None),
|
||||
id=forum_topic.id,
|
||||
date=utils.timestamp_to_datetime(forum_topic.date),
|
||||
title=forum_topic.title,
|
||||
icon_color=getattr(forum_topic, "icon_color", None),
|
||||
icon_emoji_id=getattr(forum_topic, "icon_emoji_id", None),
|
||||
top_message=getattr(forum_topic, "top_message", None),
|
||||
read_inbox_max_id=getattr(forum_topic, "read_inbox_max_id", None),
|
||||
read_outbox_max_id=getattr(forum_topic, "read_outbox_max_id", None),
|
||||
unread_count=getattr(forum_topic, "unread_count", None),
|
||||
unread_mentions_count=getattr(forum_topic, "unread_mentions_count", None),
|
||||
unread_reactions_count=getattr(forum_topic, "unread_reactions_count", None),
|
||||
from_id=peer,
|
||||
# notify_settings=None, //todo
|
||||
my=getattr(forum_topic, "my", None),
|
||||
closed=getattr(forum_topic, "closed", None),
|
||||
pinned=getattr(forum_topic, "pinned", None),
|
||||
short=getattr(forum_topic, "short", None),
|
||||
icon_emoji_id=getattr(forum_topic, "icon_emoji_id", None),
|
||||
# draft=None //todo
|
||||
is_my=getattr(forum_topic, "my", None),
|
||||
is_closed=getattr(forum_topic, "closed", None),
|
||||
is_pinned=getattr(forum_topic, "pinned", None),
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ class Message(Object, Update):
|
||||
chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||
Conversation the message belongs to.
|
||||
|
||||
topics (:obj:`~pyrogram.types.ForumTopic`, *optional*):
|
||||
topic (:obj:`~pyrogram.types.ForumTopic`, *optional*):
|
||||
Topic the message belongs to.
|
||||
|
||||
forward_from (:obj:`~pyrogram.types.User`, *optional*):
|
||||
@ -99,12 +99,9 @@ class Message(Object, Update):
|
||||
forward_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||
For forwarded messages, date the original message was sent.
|
||||
|
||||
is_topic_message (``bool``, *optional*):
|
||||
True, if the message is sent to a forum topic
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
for supergroups only
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
The id of the message which this message directly replied to.
|
||||
@ -377,14 +374,13 @@ class Message(Object, Update):
|
||||
sender_chat: "types.Chat" = None,
|
||||
date: datetime = None,
|
||||
chat: "types.Chat" = None,
|
||||
topics: "types.ForumTopic" = None,
|
||||
topic: "types.ForumTopic" = None,
|
||||
forward_from: "types.User" = None,
|
||||
forward_sender_name: str = None,
|
||||
forward_from_chat: "types.Chat" = None,
|
||||
forward_from_message_id: int = None,
|
||||
forward_signature: str = None,
|
||||
forward_date: datetime = None,
|
||||
is_topic_message: bool = None,
|
||||
message_thread_id: int = None,
|
||||
reply_to_message_id: int = None,
|
||||
reply_to_story_id: int = None,
|
||||
@ -474,14 +470,13 @@ class Message(Object, Update):
|
||||
self.sender_chat = sender_chat
|
||||
self.date = date
|
||||
self.chat = chat
|
||||
self.topics = topics
|
||||
self.topic = topic
|
||||
self.forward_from = forward_from
|
||||
self.forward_sender_name = forward_sender_name
|
||||
self.forward_from_chat = forward_from_chat
|
||||
self.forward_from_message_id = forward_from_message_id
|
||||
self.forward_signature = forward_signature
|
||||
self.forward_date = forward_date
|
||||
self.is_topic_message = is_topic_message
|
||||
self.message_thread_id = message_thread_id
|
||||
self.reply_to_message_id = reply_to_message_id
|
||||
self.reply_to_story_id = reply_to_story_id
|
||||
@ -606,7 +601,6 @@ class Message(Object, Update):
|
||||
group_chat_created = None
|
||||
channel_chat_created = None
|
||||
new_chat_photo = None
|
||||
is_topic_message = None
|
||||
forum_topic_created = None
|
||||
forum_topic_closed = None
|
||||
forum_topic_reopened = None
|
||||
@ -708,7 +702,6 @@ class Message(Object, Update):
|
||||
message_thread_id=message_thread_id,
|
||||
date=utils.timestamp_to_datetime(message.date),
|
||||
chat=types.Chat._parse(client, message, users, chats, is_chat=True),
|
||||
topics=None,
|
||||
from_user=from_user,
|
||||
sender_chat=sender_chat,
|
||||
service=service_type,
|
||||
@ -722,7 +715,6 @@ class Message(Object, Update):
|
||||
migrate_from_chat_id=-migrate_from_chat_id if migrate_from_chat_id else None,
|
||||
group_chat_created=group_chat_created,
|
||||
channel_chat_created=channel_chat_created,
|
||||
is_topic_message=is_topic_message,
|
||||
forum_topic_created=forum_topic_created,
|
||||
forum_topic_closed=forum_topic_closed,
|
||||
forum_topic_reopened=forum_topic_reopened,
|
||||
@ -775,7 +767,6 @@ class Message(Object, Update):
|
||||
parsed_message.message_thread_id = message.reply_to.reply_to_top_id
|
||||
else:
|
||||
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
|
||||
parsed_message.is_topic_message = True
|
||||
|
||||
return parsed_message
|
||||
|
||||
@ -790,7 +781,6 @@ class Message(Object, Update):
|
||||
forward_from_message_id = None
|
||||
forward_signature = None
|
||||
forward_date = None
|
||||
is_topic_message = None
|
||||
|
||||
forward_header = message.fwd_from # type: raw.types.MessageFwdHeader
|
||||
|
||||
@ -936,7 +926,6 @@ class Message(Object, Update):
|
||||
message_thread_id=message_thread_id,
|
||||
date=utils.timestamp_to_datetime(message.date),
|
||||
chat=types.Chat._parse(client, message, users, chats, is_chat=True),
|
||||
topics=None,
|
||||
from_user=from_user,
|
||||
sender_chat=sender_chat,
|
||||
text=(
|
||||
@ -968,7 +957,6 @@ class Message(Object, Update):
|
||||
forward_from_message_id=forward_from_message_id,
|
||||
forward_signature=forward_signature,
|
||||
forward_date=forward_date,
|
||||
is_topic_message=is_topic_message,
|
||||
mentioned=message.mentioned,
|
||||
scheduled=is_scheduled,
|
||||
from_scheduled=message.from_scheduled,
|
||||
@ -1014,14 +1002,13 @@ class Message(Object, Update):
|
||||
else:
|
||||
thread_id = message.reply_to.reply_to_msg_id
|
||||
parsed_message.message_thread_id = thread_id
|
||||
parsed_message.is_topic_message = True
|
||||
if topics:
|
||||
parsed_message.topics = types.ForumTopic._parse(topics[thread_id])
|
||||
parsed_message.topic = types.ForumTopic._parse(topics[thread_id])
|
||||
else:
|
||||
try:
|
||||
msg = await client.get_messages(parsed_message.chat.id,message.id)
|
||||
if getattr(msg, "topics"):
|
||||
parsed_message.topics = msg.topics
|
||||
if msg.topic:
|
||||
parsed_message.topic = msg.topic
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
@ -1186,7 +1173,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -1327,7 +1315,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -1485,7 +1474,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -1619,7 +1609,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -1760,7 +1751,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -1892,7 +1884,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2017,7 +2010,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2096,7 +2090,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``bool``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2189,7 +2184,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
@ -2274,7 +2270,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2390,7 +2387,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2569,7 +2567,8 @@ class Message(Object, Update):
|
||||
Protects the contents of the sent message from forwarding and saving.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2683,7 +2682,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -2826,7 +2826,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
@ -2974,7 +2975,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message.
|
||||
@ -3118,7 +3120,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
@ -3261,7 +3264,8 @@ class Message(Object, Update):
|
||||
Users will receive a notification with no sound.
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_message_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original message
|
||||
@ -3555,7 +3559,8 @@ class Message(Object, Update):
|
||||
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
disable_notification (``bool``, *optional*):
|
||||
Sends the message silently.
|
||||
@ -3642,7 +3647,7 @@ class Message(Object, Update):
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier for the target message thread (topic) of the forum.
|
||||
for forum supergroups only.
|
||||
For supergroups only.
|
||||
|
||||
reply_to_chat_id (``int``, *optional*):
|
||||
If the message is a reply, ID of the original chat.
|
||||
|
@ -1669,7 +1669,8 @@ class Story(Object, Update):
|
||||
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||
|
||||
message_thread_id (``int``, *optional*):
|
||||
Unique identifier of a message thread to which the message belongs; for supergroups only
|
||||
Unique identifier of a message thread to which the message belongs.
|
||||
For supergroups only.
|
||||
|
||||
disable_notification (``bool``, *optional*):
|
||||
Sends the message silently.
|
||||
|
@ -35,8 +35,6 @@ from .emoji_status import EmojiStatus
|
||||
from .folder import Folder
|
||||
from .invite_link_importer import InviteLinkImporter
|
||||
from .restriction import Restriction
|
||||
from .peer_channel import PeerChannel
|
||||
from .peer_user import PeerUser
|
||||
from .user import User
|
||||
from .username import Username
|
||||
from .video_chat_ended import VideoChatEnded
|
||||
@ -51,8 +49,6 @@ __all__ = [
|
||||
"ChatPhoto",
|
||||
"ChatPreview",
|
||||
"Dialog",
|
||||
"PeerChannel",
|
||||
"PeerUser",
|
||||
"User",
|
||||
"Username",
|
||||
"Restriction",
|
||||
|
@ -37,7 +37,7 @@ class Chat(Object):
|
||||
Type of chat.
|
||||
|
||||
is_forum (``bool``, *optional*):
|
||||
True, if the supergroup chat is a forum
|
||||
True, if the supergroup chat is a forum.
|
||||
|
||||
is_verified (``bool``, *optional*):
|
||||
True, if this chat has been verified by Telegram. Supergroups, channels and bots only.
|
||||
|
@ -56,7 +56,7 @@ class ChatPermissions(Object):
|
||||
|
||||
can_manage_topics (``bool``, *optional*):
|
||||
True, if the user is allowed to create, rename, close, and reopen forum topics.
|
||||
supergroups only.
|
||||
Supergroups only.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
@ -63,7 +63,7 @@ class ChatPrivileges(Object):
|
||||
True, if the user is allowed to pin messages.
|
||||
|
||||
can_manage_topics (``bool``, *optional*):
|
||||
supergroups only.
|
||||
Supergroups only.
|
||||
True, if the user is allowed to create, rename, close, and reopen forum topics.
|
||||
|
||||
is_anonymous (``bool``, *optional*):
|
||||
|
@ -1,44 +0,0 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram 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.
|
||||
#
|
||||
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class PeerChannel(Object):
|
||||
"""A PeerChannel.
|
||||
|
||||
|
||||
Parameters:
|
||||
channel_id (``int``):
|
||||
Id of the channel.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
channel_id: int
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.channel_id = channel_id
|
||||
|
||||
@staticmethod
|
||||
def _parse(action: "raw.types.PeerChannel") -> "PeerChannel":
|
||||
return PeerChannel(
|
||||
channel_id=getattr(action, "channel_id", None)
|
||||
)
|
@ -1,44 +0,0 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram 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.
|
||||
#
|
||||
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram import raw
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class PeerUser(Object):
|
||||
"""A PeerUser.
|
||||
|
||||
|
||||
Parameters:
|
||||
user_id (``int``):
|
||||
Id of the user.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
user_id: int
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.user_id = user_id
|
||||
|
||||
@staticmethod
|
||||
def _parse(action: "raw.types.PeerUser") -> "PeerUser":
|
||||
return PeerUser(
|
||||
user_id=getattr(action, "user_id", None)
|
||||
)
|
Loading…
Reference in New Issue
Block a user