Python telegram.InlineKeyboardButton() Examples

The following are 30 code examples of telegram.InlineKeyboardButton(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module telegram , or try the search function .
Example #1
Source File: ranklist.py    From superCodingBot with MIT License 9 votes vote down vote up
def polo(self, bot, update, user_data):
        msg = update.message.text.upper()
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT name FROM handles WHERE name=(?)", (msg,))
        if c.fetchone():
            keyboard = [[InlineKeyboardButton("Hackerearth", callback_data='HElist8'),
                         InlineKeyboardButton("Hackerrank", callback_data='HRlist8')],
                        [InlineKeyboardButton("Codechef", callback_data='CClist8'),
                         InlineKeyboardButton("Spoj", callback_data='SPlist8')],
                        [InlineKeyboardButton("Codeforces", callback_data='CFlist8'),
                         InlineKeyboardButton("ALL", callback_data='ALLlist8')]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text('please select the judge or select all for showing all',
                                      reply_markup=reply_markup)
            user_data['name1'] = msg
            conn.close()
            return XOLO
        else:
            conn.close()
            update.message.reply_text("Sorry this name is not registered with me.")
            return ConversationHandler.END

    # FUNCTION TO SHOW THE KIND OF RANKLIST USER WANTS 
Example #2
Source File: botproperties.py    From BotListBot with MIT License 8 votes vote down vote up
def set_country_menu(bot, update, to_edit):
    uid = util.uid_from_update(update)
    countries = Country.select().order_by(Country.name).execute()

    buttons = util.build_menu(
        [InlineKeyboardButton(
            '{} {}'.format(c.emojized, c.name),
            callback_data=util.callback_for_action(
                CallbackActions.SET_COUNTRY, {'cid': c.id, 'bid': to_edit.id})) for c in countries
        ], 3)
    buttons.insert(0, [
        InlineKeyboardButton(captions.BACK,
                             callback_data=util.callback_for_action(CallbackActions.EDIT_BOT,
                                                                    {'id': to_edit.id})),
        InlineKeyboardButton("None",
                             callback_data=util.callback_for_action(CallbackActions.SET_COUNTRY,
                                                                    {
                                                                        'cid': 'None',
                                                                        'bid': to_edit.id
                                                                    })),
    ])
    return bot.formatter.send_or_edit(uid, util.action_hint(
        "Please select a country/language for {}".format(to_edit)),
                                      to_edit=util.mid_from_update(update),
                                      reply_markup=InlineKeyboardMarkup(buttons)) 
Example #3
Source File: contest_utility.py    From superCodingBot with MIT License 7 votes vote down vote up
def upcoming_sender(self, update, contest_list):
        i = 0
        s = ""
        keyboard = []
        keyboard1 = []
        for er in contest_list:
            i = i + 1
            # LIMITING NO OF EVENTS TO 20
            if i == 16:
                break
            parsed_contest = self.contest_parser(er)
            s = s + str(i) + ". " + parsed_contest["title"] + "\n" + "Start:\n" + \
                parsed_contest["start"].replace("T", " ")\
                + " GMT\n" + str(parsed_contest["start1"]).replace("T", " ") + " IST\n" + \
                "Duration: " + str(parsed_contest["duration"]) + "\n" + \
                parsed_contest["host"] + "\n" + parsed_contest["contest"] + "\n\n"
            keyboard1.append(InlineKeyboardButton(str(i), callback_data=str(i)))
            if i % 5 == 0:
                keyboard.append(keyboard1)
                keyboard1 = []
        keyboard.append(keyboard1)
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text(s + "Select competition number to get notification" + "\n\n",
                                  reply_markup=reply_markup) 
Example #4
Source File: towel_mode.py    From vldc-bot with MIT License 7 votes vote down vote up
def quarantine_user(user: User, chat_id: str, context: CallbackContext):
    logger.info(f"put {user} in quarantine")
    db.add_user(user.id)

    markup = InlineKeyboardMarkup([
        [InlineKeyboardButton(choice(I_AM_BOT), callback_data=MAGIC_NUMBER)]])

    # messages from `rel_message` will be deleted after greeting or ban
    db.add_user_rel_message(user.id, context.bot.send_message(
        chat_id,
        f"{user.name} НЕ нажимай на кнопку ниже, чтобы доказать, что ты не бот.\n"
        "Просто ответь (reply) на это сообщение, кратко написав о себе (у нас так принято).\n"
        "Я буду удалять твои сообщения, пока ты не сделаешь это.\n"
        f"А коли не сделаешь, через {QUARANTINE_TIME} минут выкину из чата.\n"
        "Ничего личного, просто боты одолели.\n",
        reply_markup=markup
    ).message_id) 
Example #5
Source File: favorites.py    From BotListBot with MIT License 7 votes vote down vote up
def remove_favorite_menu(bot, update):
    uid = util.uid_from_update(update)
    user = User.from_update(update)
    favorites = Favorite.select_all(user)

    fav_remove_buttons = [InlineKeyboardButton(
        '✖️ {}'.format(str(f.bot.username)),
        callback_data=util.callback_for_action(CallbackActions.REMOVE_FAVORITE, {'id': f.id}))
                          for f in favorites]
    buttons = util.build_menu(fav_remove_buttons, 2, header_buttons=[
        InlineKeyboardButton(captions.DONE,
                             callback_data=util.callback_for_action(CallbackActions.SEND_FAVORITES_LIST))
    ])
    reply_markup = InlineKeyboardMarkup(buttons)
    bot.formatter.send_or_edit(uid, util.action_hint("Select favorites to remove"),
                                 to_edit=util.mid_from_update(update),
                                 reply_markup=reply_markup) 
Example #6
Source File: inlinequeries.py    From BotListBot with MIT License 7 votes vote down vote up
def bot_article(b):
    txt = '{} ➡️ {}'.format(messages.rand_call_to_action(), b.detail_text)
    txt += '\n\n' + messages.PROMOTION_MESSAGE
    buttons = [
        [InlineKeyboardButton(captions.ADD_TO_FAVORITES, callback_data=util.callback_for_action(
            const.CallbackActions.ADD_TO_FAVORITES, {'id': b.id, 'discreet': True}))]]
    reply_markup = InlineKeyboardMarkup(buttons)
    return InlineQueryResultArticle(
        id=uuid4(),
        title=b.str_no_md,
        input_message_content=InputTextMessageContent(message_text=txt,
                                                      parse_mode=ParseMode.MARKDOWN),
        description=b.description if b.description else b.name if b.name else None,
        reply_markup=reply_markup
        # thumb_url='http://www.colorcombos.com/images/colors/FF0000.png'
    ) 
Example #7
Source File: stickers.py    From SkittBot with GNU General Public License v3.0 7 votes vote down vote up
def makepack_internal(msg, user, png_sticker, emoji, bot, packname, packnum):
    name = user.first_name
    name = name[:50]
    try:
        extra_version = ""
        if packnum > 0:
            extra_version = " " + str(packnum)
        success = bot.create_new_sticker_set(user.id, packname, f"{name}s kang pack" + extra_version,
                                             png_sticker=png_sticker,
                                             emojis=emoji)
    except TelegramError as e:
        print(e)
        if e.message == "Sticker set name is already occupied":
            msg.reply_text("Your pack can be found [here](t.me/addstickers/%s)" % packname,
                           parse_mode=ParseMode.MARKDOWN)
        elif e.message == "Peer_id_invalid":
            msg.reply_text("Contact me in PM first.", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(
                text="Start", url=f"t.me/{bot.username}")]]))
        elif e.message == "Internal Server Error: created sticker set not found (500)":
                msg.reply_text("Sticker pack successfully created. Get it [here](t.me/addstickers/%s)" % packname,
                       parse_mode=ParseMode.MARKDOWN)
        return

    if success:
        msg.reply_text("Sticker pack successfully created. Get it [here](t.me/addstickers/%s)" % packname,
                       parse_mode=ParseMode.MARKDOWN)
    else:
        msg.reply_text("Failed to create sticker pack. Possibly due to blek mejik.") 
