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


Python telegram.ReplyKeyboardMarkup方法代碼示例

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


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

示例1: add_custom

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def add_custom(bot, update, username):
    uid = util.uid_from_update(update)
    user = User.from_update(update)
    mid = util.mid_from_update(update)
    from components.basic import main_menu_buttons
    main_menu_markup = ReplyKeyboardMarkup(main_menu_buttons(uid in settings.MODERATORS))

    try:
        fav = Favorite.get(custom_bot=username)
        util.send_or_edit_md_message(
            bot, uid, mdformat.none_action(
                "{} is already a favorite of yours. /favorites".format(fav.custom_bot)),
            to_edit=mid,
            reply_markup=main_menu_markup)
    except Favorite.DoesNotExist:
        fav = Favorite(user=user, custom_bot=username, date_added=datetime.date.today())
        fav.save()
        msg = bot.formatter.send_or_edit(uid,
                                           mdformat.love("{} added to your /favorites.".format(fav.custom_bot)),
                                           to_edit=mid)
        mid = msg.message_id
        util.wait(bot, update)
        send_favorites_list(bot, update, to_edit=mid)
    return ConversationHandler.END 
開發者ID:JosXa,項目名稱:BotListBot,代碼行數:26,代碼來源:favorites.py

示例2: send_next

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def send_next(bot, update, job_queue: JobQueue, args=None):
    uid = util.uid_from_update(update)
    num_rows = None
    if args:
        try:
            num_rows = int(args[0])
        except:
            num_rows = None

    reply_markup = ReplyKeyboardMarkup(
        _crapPy_Tr0ll_kbmarkup(num_rows), one_time_keyboard=False, per_user=True
    )
    text = "ɹoʇɐɹǝuǝb ǝɯɐuɹǝsn ɯɐɹbǝןǝʇ"
    util.send_md_message(bot, uid, text, reply_markup=reply_markup)

    if util.is_group_message(update):
        del_msg = bot.formatter.send_message(
            update.effective_chat.id, "Have fun in private ;)\n/easteregg"
        )
        update.effective_message.delete()
        job_queue.run_once(
            lambda *_: del_msg.delete(safe=True), 4, name="delete easteregg hint"
        ) 
開發者ID:JosXa,項目名稱:BotListBot,代碼行數:25,代碼來源:eastereggs.py

示例3: filer

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def filer(bot, update, user_data):
        file_id = update.message.document.file_id
        if ComHandler.check_file_size(update):
            return ConversationHandler.END
        newFile = bot.get_file(file_id)
        newFile.download('abcd.txt')
        with open('abcd.txt', 'r') as f:
            source = f.read()
        user_data['code'] = source
        custom_keyboard = [['#no test case', '#send a .txt file']]
        reply_markup = ReplyKeyboardMarkup(custom_keyboard, one_time_keyboard=True, resize_keybord=True)
        update.message.reply_text(
            'Please send test cases together as you would do in online ide\nIf you dont want to provide test cases select #no test case\n I you want to send test cases as .txt file select #send a .txt file',
            reply_markup=reply_markup)
        # REMOVING THE FILE AFTER PROCESS IS COMPLETE
        os.remove('abcd.txt')
        return TESTCASES

    # FUNCTION TO GET THE SOURCE CODE SENT BY USER 
開發者ID:Gotham13121997,項目名稱:superCodingBot,代碼行數:21,代碼來源:compiler.py

示例4: start

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def start(bot, update):
    """
    Start function. Displayed whenever the /start command is called.
    This function sets the language of the bot.
    """
    # Create buttons to slect language:
    keyboard = [['ES', 'EN']]

    # Create initial message:
    message = "Hey, I'm DisAtBot! / ¡Hey, soy DisAtBot! \n\n\
Please select a language to start. / Por favor selecciona un idioma \
para comenzar."

    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       one_time_keyboard=True,
                                       resize_keyboard=True)
    update.message.reply_text(message, reply_markup=reply_markup)

    return SET_LANG 
開發者ID:RodolfoFerro,項目名稱:DisAtBot,代碼行數:21,代碼來源:DisAtBot.py

