mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add RequestedChats type
This commit is contained in:
parent
ede750ffa3
commit
4ccc71685a
@ -43,6 +43,7 @@ from .request_channel_info import RequestChannelInfo
|
||||
from .request_chat_info import RequestChatInfo
|
||||
from .request_user_info import RequestUserInfo
|
||||
from .request_poll_info import RequestPollInfo
|
||||
from .requested_chats import RequestedChats
|
||||
from .sent_web_app_message import SentWebAppMessage
|
||||
from .web_app_info import WebAppInfo
|
||||
|
||||
@ -60,6 +61,7 @@ __all__ = [
|
||||
"RequestChatInfo",
|
||||
"RequestUserInfo",
|
||||
"RequestPollInfo",
|
||||
"RequestedChats",
|
||||
"LoginUrl",
|
||||
"BotCommand",
|
||||
"BotCommandScope",
|
||||
|
75
pyrogram/types/bots_and_keyboards/requested_chats.py
Normal file
75
pyrogram/types/bots_and_keyboards/requested_chats.py
Normal file
@ -0,0 +1,75 @@
|
||||
# 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/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import enums
|
||||
from pyrogram import raw, utils, types
|
||||
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class RequestedChats(Object):
|
||||
"""Contains information about requested chats.
|
||||
|
||||
Parameters:
|
||||
button_id (``int``):
|
||||
Identifier of button.
|
||||
|
||||
chats (List of :obj:`~pyrogram.types.Chat`):
|
||||
List of requested chats.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
client: "pyrogram.Client" = None,
|
||||
button_id: int,
|
||||
chats: bool,
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
self.button_id = button_id
|
||||
self.chats = chats
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, action: "raw.types.MessageActionRequestedPeer") -> "RequestedChats":
|
||||
_requested_chats = []
|
||||
|
||||
for requested_peer in action.peers:
|
||||
chat_id = utils.get_peer_id(requested_peer)
|
||||
peer_type = utils.get_peer_type(chat_id)
|
||||
|
||||
if peer_type == "user":
|
||||
chat_type = enums.ChatType.PRIVATE
|
||||
elif peer_type == "chat":
|
||||
chat_type = enums.ChatType.GROUP
|
||||
else:
|
||||
chat_type = enums.ChatType.CHANNEL
|
||||
|
||||
_requested_chats.append(
|
||||
types.Chat(
|
||||
id=chat_id,
|
||||
type=chat_type,
|
||||
client=client
|
||||
)
|
||||
)
|
||||
|
||||
return RequestedChats(
|
||||
button_id=action.button_id,
|
||||
chats=types.List(_requested_chats),
|
||||
client=client
|
||||
)
|
@ -357,7 +357,7 @@ class Message(Object, Update):
|
||||
gift_code (:obj:`~pyrogram.types.GiftCode`, *optional*):
|
||||
Service message: gift code information.
|
||||
|
||||
requested_chats (List of :obj:`~pyrogram.types.Chat`, *optional*):
|
||||
requested_chats (:obj:`~pyrogram.types.RequestedChats`, *optional*):
|
||||
Service message: requested chats information.
|
||||
|
||||
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
|
||||
@ -464,7 +464,7 @@ class Message(Object, Update):
|
||||
video_chat_members_invited: "types.VideoChatMembersInvited" = None,
|
||||
web_app_data: "types.WebAppData" = None,
|
||||
gift_code: "types.GiftCode" = None,
|
||||
requested_chats: List["types.Chat"] = None,
|
||||
requested_chats: "types.RequestedChats" = None,
|
||||
giveaway_launched: bool = None,
|
||||
chat_ttl_period: int = None,
|
||||
reply_markup: Union[
|
||||
@ -711,29 +711,7 @@ class Message(Object, Update):
|
||||
gift_code = types.GiftCode._parse(client, action, chats)
|
||||
service_type = enums.MessageServiceType.GIFT_CODE
|
||||
elif isinstance(action, raw.types.MessageActionRequestedPeer):
|
||||
_requested_chats = []
|
||||
|
||||
for requested_peer in action.peers:
|
||||
chat_id = utils.get_peer_id(requested_peer)
|
||||
peer_type = utils.get_peer_type(chat_id)
|
||||
|
||||
if peer_type == "user":
|
||||
chat_type = enums.ChatType.PRIVATE
|
||||
elif peer_type == "chat":
|
||||
chat_type = enums.ChatType.GROUP
|
||||
else:
|
||||
chat_type = enums.ChatType.CHANNEL
|
||||
|
||||
_requested_chats.append(
|
||||
types.Chat(
|
||||
id=chat_id,
|
||||
type=chat_type,
|
||||
client=client
|
||||
)
|
||||
)
|
||||
|
||||
requested_chats = types.List(_requested_chats) or None
|
||||
|
||||
requested_chats = types.RequestedChats._parse(client, action)
|
||||
service_type = enums.MessageServiceType.REQUESTED_CHAT
|
||||
elif isinstance(action, raw.types.MessageActionSetMessagesTTL):
|
||||
chat_ttl_period = action.period
|
||||
|
Loading…
Reference in New Issue
Block a user