Example #8
Source File: creation.py    From ultimate-poll-bot with MIT License 6 votes vote down vote up
def get_native_poll_merged_keyboard(poll):
    """Get the initial inline keyboard for poll creation."""
    locale = poll.user.locale
    change_type = CallbackType.show_poll_type_keyboard.value
    change_type_payload = f"{change_type}:{poll.id}:0"
    change_type_text = i18n.t("creation.keyboard.change", locale=locale)

    accept_text = i18n.t("keyboard.accept_continue", locale=locale)
    accept_payload = f"{CallbackType.ask_description.value}:{poll.id}:0"

    buttons = [
        [InlineKeyboardButton(change_type_text, callback_data=change_type_payload)],
        [InlineKeyboardButton(accept_text, callback_data=accept_payload)],
    ]

    return InlineKeyboardMarkup(buttons) 
Example #9
Source File: creation.py    From ultimate-poll-bot with MIT License 6 votes vote down vote up
def get_init_keyboard(poll):
    """Get the initial inline keyboard for poll creation."""
    locale = poll.user.locale
    change_type = CallbackType.show_poll_type_keyboard.value
    change_type_payload = f"{change_type}:{poll.id}:0"
    change_type_text = i18n.t("creation.keyboard.change", locale=locale)

    anonymity_text = i18n.t("keyboard.anonymity_settings", locale=locale)
    anonymity_payload = f"{CallbackType.anonymity_settings.value}:{poll.id}:0"

    buttons = [
        [InlineKeyboardButton(change_type_text, callback_data=change_type_payload)],
        [InlineKeyboardButton(anonymity_text, callback_data=anonymity_payload)],
    ]

    return InlineKeyboardMarkup(buttons) 
