Add VoiceChatScheduled type and Message.voice_chat_scheduled field

This commit is contained in:
Dan 2021-04-26 16:56:10 +02:00
parent fa7673e51c
commit 89860a4b4c
4 changed files with 54 additions and 1 deletions

View File

@ -376,6 +376,7 @@ def pyrogram_api():
Poll
PollOption
Dice
VoiceChatScheduled
VoiceChatStarted
VoiceChatEnded
VoiceChatMembersInvited

View File

@ -264,6 +264,9 @@ class Message(Object, Update):
E.g.: "/start 1 2 3" would produce ["start", "1", "2", "3"].
Only applicable when using :obj:`~pyrogram.filters.command`.
voice_chat_scheduled (:obj:`~pyrogram.types.VoiceChatScheduled`, *optional*):
Service message: voice chat scheduled.
voice_chat_started (:obj:`~pyrogram.types.VoiceChatStarted`, *optional*):
Service message: the voice chat started.
@ -344,6 +347,7 @@ class Message(Object, Update):
outgoing: bool = None,
matches: List[Match] = None,
command: List[str] = None,
voice_chat_scheduled: "types.VoiceChatScheduled" = None,
voice_chat_started: "types.VoiceChatStarted" = None,
voice_chat_ended: "types.VoiceChatEnded" = None,
voice_chat_members_invited: "types.VoiceChatMembersInvited" = None,
@ -414,6 +418,7 @@ class Message(Object, Update):
self.matches = matches
self.command = command
self.reply_markup = reply_markup
self.voice_chat_scheduled = voice_chat_scheduled
self.voice_chat_started = voice_chat_started
self.voice_chat_ended = voice_chat_ended
self.voice_chat_members_invited = voice_chat_members_invited
@ -442,6 +447,7 @@ class Message(Object, Update):
group_chat_created = None
channel_chat_created = None
new_chat_photo = None
voice_chat_scheduled = None
voice_chat_started = None
voice_chat_ended = None
voice_chat_members_invited = None
@ -466,6 +472,8 @@ class Message(Object, Update):
channel_chat_created = True
elif isinstance(action, raw.types.MessageActionChatEditPhoto):
new_chat_photo = types.Photo._parse(client, action.photo)
elif isinstance(action, raw.types.MessageActionGroupCallScheduled):
voice_chat_scheduled = types.VoiceChatScheduled._parse(action)
elif isinstance(action, raw.types.MessageActionGroupCall):
if action.duration:
voice_chat_ended = types.VoiceChatEnded._parse(action)
@ -495,6 +503,7 @@ class Message(Object, Update):
group_chat_created=group_chat_created,
channel_chat_created=channel_chat_created,
client=client,
voice_chat_scheduled=voice_chat_scheduled,
voice_chat_started=voice_chat_started,
voice_chat_ended=voice_chat_ended,
voice_chat_members_invited=voice_chat_members_invited

View File

@ -32,6 +32,7 @@ from .restriction import Restriction
from .user import User
from .voice_chat_ended import VoiceChatEnded
from .voice_chat_members_invited import VoiceChatMembersInvited
from .voice_chat_scheduled import VoiceChatScheduled
from .voice_chat_started import VoiceChatStarted
__all__ = [
@ -51,5 +52,6 @@ __all__ = [
"VoiceChatStarted",
"VoiceChatEnded",
"VoiceChatMembersInvited",
"ChatMemberUpdated"
"ChatMemberUpdated",
"VoiceChatScheduled"
]

View File

@ -0,0 +1,41 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2021 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 VoiceChatScheduled(Object):
"""A service message about a voice chat scheduled in the chat.
Parameters:
start_date (``int``):
Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator.
"""
def __init__(
self, *,
start_date: int
):
super().__init__()
self.start_date = start_date
@staticmethod
def _parse(action: "raw.types.MessageActionGroupCallScheduled") -> "VoiceChatScheduled":
return VoiceChatScheduled(start_date=action.schedule_date)