From 89860a4b4cad2b4fc921d133d210f267fd358059 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 26 Apr 2021 16:56:10 +0200 Subject: [PATCH] Add VoiceChatScheduled type and Message.voice_chat_scheduled field --- compiler/docs/compiler.py | 1 + pyrogram/types/messages_and_media/message.py | 9 ++++ pyrogram/types/user_and_chats/__init__.py | 4 +- .../user_and_chats/voice_chat_scheduled.py | 41 +++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 pyrogram/types/user_and_chats/voice_chat_scheduled.py diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 8ee22fff..1d4ba9e4 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -376,6 +376,7 @@ def pyrogram_api(): Poll PollOption Dice + VoiceChatScheduled VoiceChatStarted VoiceChatEnded VoiceChatMembersInvited diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index e96a1d10..279ac3ea 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -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 diff --git a/pyrogram/types/user_and_chats/__init__.py b/pyrogram/types/user_and_chats/__init__.py index f3022e37..39e5d786 100644 --- a/pyrogram/types/user_and_chats/__init__.py +++ b/pyrogram/types/user_and_chats/__init__.py @@ -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" ] diff --git a/pyrogram/types/user_and_chats/voice_chat_scheduled.py b/pyrogram/types/user_and_chats/voice_chat_scheduled.py new file mode 100644 index 00000000..fc7a5f1e --- /dev/null +++ b/pyrogram/types/user_and_chats/voice_chat_scheduled.py @@ -0,0 +1,41 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2021 Dan +# +# 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 . + +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)