from ...tl.mtproto_request import MTProtoRequest


class InputBotInlineMessageGame(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x4b425864
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0x53fb4010

    def __init__(self, reply_markup=None):
        """
        :param reply_markup: Telegram type: "ReplyMarkup".

        Constructor for InputBotInlineMessage: Instance of either InputBotInlineMessageMediaAuto, InputBotInlineMessageText, InputBotInlineMessageMediaGeo, InputBotInlineMessageMediaVenue, InputBotInlineMessageMediaContact, InputBotInlineMessageGame.
        """
        super().__init__()

        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            'reply_markup': None if self.reply_markup is None else self.reply_markup.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(InputBotInlineMessageGame.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 2) if self.reply_markup else 0
        writer.write_int(flags)

        if self.reply_markup:
            self.reply_markup.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return InputBotInlineMessageGame(None)

    def on_response(self, reader):
        flags = reader.read_int()

        if (flags & (1 << 2)) != 0:
            self.reply_markup = reader.tgread_object()

    def __repr__(self):
        return 'inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage'

    def __str__(self):
        return '(inputBotInlineMessageGame (ID: 0x4b425864) = (reply_markup={}))'.format(str(self.reply_markup))