示例5: menu

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def menu(bot, update):
    """
    Main menu function.
    This will display the options from the main menu.
    """
    # Create buttons to slect language:
    keyboard = [[send_report[LANG], view_map[LANG]],
                [view_faq[LANG], view_about[LANG]]]

    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       one_time_keyboard=True,
                                       resize_keyboard=True)

    user = update.message.from_user
    logger.info("Menu command requested by {}.".format(user.first_name))
    update.message.reply_text(main_menu[LANG], reply_markup=reply_markup)

    return SET_STAT 
開發者ID:RodolfoFerro,項目名稱:DisAtBot,代碼行數:20,代碼來源:DisAtBot.py

示例6: show_crawlers_to_search

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def show_crawlers_to_search(self, bot, update, user_data):
        app = user_data.get('app')

        buttons = []

        def make_button(i, url):
            return '%d - %s' % (i + 1, urlparse(url).hostname)
        # end def
        for i in range(1, len(app.crawler_links) + 1, 2):
            buttons += [[
                make_button(i - 1, app.crawler_links[i - 1]),
                make_button(i, app.crawler_links[i]) if i < len(
                    app.crawler_links) else '',
            ]]
        # end for

        update.message.reply_text(
            'Choose where to search for your novel, \n'
            'or send /skip to search everywhere.',
            reply_markup=ReplyKeyboardMarkup(buttons, one_time_keyboard=True),
        )
        return 'handle_crawler_to_search'
    # end def 
開發者ID:dipu-bd,項目名稱:lightnovel-crawler,代碼行數:25,代碼來源:telegram.py

示例7: show_source_selection

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def show_source_selection(self, bot, update, user_data):
        app = user_data.get('app')
        selected = user_data.get('selected')

        if len(selected['novels']) == 1:
            app.init_crawler(selected['novels'][0]['url'])
            return self.get_novel_info(bot, update, user_data)
        # end if

        update.message.reply_text(
            ('Choose a source to download "%s", ' % selected['title']) +
            'or send /cancel to stop this session.',
            reply_markup=ReplyKeyboardMarkup([
                [
                    '%d. %s %s' % (
                        index + 1,
                        novel['url'],
                        novel['info'] if 'info' in novel else ''
                    )
                ] for index, novel in enumerate(selected['novels'])
            ], one_time_keyboard=True),
        )

        return 'handle_select_source'
    # end def 
開發者ID:dipu-bd,項目名稱:lightnovel-crawler,代碼行數:27,代碼來源:telegram.py

示例8: range_selection_done

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def range_selection_done(self, bot, update, user_data):
        app = user_data.get('app')
        update.message.reply_text(
            'You have selected %d chapters to download' % len(app.chapters)
        )
        if len(app.chapters) == 0:
            return self.display_range_selection_help(bot, update)
        # end if
        update.message.reply_text(
            'Do you want to generate a single file or split the books into volumes?',
            reply_markup=ReplyKeyboardMarkup([
                ['Single file', 'Split by volumes']
            ], one_time_keyboard=True),
        )
        return 'handle_pack_by_volume'
    # end def 
開發者ID:dipu-bd,項目名稱:lightnovel-crawler,代碼行數:18,代碼來源:telegram.py

示例9: start

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def start(bot, update):
    """
        Shows an welcome message and help info about the available commands.
    """
    me = bot.get_me()

    # Welcome message
    msg = _("Hello!\n")
    msg += _("I'm {0} and I came here to help you.\n").format(me.first_name)
    msg += _("What would you like to do?\n\n")
    msg += _("/support - Opens a new support ticket\n")
    msg += _("/settings - Settings of your account\n\n")

    # Commands menu
    main_menu_keyboard = [[telegram.KeyboardButton('/support')],
                          [telegram.KeyboardButton('/settings')]]
    reply_kb_markup = telegram.ReplyKeyboardMarkup(main_menu_keyboard,
                                                   resize_keyboard=True,
                                                   one_time_keyboard=True)

    # Send the message with menu
    bot.send_message(chat_id=update.message.chat_id,
                     text=msg,
                     reply_markup=reply_kb_markup) 
開發者ID:juliarizza,項目名稱:helpdeskbot,代碼行數:26,代碼來源:main.py

