How to use the aiogram.dispatcher.webhook.BaseResponse function in aiogram

To help you get started, we’ve selected a few aiogram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
__slots__ = ("sticker",)

    method = api.Methods.DELETE_STICKER_FROM_SET

    def __init__(self, sticker: String):
        """
        :param sticker: String - File identifier of the sticker
        """
        self.sticker = sticker

    def prepare(self):
        return {"sticker": self.sticker}


class AnswerInlineQuery(BaseResponse):
    """
    Use that response type for answer inline query on to webhook.
    """

    __slots__ = (
        "inline_query_id",
        "results",
        "cache_time",
        "is_personal",
        "next_offset",
        "switch_pm_text",
        "switch_pm_parameter",
    )

    method = api.Methods.ANSWER_INLINE_QUERY
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
__slots__ = ("chat_id",)

    method = api.Methods.UNPIN_CHAT_MESSAGE

    def __init__(self, chat_id: Union[Integer, String]):
        """
        :param chat_id: Union[Integer, String] - Unique identifier for the target chat or
            username of the target supergroup (in the format @supergroupusername)
        """
        self.chat_id = chat_id

    def prepare(self):
        return {"chat_id": self.chat_id}


class LeaveChat(BaseResponse):
    """
    Use that response type for leave chat on to webhook.
    """

    __slots__ = ("chat_id",)

    method = api.Methods.LEAVE_CHAT

    def __init__(self, chat_id: Union[Integer, String]):
        """
        :param chat_id: Union[Integer, String] - Unique identifier for the target chat
            or username of the target supergroup or channel (in the format @channelusername)
        """
        self.chat_id = chat_id

    def prepare(self):
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
def prepare(self):
        return {
            "chat_id": self.chat_id,
            "video": self.video,
            "duration": self.duration,
            "width": self.width,
            "height": self.height,
            "caption": self.caption,
            "disable_notification": self.disable_notification,
            "reply_to_message_id": self.reply_to_message_id,
            "reply_markup": prepare_arg(self.reply_markup),
        }


class SendVoice(BaseResponse, ReplyToMixin, DisableNotificationMixin):
    """
    Use that response type for send voice on to webhook.
    """

    __slots__ = (
        "chat_id",
        "voice",
        "caption",
        "duration",
        "disable_notification",
        "reply_to_message_id",
        "reply_markup",
    )

    method = api.Methods.SEND_VOICE
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
self.message_id = message_id
        self.inline_message_id = inline_message_id
        self.caption = caption
        self.reply_markup = reply_markup

    def prepare(self):
        return {
            "chat_id": self.chat_id,
            "message_id": self.message_id,
            "inline_message_id": self.inline_message_id,
            "caption": self.caption,
            "reply_markup": prepare_arg(self.reply_markup),
        }


class EditMessageReplyMarkup(BaseResponse):
    """
    Use that response type for edit message reply markup on to webhook.
    """

    __slots__ = ("chat_id", "message_id", "inline_message_id", "reply_markup")

    method = api.Methods.EDIT_MESSAGE_REPLY_MARKUP

    def __init__(
        self,
        chat_id: Optional[Union[Integer, String]] = None,
        message_id: Optional[Integer] = None,
        inline_message_id: Optional[String] = None,
        reply_markup: Optional[types.InlineKeyboardMarkup] = None,
    ):
        """
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
filling out your payment details. Please choose a different color or garment!").
            Telegram will display this message to the user.
        """
        self.pre_checkout_query_id = pre_checkout_query_id
        self.ok = ok
        self.error_message = error_message

    def prepare(self):
        return {
            "pre_checkout_query_id": self.pre_checkout_query_id,
            "ok": self.ok,
            "error_message": self.error_message,
        }


