當前位置: 首頁>>代碼示例>>Python>>正文


Python telegram.InlineKeyboardMarkup方法代碼示例

本文整理匯總了Python中telegram.InlineKeyboardMarkup方法的典型用法代碼示例。如果您正苦於以下問題:Python telegram.InlineKeyboardMarkup方法的具體用法?Python telegram.InlineKeyboardMarkup怎麽用?Python telegram.InlineKeyboardMarkup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在telegram的用法示例。


在下文中一共展示了telegram.InlineKeyboardMarkup方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: polo

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
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 
開發者ID:Gotham13121997,項目名稱:superCodingBot,代碼行數:26,代碼來源:ranklist.py

示例2: send_intro_template

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def send_intro_template(bot, chat_id, lang, key, text_key):
    # Prepare Keyboard
    lang_list = helper_const.LANG_LIST
    width = helper_const.LANG_WIDTH
    current_lang = lang
    motd_keyboard = [[
        InlineKeyboardButton(
            lang_list[width * idx + delta] + (" (*)" if lang_list[width * idx + delta] == current_lang else ""),
            callback_data="%s|%s" % (key, lang_list[width * idx + delta])
        ) for delta in range(width)
    ] for idx in range(len(lang_list) // width)] + [[
        InlineKeyboardButton(
            lang_list[idx] + (" (*)" if lang_list[idx] == current_lang else ""),
            callback_data="%s|%s" % (key, lang_list[idx])
        )
    for idx in range(width * (len(lang_list) // width), len(lang_list))]]

    motd_markup = InlineKeyboardMarkup(motd_keyboard)
    bot.send_message(
        chat_id=chat_id, 
        text=value(text_key, "", lang=current_lang),
        reply_markup=motd_markup
    ) 
開發者ID:JogleLew,項目名稱:channel-helper-bot,代碼行數:25,代碼來源:helper_global.py

示例3: get_help

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def get_help(bot: Bot, update: Update):
    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.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Help",
                                                                       url="t.me/{}?start=help".format(
                                                                           bot.username))]]))
        return

    elif len(args) >= 2 and any(args[1].lower() == x for x in HELPABLE):
        module = args[1].lower()
        text = "Here is the available help for the *{}* module:\n".format(HELPABLE[module].__mod_name__) \
               + HELPABLE[module].__help__
        send_help(chat.id, text, InlineKeyboardMarkup([[InlineKeyboardButton(text="Back", callback_data="help_back")]]))

    else:
        send_help(chat.id, HELP_STRINGS) 
開發者ID:skittles9823,項目名稱:SkittBot,代碼行數:24,代碼來源:__main__.py

示例4: send_settings

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def send_settings(chat_id, user_id, user=False):
    if user:
        if USER_SETTINGS:
            settings = "\n\n".join(
                "*{}*:\n{}".format(mod.__mod_name__, mod.__user_settings__(user_id)) for mod in USER_SETTINGS.values())
            dispatcher.bot.send_message(user_id, "These are your current settings:" + "\n\n" + settings,
                                        parse_mode=ParseMode.MARKDOWN)

        else:
            dispatcher.bot.send_message(user_id, "Seems like there aren't any user specific settings available :'(",
                                        parse_mode=ParseMode.MARKDOWN)

    else:
        if CHAT_SETTINGS:
            chat_name = dispatcher.bot.getChat(chat_id).title
            dispatcher.bot.send_message(user_id,
                                        text="Which module would you like to check {}'s settings for?".format(
                                            chat_name),
                                        reply_markup=InlineKeyboardMarkup(
                                            paginate_modules(0, CHAT_SETTINGS, "stngs", chat=chat_id)))
        else:
            dispatcher.bot.send_message(user_id, "Seems like there aren't any chat settings available :'(\nSend this "
                                                 "in a group chat you're admin in to find its current settings!",
                                        parse_mode=ParseMode.MARKDOWN) 
開發者ID:skittles9823,項目名稱:SkittBot,代碼行數:26,代碼來源:__main__.py

示例5: get_settings

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def get_settings(bot: Bot, update: Update):
    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 = "Click here to get this chat's settings, as well as yours."
            msg.reply_text(text,
                           reply_markup=InlineKeyboardMarkup(
                               [[InlineKeyboardButton(text="Settings",
                                                      url="t.me/{}?start=stngs_{}".format(
                                                          bot.username, chat.id))]]))
        else:
            text = "Click here to check your settings."

    else:
        send_settings(chat.id, user.id, True) 
開發者ID:skittles9823,項目名稱:SkittBot,代碼行數:22,代碼來源:__main__.py

示例6: manage_subscription

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def manage_subscription(bot, update):
    chat_id = update.effective_chat.id
    user_id = update.effective_user.id

    if util.is_group_message(update):
        admins = bot.get_chat_administrators(chat_id)
        if user_id not in admins:
            bot.formatter.send_failure(chat_id, "Sorry, but only Administrators of this group are allowed "
                                                    "to manage subscriptions.")
            return

    text = "Would you like to be notified when new bots arrive at the @BotList?"
    buttons = [[
        InlineKeyboardButton(util.success("Yes"),
                             callback_data=util.callback_for_action(CallbackActions.SET_NOTIFICATIONS,
                                                                    {'value': True})),
        InlineKeyboardButton("No", callback_data=util.callback_for_action(CallbackActions.SET_NOTIFICATIONS,
                                                                          {'value': False}))]]
    reply_markup = InlineKeyboardMarkup(buttons)
    msg = util.send_md_message(bot, chat_id, text, reply_markup=reply_markup)
    return ConversationHandler.END 