Example #10
Source File: worker.py    From greed with GNU Affero General Public License v3.0 6 votes vote down vote up
def __order_notify_admins(self, order):
        # Notify the user of the order result
        self.bot.send_message(self.chat.id, self.loc.get("success_order_created", order=order.text(loc=self.loc,
                                                                                                   session=self.session,
                                                                                                   user=True)))
        # Notify the admins (in Live Orders mode) of the new order
        admins = self.session.query(db.Admin).filter_by(live_mode=True).all()
        # Create the order keyboard
        order_keyboard = telegram.InlineKeyboardMarkup(
            [
                [telegram.InlineKeyboardButton(self.loc.get("menu_complete"), callback_data="order_complete")],
                [telegram.InlineKeyboardButton(self.loc.get("menu_refund"), callback_data="order_refund")]
            ])
        # Notify them of the new placed order
        for admin in admins:
            self.bot.send_message(admin.user_id,
                                  self.loc.get('notification_order_placed',
                                               order=order.text(loc=self.loc, session=self.session)),
                                  reply_markup=order_keyboard) 
Example #11
Source File: blackJackGame.py    From Python-BlackJackBot with GNU General Public License v3.0 6 votes vote down vote up
def add_player(self, user_id, first_name, message_id, silent=False):
        if self.game_running:
            return

        if self.get_player_by_id(user_id) is None and len(self.players) < self.MAX_PLAYERS:
            self.logger.debug("Adding user '" + first_name + "' to players.")
            player = Player(user_id, first_name, join_id=message_id)
            self.players.append(player)

            if silent:
                return

            # TODO When game is multiplayer then print current players?
            keyboard = [[InlineKeyboardButton(text=translate("start_game", self.lang_id), callback_data="start_game")]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            self.send_message(self.chat_id, translate("playerJoined", self.lang_id).format(first_name), message_id=message_id, reply_markup=reply_markup, game_id=self.__game_id)
        else:
            self.send_message(self.chat_id, translate("alreadyJoined", self.lang_id).format(first_name))
            self.logger.debug("User '{}' already in player list. Or max players reached".format(first_name)) 
Example #12
Source File: __main__.py    From EmiliaHikari with GNU General Public License v3.0 6 votes vote down vote up
def get_settings(update, context):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]
    args = msg.text.split(None, 1)

    # ONLY send settings in PM
    if chat.type != chat.PRIVATE:
        if is_user_admin(chat, user.id):
            text = tl(update.effective_message, "Klik di sini untuk mendapatkan pengaturan obrolan ini, serta milik Anda.")
            msg.reply_text(text,
                           reply_markup=InlineKeyboardMarkup(
                               [[InlineKeyboardButton(text="Pengaturan",
                                                      url="t.me/{}?start=stngs_{}".format(
                                                          context.bot.username, chat.id))]]))
        # else:
        #     text = tl(update.effective_message, "Klik di sini untuk memeriksa pengaturan Anda.")

    else:
        send_settings(chat.id, user.id, True) 