class SendGame(BaseResponse, ReplyToMixin, DisableNotificationMixin):
    """
    Use that response type for send game on to webhook.
    """

    __slots__ = (
        "chat_id",
        "game_short_name",
        "disable_notification",
        "reply_to_message_id",
        "reply_markup",
    )

    method = api.Methods.SEND_GAME

    def __init__(
        self,
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
def prepare(self):
        return {
            "chat_id": self.chat_id,
            "user_id": self.user_id,
            "can_change_info": self.can_change_info,
            "can_post_messages": self.can_post_messages,
            "can_edit_messages": self.can_edit_messages,
            "can_delete_messages": self.can_delete_messages,
            "can_invite_users": self.can_invite_users,
            "can_restrict_members": self.can_restrict_members,
            "can_pin_messages": self.can_pin_messages,
            "can_promote_members": self.can_promote_members,
        }


class DeleteChatPhoto(BaseResponse):
    """
    Use that response type for delete chat photo on to webhook.
    """

    __slots__ = ("chat_id",)

    method = api.Methods.DELETE_CHAT_PHOTO

    def __init__(self, chat_id: Union[Integer, String]):
        """
        :param chat_id: Union[Integer, String] - Unique identifier for the target chat
            or username of the target channel (in the format @channelusername)
        """
        self.chat_id = chat_id

    def prepare(self):
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
method = api.Methods.SET_CHAT_TITLE

    def __init__(self, chat_id: Union[Integer, String], title: String):
        """
        :param chat_id: Union[Integer, String] - Unique identifier for the target chat or username
            of the target channel (in the format @channelusername)
        :param title: String - New chat title, 1-255 characters
        """
        self.chat_id = chat_id
        self.title = title

    def prepare(self):
        return {"chat_id": self.chat_id, "title": self.title}


class SetChatDescription(BaseResponse):
    """
    Use that response type for set chat description on to webhook.
    """

    __slots__ = ("chat_id", "description")

    method = api.Methods.SET_CHAT_DESCRIPTION

    def __init__(self, chat_id: Union[Integer, String], description: String):
        """
        :param chat_id: Union[Integer, String] - Unique identifier for the target chat
            or username of the target channel (in the format @channelusername)
        :param description: String - New chat description, 0-255 characters
        """
        self.chat_id = chat_id
        self.description = description
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
def write_ln(self, *text, sep=" "):
        """
        Write line

        :param text:
        :param sep:
        :return:
        """
        if self.text and self.text[-1] != "\n":
            self.text += "\n"
        self.text += markdown.text(*text, sep) + "\n"
        return self


class ForwardMessage(BaseResponse, ReplyToMixin, DisableNotificationMixin):
    """
    Use that response type for forward messages of any kind on to webhook.
    """

    __slots__ = ("chat_id", "from_chat_id", "message_id", "disable_notification")

    method = api.Methods.FORWARD_MESSAGE

    def __init__(
        self,
        chat_id: Union[Integer, String] = None,
        from_chat_id: Union[Integer, String] = None,
        message_id: Integer = None,
        disable_notification: Optional[Boolean] = None,
    ):
        """
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
self.name = name
        self.png_sticker = png_sticker
        self.emojis = emojis
        self.mask_position = mask_position

    def prepare(self):
        return {
            "user_id": self.user_id,
            "name": self.name,
            "png_sticker": self.png_sticker,
            "emojis": self.emojis,
            "mask_position": prepare_arg(self.mask_position),
        }


class SetStickerPositionInSet(BaseResponse):
    """
    Use that response type for set sticker position in set on to webhook.
    """

    __slots__ = ("sticker", "position")

    method = api.Methods.SET_STICKER_POSITION_IN_SET

    def __init__(self, sticker: String, position: Integer):
        """
        :param sticker: String - File identifier of the sticker
        :param position: Integer - New sticker position in the set, zero-based
        """
        self.sticker = sticker
        self.position = position
github aiogram / aiogram / aiogram / dispatcher / webhook.py View on Github external
method = api.Methods.SET_STICKER_POSITION_IN_SET

    def __init__(self, sticker: String, position: Integer):
        """
        :param sticker: String - File identifier of the sticker
        :param position: Integer - New sticker position in the set, zero-based
        """
        self.sticker = sticker
        self.position = position

    def prepare(self):
        return {"sticker": self.sticker, "position": self.position}


class DeleteStickerFromSet(BaseResponse):
    """
    Use that response type for delete sticker from set on to webhook.
    """

    __slots__ = ("sticker",)

    method = api.Methods.DELETE_STICKER_FROM_SET

    def __init__(self, sticker: String):
        """
        :param sticker: String - File identifier of the sticker
        """
        self.sticker = sticker

    def prepare(self):
        return {"sticker": self.sticker}