開發者ID:JosXa,項目名稱:BotListBot,代碼行數:23,代碼來源:misc.py

示例7: remove_favorite_menu

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
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) 
開發者ID:JosXa,項目名稱:BotListBot,代碼行數:19,代碼來源:favorites.py

示例8: upcoming_sender

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
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) 
開發者ID:Gotham13121997,項目名稱:superCodingBot,代碼行數:26,代碼來源:contest_utility.py

示例9: removeRemind

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
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 
開發者ID:Gotham13121997,項目名稱:superCodingBot,代碼行數:27,代碼來源:competitions.py

示例10: time_options_keyboard

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def time_options_keyboard():
    buttons = [
        [
            Button('5 Mins', callback_data=remind_time(5 * MINUTE)),
            Button('10 Mins', callback_data=remind_time(10 * MINUTE)),
            Button('20 Mins', callback_data=remind_time(20 * MINUTE)),
            Button('30 Mins', callback_data=remind_time(30 * MINUTE)),
        ],
        [
            Button('1 Hour', callback_data=remind_time(HOUR)),
            Button('2 Hours', callback_data=remind_time(2 * HOUR)),
            Button('4 Hours', callback_data=remind_time(4 * HOUR)),
            Button('8 Hours', callback_data=remind_time(8 * HOUR)),
        ],
        [
            Button('12 hours', callback_data=remind_time(12 * HOUR)),
            Button('24 hours', callback_data=remind_time(24 * HOUR)),
            Button('48 hours', callback_data=remind_time(48 * HOUR)),
        ],
    ]

    return InlineKeyboardMarkup(buttons) 
開發者ID:Ambro17,項目名稱:AmbroBot,代碼行數:24,代碼來源:keyboards.py

示例11: get_help

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
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)) 
開發者ID:AyraHikari,項目名稱:EmiliaHikari,代碼行數:25,代碼來源:__main__.py

示例12: start

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def start(bot, update):
    # Select language
    langs_markup = InlineKeyboardMarkup([[
        InlineKeyboardButton('English {}'.format(b'\xF0\x9F\x87\xAC\xF0\x9F\x87\xA7'.decode()), callback_data='en'),
        InlineKeyboardButton('Русский {}'.format(b'\xF0\x9F\x87\xB7\xF0\x9F\x87\xBA'.decode()), callback_data='ru'),
        InlineKeyboardButton('Português {}'.format(b'\xF0\x9F\x87\xA7\xF0\x9F\x87\xB7'.decode()), callback_data='pt')
    ]])
    bot.send_message(
        text='Choose your language / Выберите язык / Escolha seu idioma',
        reply_markup=langs_markup,
        chat_id=update.message.chat_id,
    ) 
開發者ID:dizballanze,項目名稱:m00dbot,代碼行數:14,代碼來源:bot.py

示例13: send_frequency_question

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def send_frequency_question(bot, chat_id):
    lang = chat_storage.get_or_create(chat_id)['language']
    frequency_markup = InlineKeyboardMarkup([[
        InlineKeyboardButton(texts.FREQUENCY_NONE[lang], callback_data='none'),
        InlineKeyboardButton(texts.FREQUENCY_DAILY[lang], callback_data='daily'),
        InlineKeyboardButton(texts.FREQUENCY_WEEKLY[lang], callback_data='weekly')]])
    bot.send_message(text=texts.FREQUENCY_QUESTION[lang], reply_markup=frequency_markup, chat_id=chat_id) 
開發者ID:dizballanze,項目名稱:m00dbot,代碼行數:9,代碼來源:bot.py

示例14: send_hars_question

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def send_hars_question(question, bot, chat_id):
    keyboard = [[InlineKeyboardButton(answer, callback_data=i)] for i, answer in enumerate(question.answers)]
    reply_markup = InlineKeyboardMarkup(keyboard)
    bot.send_message(text=question.question, reply_markup=reply_markup, chat_id=chat_id) 
開發者ID:dizballanze,項目名稱:m00dbot,代碼行數:6,代碼來源:bot.py

示例15: send_madrs_question

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import InlineKeyboardMarkup [as 別名]
def send_madrs_question(question, bot, chat_id):
    keyboard = [[InlineKeyboardButton(str(i), callback_data=i) for i in range(0, 7)]]
    reply_markup = InlineKeyboardMarkup(keyboard)
    question_text = '{}\n{}'.format(question.question, '\n'.join(question.answers))
    bot.send_message(text=question_text, reply_markup=reply_markup, chat_id=chat_id) 
開發者ID:dizballanze,項目名稱:m00dbot,代碼行數:7,代碼來源:bot.py


注:本文中的telegram.InlineKeyboardMarkup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。