python-telegram-bot 错误内联:未指定输入消息内容

python-telegram-bot error inline : input message content is not specified

我有一个函数,它接受一个字符串并在字典中搜索它,然后 return 将结果作为字符串。我搜索了很多,但无法了解如何使用内联方法向用户显示函数的输出。 我使用 python-telegram-bot 库。这是我写的代码return响应函数的结果。

def inlinequery(update, context: CallbackContext) :
    query = update.inline_query.query
    if query == "":
        return

    results = [
        InlineQueryResultArticle(
            id=str(uuid4()),
            title="find this class code",
            description='example 1322008',
            input_message_content=InputTextMessageContent(
                response(query)
            )
        )
    ]
    update.inline_query.answer(results)

我希望查询结果作为内联机器人接收。有时它有效但出现此错误:

root - 错误 - 更新 {'inline_query': {'id': '701438966003659473', 'offset': '', 'query': '1322008', 'chat_type': 'private', 'from': {'is_bot': 假, 'id': 1633163216, 'first_name': '', 'username': '', 'language_code': 'fa'}}, 'update_id': 331490925} 导致错误无法解析内联查询结果:未指定输入消息内容

问题出在我的响应函数上,它有时会返回 None 类型 ...