Reworked request builder (#1142)

* Reworked request builder

* Added more default values

* Update tests

* Fixed timestamp

* Fixed Py3.8 support

* Describe changes
This commit is contained in:
Alex Root Junior 2023-03-11 20:46:36 +02:00 committed by GitHub
parent 924a83966d
commit fea1b7b0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
300 changed files with 1003 additions and 3448 deletions

View file

@ -1,6 +1,6 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
from typing import TYPE_CHECKING, Optional, Union
from ..types import (
ForceReply,
@ -9,10 +9,8 @@ from ..types import (
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
)
from .base import Request, TelegramMethod
if TYPE_CHECKING:
from ..client.bot import Bot
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
class SendDice(TelegramMethod[Message]):
@ -23,6 +21,7 @@ class SendDice(TelegramMethod[Message]):
"""
__returning__ = Message
__api_method__ = "sendDice"
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
@ -32,7 +31,7 @@ class SendDice(TelegramMethod[Message]):
"""Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None
protect_content: Optional[bool] = UNSET_PROTECT_CONTENT
"""Protects the contents of the sent message from forwarding"""
reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message"""
@ -42,8 +41,3 @@ class SendDice(TelegramMethod[Message]):
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None
"""Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_, `custom reply keyboard <https://core.telegram.org/bots/features#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user."""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="sendDice", data=data)