Example #13
Source File: __main__.py    From EmiliaHikari with GNU General Public License v3.0 6 votes vote down vote up
def get_help(update, context):
    chat = update.effective_chat  # type: Optional[Chat]
    args = update.effective_message.text.split(None, 1)

    # ONLY send help in PM
    if chat.type != chat.PRIVATE:

        # update.effective_message.reply_text("Contact me in PM to get the list of possible commands.",
        update.effective_message.reply_text(tl(update.effective_message, "Hubungi saya di PM untuk mendapatkan daftar perintah."),
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text=tl(update.effective_message, "Tolong"),
                                                                       url="t.me/{}?start=help".format(
                                                                           context.bot.username))]]))
        return

    elif len(args) >= 2 and any(args[1].lower() == x for x in HELPABLE):
        module = args[1].lower()
        text = tl(update.effective_message, "Ini adalah bantuan yang tersedia untuk modul *{}*:\n").format(HELPABLE[module].__mod_name__) \
               + tl(update.effective_message, HELPABLE[module].__help__)
        send_help(chat.id, text, InlineKeyboardMarkup([[InlineKeyboardButton(text=tl(update.effective_message, "Kembali"), callback_data="help_back")]]))

    else:
        send_help(chat.id, tl(update.effective_message, HELP_STRINGS)) 
Example #14
Source File: competitions.py    From superCodingBot with MIT License 6 votes vote down vote up
def removeRemind(self, bot, update):
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT id FROM apscheduler_jobs WHERE id LIKE  " + "'" + str(
            update.message.chat_id) + "%' AND id LIKE " + "'%1'")
        if c.fetchone():
            c.execute("SELECT id FROM apscheduler_jobs WHERE id LIKE  " + "'" + str(
                update.message.chat_id) + "%' AND id LIKE " + "'%1'")
            a = c.fetchall()
            keyboard = []
            for i in range(0, len(a)):
                s = str(a[i]).replace("('", "").replace("',)", "").replace(
                    '("', "").replace('",)', "")
                print(s)
                keyboard.append([InlineKeyboardButton(str(self.schedule.get_job(job_id=s).args[1].split("\n")[0]),
                                                      callback_data=s[:-1] + "notiplz")])
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text("Here are your pending reminders\nSelect the reminder you want to remove",
                                      reply_markup=reply_markup)
            c.close()
            return REMNOTI
        else:
            c.close()
            update.message.reply_text("You have no pending reminders")
            return ConversationHandler.END 
Example #15
Source File: creation.py    From ultimate-poll-bot with MIT License 5 votes vote down vote up
def get_back_to_init_button(poll):
    """Get the button to go back to the init creation message."""
    back_text = i18n.t("keyboard.back", locale=poll.locale)
    anonymity_payload = f"{CallbackType.back_to_init.value}:{poll.id}:0"
    return InlineKeyboardButton(back_text, callback_data=anonymity_payload) 
Example #16
Source File: vid_utils.py    From telegram-bot-youtube-downloader with MIT License 5 votes vote down vote up
def generate_keyboard(self):
        """ Generate a list of InlineKeyboardButton of resolutions """
        kb = []

        for code, extension, resolution in self.formats:
            kb.append([InlineKeyboardButton("{0}, {1}".format(extension, resolution),
                                     callback_data="{} {}".format(code, self.link))]) # maybe callback_data can support a list or tuple?
        return kb 
Example #17
Source File: repeat.py    From OpenCryptoBot with GNU Affero General Public License v3.0 5 votes vote down vote up
def _keyboard_remove_rep(self):
        menu = self.build_menu([InlineKeyboardButton("Remove", callback_data="remove")])
        return InlineKeyboardMarkup(menu, resize_keyboard=True)

    # Callback to delete repeater 
