animebot.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:animebot 作者: EV3REST 项目源码 文件源码
def inline(bot, update): #Inline Handler & Parser
    query = update.inline_query.query
    if query is None:
        query = 'rating:s'
        client = Pybooru('Yandere')
        posts = client.posts_list(tags=query, limit=50)
        lposts = len(posts)
        inlinequery = list()
        reply_markup = InlineKeyboardMarkup([InlineKeyboardButton("More", callback_data='More')])
        for post in posts:
            inlinequery.append(InlineQueryResultPhoto(
                    type='photo',
                    id=uuid4(),
                    photo_url=post['file_url'],
                    photo_width=post['preview_width']*6,
                    photo_height=post['preview_height']*6,
                    #reply_markup=reply_markup,
                    thumb_url=post['preview_url']),)
        bot.answerInlineQuery(update.inline_query.id, results=inlinequery, switch_pm_text="Help", switch_pm_parameter="ihelp")
        inlinequery.clear()
    else:
        client = Pybooru('Yandere')
        posts = client.posts_list(tags=query, limit=50)
        lposts = len(posts)
        inlinequery = list()
        reply_markup = InlineKeyboardMarkup([InlineKeyboardButton("More", callback_data='More')])
        for post in posts:
            inlinequery.append(InlineQueryResultPhoto(
                    type='photo',
                    id=uuid4(),
                    photo_url=post['file_url'],
                    photo_width=post['preview_width']*6,
                    photo_height=post['preview_height']*6,
                    #reply_markup=reply_markup,
                    thumb_url=post['preview_url']),)
        bot.answerInlineQuery(update.inline_query.id, results=inlinequery, switch_pm_text="Help", switch_pm_parameter="ihelp")
        inlinequery.clear()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号