meysam
meysam

Reputation: 21

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

I have a function that takes a string and searches it in the dictionary and then returns the result as a string. I searched a lot but I could not learn how to show the output of the function to the user using the inline method. I use the python-telegram-bot library. This is the code I wrote to return the result of the response function.

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)

I want the query result to be received as an inline bot. Sometimes it works but this error appears :

root - ERROR - Update {'inline_query': {'id': '701438966003659473', 'offset': '', 'query': '1322008', 'chat_type': 'private', 'from': {'is_bot': False, 'id': 1633163216, 'first_name': '', 'username': '', 'language_code': 'fa'}}, 'update_id': 331490925} caused error Can't parse inline query result: input message content is not specified

Upvotes: 0

Views: 1064

Answers (1)

meysam
meysam

Reputation: 21

The problem was with my response function, which sometimes returned None type ...

Upvotes: 0

Related Questions