示例10: settings

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def settings(bot, update):
    """
        Configure the messages language using a custom keyboard.
    """
    # Languages message
    msg = _("Please, choose a language:\n")
    msg += "en_US - English (US)\n"
    msg += "pt_BR - Português (Brasil)\n"

    # Languages menu
    languages_keyboard = [
        [telegram.KeyboardButton('en_US - English (US)')],
        [telegram.KeyboardButton('pt_BR - Português (Brasil)')]
    ]
    reply_kb_markup = telegram.ReplyKeyboardMarkup(languages_keyboard,
                                                   resize_keyboard=True,
                                                   one_time_keyboard=True)

    # Sends message with languages menu
    bot.send_message(chat_id=update.message.chat_id,
                     text=msg,
                     reply_markup=reply_kb_markup) 
開發者ID:juliarizza,項目名稱:helpdeskbot,代碼行數:24,代碼來源:main.py

示例11: language_command

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def language_command(self, message, user_id, chat_id, user):
        """
        Handles the Language command and sends the lis of languages

        :param message: the message sent by the user
        :param user_id: User id
        :param chat_id: Chat id
        :param user: Dict with user configuration
        :return: None
        """
        languages = [[lang] for lang in sorted(self.get_languages().keys())]
        keyboard = ReplyKeyboardMarkup(languages, one_time_keyboard=True)
        text = self._get_template('language_answer.md').render()
        self.telegram_api.sendMessage(chat_id, text, reply_markup=keyboard)
        if self.get_group():
            user.set_field(chat_id, 'mode', 'setlanguage', group=self.get_group())
        else:
            user.set_field(user_id, 'mode', 'setlanguage', group=self.get_group()) 
開發者ID:Xevib,項目名稱:osmbot,代碼行數:20,代碼來源:osmbot.py

示例12: settings_command

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def settings_command(self, message, user_id, chat_id, u):
        """
        Answers the settings command

        :param message: User message
        :param user_id: User identifier
        :param chat_id: Chat id
        :param u: Uers object
        :param group: Boolen to indicate if it's on a group
        :return: None
        """

        if self.get_group():
            text = self._get_template('question_only_mention.md').render()
            k = ReplyKeyboardMarkup([['Language'], [text]], one_time_keyboard=True)
        else:
            k = ReplyKeyboardMarkup([['Language']], one_time_keyboard=True)
        text = self._get_template('configure_question.md').render()
        self.telegram_api.sendMessage(chat_id, text, reply_markup=k)
        if self.get_group():
            identifier = chat_id
        else:
            identifier = user_id
        u.set_field(identifier, 'mode', 'settings', group=self.get_group()) 
開發者ID:Xevib,項目名稱:osmbot,代碼行數:26,代碼來源:osmbot.py

示例13: prompt_for_confirm

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def prompt_for_confirm(bot, update: Update, user: User, render):
    reply_markup = ReplyKeyboardMarkup([['Resend confirmation email'], ['Change email']])
    update.message.reply_text(render('waiting_for_confirmation'), reply_markup=reply_markup) 
開發者ID:f213,項目名稱:selfmailbot,代碼行數:5,代碼來源:app.py

示例14: section_keyboard

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def section_keyboard(bot, update):
    """
    Command that shows keyboard of departments for:
    news, newson and newsoff
    """

    keys = [['Univaq'], ['Disim'], ['Mesva'],
            ['Discab'], ['Chiudi']]

    bot.sendMessage(update.message.chat_id,
                    'Scegli il dipartimento:',
                    reply_markup=telegram.ReplyKeyboardMarkup(
                        keys, one_time_keyboard=True))

    return "department" 
開發者ID:giacomocerquone,項目名稱:UnivaqBot,代碼行數:17,代碼來源:news_commands.py

示例15: univaq

# 需要導入模塊: import telegram [as 別名]
# 或者: from telegram import ReplyKeyboardMarkup [as 別名]
def univaq(bot, update):
    """
    Command that shows keyboard of sections for:
    inevidenza, ultimissime, univaqon, univaqoff
    """

    keys = [['In Evidenza'], ['Ultimissime'], ['Chiudi']]

    bot.sendMessage(update.message.chat_id,
                    'Scegli la sezione:',
                    reply_markup=telegram.ReplyKeyboardMarkup(
                        keys, one_time_keyboard=True))

    return "univaq" 
開發者ID:giacomocerquone,項目名稱:UnivaqBot,代碼行數:16,代碼來源:univaq.py


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