Example #18
Source File: bot.py    From permabots with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _create_keyboard_button(self, element):
        if isinstance(element, tuple):
            if 'http' in element[1]:
                return InlineKeyboardButton(text=element[0], url=element[1])
            else:
                return InlineKeyboardButton(text=element[0], callback_data=element[1])
        else:
            return InlineKeyboardButton(text=element, callback_data=element) 
Example #19
Source File: telegram.py    From satori with Apache License 2.0 5 votes vote down vote up
def make_button(action, event):
        action = str(action)
        return telegram.InlineKeyboardButton(
            text=action.capitalize(),
            callback_data="{} {}".format(action.lower(), event['id'])
        ) 
Example #20
Source File: feds.py    From EmiliaHikari with GNU General Public License v3.0 5 votes vote down vote up
def del_fed(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	args = context.args
	if chat.type != "private":
		send_message(update.effective_message, tl(update.effective_message, "Hapus federasi Anda di PM saya, bukan dalam grup."))
		return
	if args:
		is_fed_id = args[0]
		getinfo = sql.get_fed_info(is_fed_id)
		if getinfo == False:
			send_message(update.effective_message, tl(update.effective_message, "Federasi ini tidak di temukan!"))
			return
		if int(getinfo['owner']) == int(user.id) or int(user.id) == OWNER_ID:
			fed_id = is_fed_id
		else:
			send_message(update.effective_message, tl(update.effective_message, "Hanya pemilik federasi yang dapat melakukan ini!"))
			return
	else:
		send_message(update.effective_message, tl(update.effective_message, "Apa yang harus saya hapus?"))
		return

	if is_user_fed_owner(fed_id, user.id) == False:
		send_message(update.effective_message, tl(update.effective_message, "Hanya pemilik federasi yang dapat melakukan ini!"))
		return

	send_message(update.effective_message, tl(update.effective_message, "Anda yakin ingin menghapus federasi Anda? Tindakan ini tidak bisa dibatalkan, Anda akan kehilangan seluruh daftar larangan Anda, dan '{}' akan hilang secara permanen.").format(getinfo['fname']),
			reply_markup=InlineKeyboardMarkup(
						[[InlineKeyboardButton(text=tl(update.effective_message, "⚠️ Hapus Federasi ⚠️"), callback_data="rmfed_{}".format(fed_id))],
						[InlineKeyboardButton(text=tl(update.effective_message, "Batalkan"), callback_data="rmfed_cancel")]])) 
Example #21
Source File: telegramoptions.py    From calendar-telegram with MIT License 5 votes vote down vote up
def create_options_keyboard(options, cancel_msg):
    """
    Create an options keyboard with one line featuring each option
    """
    rows = []
    for i,op in enumerate(options):
        rows.append([InlineKeyboardButton(op,callback_data="CHOSEN;"+str(i))])
    if cancel_msg is not None:
        rows.append([InlineKeyboardButton(cancel_msg,callback_data="CANCEL;0")])
    return InlineKeyboardMarkup(rows) 
Example #22
Source File: creation.py    From ultimate-poll-bot with MIT License 5 votes vote down vote up
def get_init_settings_keyboard(poll):
    """Get the keyboard for initial settings during poll creation."""
    locale = poll.locale

    toggle_anonymity = CallbackType.toggle_anonymity.value
    toggle_anonymity_payload = f"{toggle_anonymity}:{poll.id}:0"
    toggle_anonymity_text = i18n.t("creation.keyboard.anonymity", locale=locale)
    if poll.anonymous:
        toggle_anonymity_text = i18n.t("creation.keyboard.no_anonymity", locale=locale)

    toggle_results_visible = CallbackType.toggle_results_visible.value
    toggle_results_visible_payload = f"{toggle_results_visible}:{poll.id}:0"
    toggle_results_visible_text = i18n.t(
        "creation.keyboard.results_visible", locale=locale
    )
    if poll.results_visible:
        toggle_results_visible_text = i18n.t(
            "creation.keyboard.results_not_visible", locale=locale
        )

    buttons = [
        [
            InlineKeyboardButton(
                toggle_anonymity_text, callback_data=toggle_anonymity_payload
            )
        ],
        [
            InlineKeyboardButton(
                toggle_results_visible_text,
                callback_data=toggle_results_visible_payload,
            )
        ],
        [get_back_to_init_button(poll)],
    ]

    return InlineKeyboardMarkup(buttons) 
Example #23
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def show_matrix_markup(matrix):
    COLUMNS = len(matrix[0])
    buttons = [
        Button(f'{num}', callback_data='a')
        for row in matrix
        for num in row
    ]
    columned_keyboard = [
        buttons[i: i + COLUMNS] for i in range(0, len(buttons), COLUMNS)
    ]
    return InlineKeyboardMarkup(columned_keyboard) 
Example #24
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def serie_episodes_keyboards(episodes_dict):
    COLUMNS = 5
    buttons = [
        Button(f'Ep {ep_number}', callback_data=EPISODE_T.format(ep_number))
        for ep_number, episode in sorted(episodes_dict.items())
    ]
    columned_keyboard = [
        buttons[i: i + COLUMNS] for i in range(0, len(buttons), COLUMNS)
    ]
    columned_keyboard.append(GO_BACK_BUTTON_ROW)

    return InlineKeyboardMarkup(columned_keyboard) 
Example #25
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def serie_season_keyboard(seasons):
    COLUMNS = 2
    buttons = [
        Button(f'Season {season}', callback_data=SEASON_T.format(season))
        for season, episodes in sorted(seasons.items())
    ]
    columned_keyboard = [
        buttons[i: i + COLUMNS] for i in range(0, len(buttons), COLUMNS)
    ]
    columned_keyboard.append(GO_BACK_BUTTON_ROW)

    return InlineKeyboardMarkup(columned_keyboard) 
Example #26
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def serie_load_more_latest_episodes_keyboard():
    buttons = [
        [Button('Load more..', callback_data=LOAD_MORE_LATEST)],
        GO_BACK_BUTTON_ROW,
    ]
    return InlineKeyboardMarkup(buttons) 
Example #27
Source File: telegram.py    From satori with Apache License 2.0 5 votes vote down vote up
def make_button(action, event):
        action = str(action)
        return telegram.InlineKeyboardButton(
            text=action.capitalize(),
            callback_data="{} {}".format(action.lower(), event['id'])
        ) 
Example #28
Source File: creation.py    From ultimate-poll-bot with MIT License 5 votes vote down vote up
def get_change_poll_type_keyboard(poll):
    """Get the inline keyboard for changing the vote type."""
    change_type = CallbackType.change_poll_type.value

    # Dynamically create a button for each vote type
    buttons = []
    for poll_type in PollType:
        text = translate_poll_type(poll_type.name, poll.locale)
        payload = f"{change_type}:{poll.id}:{poll_type.value}"
        button = [InlineKeyboardButton(text, callback_data=payload)]
        buttons.append(button)

    buttons.append([get_back_to_init_button(poll)])

    return InlineKeyboardMarkup(buttons) 
Example #29
Source File: creation.py    From ultimate-poll-bot with MIT License 5 votes vote down vote up
def get_cancel_creation_keyboard(poll):
    """Get the cancel creation button."""
    payload = f"{CallbackType.cancel_creation.value}:{poll.id}:0"
    buttons = [
        [
            InlineKeyboardButton(
                i18n.t("creation.cancel", locale=poll.user.locale),
                callback_data=payload,
            )
        ]
    ]

    return InlineKeyboardMarkup(buttons) 
Example #30
Source File: misc.py    From EmiliaHikari with GNU General Public License v3.0 5 votes vote down vote up
def build_keyboard_alternate(buttons):
    keyb = []
    for btn in buttons:
        if btn[2] and keyb:
            keyb[-1].append(InlineKeyboardButton(btn[0], url=btn[1]))
        else:
            keyb.append([InlineKeyboardButton(btn[0], url=btn[1])])

    return keyb