示例#1
0
def do_keyboard(chat_id):
    buttons = [
        ["YES", "NO"],
        ["Maybe", "lol"],
        [
            KeyboardButton("Contact?", request_contact=True),
            KeyboardButton("Location?", request_location=True)
        ],
    ]
    markup = ReplyKeyboardMarkup(buttons,
                                 resize_keyboard=True,
                                 one_time_keyboard=True)
    print(bot.send_msg(chat_id, "test!", reply_markup=markup))
示例#2
0
    def from_array(array):
        """
        Deserialize a new KeyboardButton from a given dictionary.

        :return: new KeyboardButton instance.
        :rtype: KeyboardButton
        """
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        data = {}
        data['text'] = u(array.get('text'))
        data['request_contact'] = bool(array.get('request_contact')) if array.get('request_contact') is not None else None
        data['request_location'] = bool(array.get('request_location')) if array.get('request_location') is not None else None
        
        instance = KeyboardButton(**data)
        instance._raw = array
        return instance
示例#3
0
def cmd_do(update, text):
    options = [[KeyboardButton(txt) for txt in features.keys()]]
    return HTMLMessage(
        Lang.here_are_some_options,
        reply_markup=ReplyKeyboardMarkup(
            options,
            resize_keyboard=True,
            one_time_keyboard=True,
            selective=True
        ),
    )
示例#4
0
    def from_array(array):
        """
        Deserializes a new KeyboardButton from a given dictionary.

        :return: new KeyboardButton instance.
        :rtype: KeyboardButton
        """
        if array is None or not array:
            return None
        # end if
        assert(isinstance(array, dict))
        
        data = {}
        data['text'] = str(array.get('text'))
        data['request_contact'] = bool(array.get('request_contact')) if array.get('request_contact') is not None else None
        data['request_location'] = bool(array.get('request_location')) if array.get('request_location') is not None else None
        return KeyboardButton(**data)
示例#5
0
    def from_array(array):
        """
        Deserializes a new ReplyKeyboardMarkup from a given dictionary.

        :return: new ReplyKeyboardMarkup instance.
        :rtype: ReplyKeyboardMarkup
        """
        if array is None or not array:
            return None
        # end if
        assert(isinstance(array, dict))
        
        from pytgbot.api_types.sendable.reply_markup import KeyboardButton
        
        data = {}
        data['keyboard'] = KeyboardButton.from_array_list(array.get('keyboard'), list_level=2)
        data['resize_keyboard'] = bool(array.get('resize_keyboard')) if array.get('resize_keyboard') is not None else None
        data['one_time_keyboard'] = bool(array.get('one_time_keyboard')) if array.get('one_time_keyboard') is not None else None
        data['selective'] = bool(array.get('selective')) if array.get('selective') is not None else None
        return ReplyKeyboardMarkup(**data)