当前位置: 首页>>代码示例>>Python>>正文


Python telegram.InlineQueryResultArticle方法代码示例

本文整理汇总了Python中telegram.InlineQueryResultArticle方法的典型用法代码示例。如果您正苦于以下问题:Python telegram.InlineQueryResultArticle方法的具体用法?Python telegram.InlineQueryResultArticle怎么用?Python telegram.InlineQueryResultArticle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram的用法示例。


在下文中一共展示了telegram.InlineQueryResultArticle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bot_article

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
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'
    ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:18,代码来源:inlinequeries.py

示例2: article

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def article(title='', description='', message_text='', key=None, reply_markup=None):
    return InlineQueryResultArticle(
        id=key or uuid4(),
        title=title,
        description=description,
        input_message_content=InputTextMessageContent(
            message_text=message_text,
            parse_mode=ParseMode.MARKDOWN,
            disable_web_page_preview=True),
        reply_markup=reply_markup
    ) 
开发者ID:python-telegram-bot,项目名称:rules-bot,代码行数:13,代码来源:inlinequeries.py

示例3: query_too_short_article

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def query_too_short_article():
    txt = '[I am a stupid, crazy fool.](https://www.youtube.com/watch?v=DLzxrzFCyOs)'
    return InlineQueryResultArticle(
        id=uuid4(),
        title=util.action_hint('Your search term must be at least {} characters long.'.format(
            SEARCH_QUERY_MIN_LENGTH)),
        input_message_content=InputTextMessageContent(message_text=txt,
                                                      parse_mode="Markdown",
                                                      disable_web_page_preview=True)
    ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:12,代码来源:inlinequeries.py

示例4: category_article

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def category_article(cat):
    cat_bots = Bot.of_category_without_new(cat)
    txt = messages.PROMOTION_MESSAGE + '\n\n'
    txt += "There are *{}* bots in the category *{}*:\n\n".format(len(cat_bots), str(cat))
    txt += '\n'.join([str(b) for b in cat_bots])
    return InlineQueryResultArticle(
        id=uuid4(),
        title=emoji.emojize(cat.emojis, use_aliases=True) + cat.name,
        input_message_content=InputTextMessageContent(message_text=txt,
                                                      parse_mode=ParseMode.MARKDOWN),
        description=cat.extra,
        # thumb_url='https://pichoster.net/images/2017/03/13/cfa5e29e29e772373242bc177a9e5479.jpg'
    ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:15,代码来源:inlinequeries.py

示例5: all_bot_results_article

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def all_bot_results_article(lst, too_many_results):
    txt = messages.PROMOTION_MESSAGE + '\n\n'
    txt += "{} one of these {} bots:\n\n".format(messages.rand_call_to_action(), len(lst))
    txt += '\n'.join([str(b) for b in lst])
    return InlineQueryResultArticle(
        id=uuid4(),
        title='{} {} ʙᴏᴛ ʀᴇsᴜʟᴛs'.format(
            mdformat.smallcaps("Send"),
            len(lst)),
        input_message_content=InputTextMessageContent(message_text=txt[:4096],
                                                      parse_mode=ParseMode.MARKDOWN)
        # description=b.description if b.description else b.name if b.name else None,
        # thumb_url='http://www.colorcombos.com/images/colors/FF0000.png'
    ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:16,代码来源:inlinequeries.py

示例6: hint_article

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def hint_article(msg, reply_markup, key):
    return InlineQueryResultArticle(
        id=uuid4(),
        title=key.replace('#', '').capitalize() + ' hint',
        input_message_content=InputTextMessageContent(
            message_text=msg,
            parse_mode="Markdown",
            disable_web_page_preview=True
        ),
        reply_markup=reply_markup
    ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:13,代码来源:inlinequeries.py

示例7: inlinequery

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def inlinequery(bot, update):
    query = update.inline_query.query
    o = execute(query, update, direct=False)
    results = list()

    results.append(InlineQueryResultArticle(id=uuid4(),
                                            title=query,
                                            description=o,
                                            input_message_content=InputTextMessageContent(
                                                '*{0}*\n\n{1}'.format(query, o),
                                                parse_mode="Markdown")))

    bot.answerInlineQuery(update.inline_query.id, results=results, cache_time=10) 
开发者ID:bvanrijn,项目名称:sudobot,代码行数:15,代码来源:bot.py

示例8: get_default_query_results

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def get_default_query_results(quran: Quran):
    results = []
    ayat = [
        (13, 28), (33, 56), (2, 62), (10, 31), (17, 36), (5, 32), (39, 9), (17, 44), (28, 88), (17, 84), (33, 6),
        (7, 57), (3, 7), (2, 255), (63, 9), (57, 20), (49, 12), (16, 125), (24, 35), (73, 8), (4, 103)
    ]
    for s, a in ayat:
        ayah = "%d:%d" % (s, a)
        english = quran.get_ayah(s, a)
        results.append(InlineQueryResultArticle(
            ayah + "def", title=ayah,
            description=english[:120],
            input_message_content=InputTextMessageContent(english))
        )
    return results 
开发者ID:rahiel,项目名称:BismillahBot,代码行数:17,代码来源:bismillah.py

示例9: _inline

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def _inline(self, bot, update):
        query = update.inline_query.query
        if not query or not query.startswith("/") or not query.endswith("."):
            return

        def _send(msg, description=None):
            if not description:
                description = str(msg)

            content = InputTextMessageContent(str(msg), parse_mode=ParseMode.MARKDOWN)
            inline_result = InlineQueryResultArticle(
                id=uuid.uuid4(),
                title=description,
                input_message_content=content)

            bot.answer_inline_query(update.inline_query.id, [inline_result])

        args = query.split(" ")
        args[len(args) - 1] = args[len(args)-1].replace(".", "")
        cmd = args[0][1:].lower()
        args.pop(0)

        args.append(f"{Keyword.INLINE}=true")

        plgn = None
        for plugin in self.plugins:
            if cmd in plugin.get_cmds():
                if not plugin.inline_mode():
                    message = "Inline mode not supported"
                    return _send(f"{emo.INFO} {message}")

                plgn = plugin
                break

        if not plgn:
            message = "Command not found"
            return _send(f"{emo.INFO} {message}")

        v = plgn.get_action(bot, update, args=args)

        if not v:
            message = "No message returned"
            return _send(f"{emo.ERROR} {message}")

        if not isinstance(v, str):
            message = "No *string* returned"
            return _send(f"{emo.ERROR} {message}")

        if v.startswith(emo.ERROR) or v.startswith(emo.INFO):
            return _send(v)

        _send(v, plgn.get_description())

    # Handle all telegram and telegram.ext related errors 
开发者ID:Endogen,项目名称:OpenCryptoBot,代码行数:56,代码来源:telegrambot.py

示例10: answer_inline

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import InlineQueryResultArticle [as 别名]
def answer_inline(self, message, query, user_config):
        """
        Answers the inline queryes

        :param message: User inline search
        :param query: Dict with the full query as a dict
        :param user_config: User configuration as a dict
        :return: None
        """
        if not message:
            return None
        nom = pynominatim.Nominatim()
        is_rtl = user_config['lang'] in self.get_rtl_languages()
        search_results = nom.query(message, acceptlanguage=user_config['lang'])
        temp = self._get_template('inline_article.md')
        inline_query_id = query['inline_query']['id']
        results = []
        if search_results:
            for index, r in enumerate(search_results[:10]):
                element_type = ''
                if r.get('osm_type', '') == 'node':
                    element_type = 'nod'
                elif r.get('osm_type', '') == 'way':
                    element_type = 'way'
                elif r.get('osm_type', '') == 'relation':
                    element_type = 'rel'
                osm_data = getData(r['osm_id'], geom_type=element_type)
                params = {
                    'data': osm_data, 'type': element_type,
                    'identifier': r['osm_id'], 'user_config': user_config,
                    'is_rtl': is_rtl, 'nominatim_data': r
                }
                if osm_data:
                    text = temp.render(**params)
                name_lang = 'name:{}'.format(user_config['lang'])
                if name_lang in osm_data['tag']:
                    results.append(InlineQueryResultArticle(
                        id=uuid4(),
                        title=osm_data['tag'][name_lang],
                        description=r['display_name'],
                        input_message_content=InputTextMessageContent(
                            text,
                            parse_mode=ParseMode.MARKDOWN)))
                else:
                    results.append(InlineQueryResultArticle(
                        id=uuid4(),
                        title=osm_data['tag'].get('name',r['display_name']),
                        description=r['display_name'],
                        input_message_content=InputTextMessageContent(
                            text,
                            parse_mode=ParseMode.MARKDOWN)))

        self.telegram_api.answerInlineQuery(
            inline_query_id,
            results,
            is_personal=True,
            cache_time=86400) 
开发者ID:Xevib,项目名称:osmbot,代码行数:59,代码来源:osmbot.py


注:本文中的telegram.InlineQueryResultArticle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。