예제 #1
0
def generate_page(current_image, peer_id, photos):
    buttons = [[], []]  # 2 rows
    # first button row
    if current_image > 0:
        buttons[0].append(
            InlineKeyboardButton(
                "<<",
                callback_data="{peer_id};{next_pos};False".format(
                    peer_id=peer_id, next_pos=current_image - 1)))
    # end if
    if current_image < len(photos) - 1:
        buttons[0].append(
            InlineKeyboardButton(
                ">>",
                callback_data="{peer_id};{next_pos};False".format(
                    peer_id=peer_id, next_pos=current_image + 1)))
    # end if
    # second button row
    buttons[1].append(
        InlineKeyboardButton("send",
                             callback_data="{peer_id};{curr_pos};True".format(
                                 peer_id=peer_id, curr_pos=current_image)))
    markup = InlineKeyboardMarkup(buttons)
    result_image = photo_cache[peer_id][current_image]
    return result_image, markup
예제 #2
0
    def from_array(array):
        """
        Deserialize a new InlineKeyboardButton from a given dictionary.

        :return: new InlineKeyboardButton instance.
        :rtype: InlineKeyboardButton
        """
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.receivable.updates import CallbackGame
        

        data = {}
        data['text'] = u(array.get('text'))
        data['url'] = u(array.get('url')) if array.get('url') is not None else None
        data['callback_data'] = u(array.get('callback_data')) if array.get('callback_data') is not None else None
        data['switch_inline_query'] = u(array.get('switch_inline_query')) if array.get('switch_inline_query') is not None else None
        data['switch_inline_query_current_chat'] = u(array.get('switch_inline_query_current_chat')) if array.get('switch_inline_query_current_chat') is not None else None
        data['callback_game'] = CallbackGame.from_array(array.get('callback_game')) if array.get('callback_game') is not None else None
        data['pay'] = bool(array.get('pay')) if array.get('pay') is not None else None
        
        instance = InlineKeyboardButton(**data)
        instance._raw = array
        return instance
예제 #3
0
    def from_array(array):
        """
        Deserializes a new InlineKeyboardMarkup from a given dictionary.

        :return: new InlineKeyboardMarkup instance.
        :rtype: InlineKeyboardMarkup
        """
        if array is None or not array:
            return None
        # end if
        assert(isinstance(array, dict))
        
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardButton
        
        data = {}
        data['inline_keyboard'] = InlineKeyboardButton.from_array_list(array.get('inline_keyboard'), list_level=2)
        return InlineKeyboardMarkup(**data)
예제 #4
0
    def from_array(array):
        """
        Deserialize a new InlineKeyboardMarkup from a given dictionary.

        :return: new InlineKeyboardMarkup instance.
        :rtype: InlineKeyboardMarkup
        """
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardButton
        

        data = {}
        data['inline_keyboard'] = InlineKeyboardButton.from_array_list(array.get('inline_keyboard'), list_level=2)
        
        instance = InlineKeyboardMarkup(**data)
        instance._raw = array
        return instance
예제 #5
0
    def from_array(array):
        """
        Deserializes a new InlineKeyboardButton from a given dictionary.

        :return: new InlineKeyboardButton instance.
        :rtype: InlineKeyboardButton
        """
        if array is None or not array:
            return None
        # end if
        assert(isinstance(array, dict))
        
        from pytgbot.api_types.receivable.updates import CallbackGame
        
        data = {}
        data['text'] = str(array.get('text'))
        data['url'] = str(array.get('url')) if array.get('url') is not None else None
        data['callback_data'] = str(array.get('callback_data')) if array.get('callback_data') is not None else None
        data['switch_inline_query'] = str(array.get('switch_inline_query')) if array.get('switch_inline_query') is not None else None
        data['switch_inline_query_current_chat'] = str(array.get('switch_inline_query_current_chat')) if array.get('switch_inline_query_current_chat') is not None else None
        data['callback_game'] = CallbackGame.from_array(array.get('callback_game')) if array.get('callback_game') is not None else None
        return InlineKeyboardButton(**data)
def feat_game(update: Update, text):
    chat_id = update.message.chat.id
    game_msg = bot.bot.send_game(chat_id, "test00", reply_markup=InlineKeyboardMarkup([
        [InlineKeyboardButton(text="test me", callback_game=CallbackGame())],
    ]))
    return format_api_result(game_msg)