From fb0d03ac513f61c508d1799dd7e667aa2c8e8f48 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 27 Mar 2017 12:48:41 +0200 Subject: [PATCH] Added set_chat_action --- telegram.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/telegram.py b/telegram.py index 9b4e39a1..930b0088 100644 --- a/telegram.py +++ b/telegram.py @@ -234,6 +234,28 @@ class Chat: await bot.api_request("sendMessage", text=text, chat_id=self.chat_id, **params) + async def set_chat_action(self, bot, action): + """Set a status for the chat. + +Valid actions are: +typing +upload_photo +record_video +upload_video +record_audio +upload_audio +upload_document +find_location""" + # TODO: This could give problems if a class inherits Bot + if not isinstance(bot, Bot): + raise TypeError("bot is not an instance of Bot.") + # Check if the action is valid + if action not in ["typing", "upload_photo", "record_video", "upload_video", "record_audio", "upload_audio", "upload_document", "find_location"]: + raise ValueError("Invalid action") + # Send the request + await bot.api_request("sendChatAction", chat_id=self.chat_id, action=action) + + class User: def __init__(self, user_dict): self.user_id = user_dict["id"]