Why if the id = '0' in "InlineQueryResultArticle" the element chosen doesn't trigger the "on_chosen_inline_result" code?
<p>I'm new to Python and new to Stack Overflow, sorry for my mistakes...</p>

<p>I'm using Telepot to write a bot for Telegram.<br>
When dealing with inline results I can only make the code in <code>on_chosen_inline_result</code> execute for every article I choose other than the first created.</p>

<pre><code>def on_inline_query(msg):
    query_id, from_id, query_string = telepot.glance(msg, flavor='inline_query')
    tastiera_inline = InlineKeyboardMarkup(*some_keyboard*)

    articles = []

    if query_string:

        found_conte = fun.get_conta(titolo=query_string)
        if found_conte == 1:
            return
        for conta_inline in found_conte:
            articles.append(InlineQueryResultArticle(
                id=str(conta_inline['id']),
                title=conta_inline['titolo'],
                input_message_content=InputTextMessageContent(*some_content*),
                reply_markup=tastiera_inline,
                description=conta_inline['testo'],
                thumb_url=*some_url*,
            ))

    else:
        if fun.get_conta('all') == 1:
            return
        for conta_inline in fun.get_conta('all'):
            articles.append(InlineQueryResultArticle(
                id=str(conta_inline['id']),
                title=conta_inline['titolo'],
            input_message_content=InputTextMessageContent(*some_content*),
            reply_markup=tastiera_inline,
            description=conta_inline['testo'],
            thumb_url=*some_url*,
        ))

     bot.answerInlineQuery(query_id, articles)


def on_chosen_inline_result(msg):  

    print(msg)


bot = telepot.Bot(TOKEN)

bot.message_loop({'chat': on_chat_message,
              'inline_query': on_inline_query,
              'chosen_inline_result': on_chosen_inline_result
              },
             run_forever='Listening ...')  
</code></pre>

<p><code>print(msg)</code> is working fine for every article I choose from the list of answers to the inline query except for the first one created.
I am really confused...</p>

<p>What is really confusing is that I don't think to have the control on what happens when I choose an article from the list in Telegram, so it seems strange that sometimes it triggers the <code>on_chosen_inline_result</code> code and other times it doesn't. </p>

<p>EDIT: It seems like if <code>id='0'</code> in <code>InlineQueryResultArticle</code> the chosen result doesn't trigger the code inside <code>on_chosen_inline_result</code>, but I'm not 100% sure this is the cause, and I really don't know why, anyway...</p>

<p>PS: I don't know how much code is needed to understand the problem without copying everything here. I can surely edit the question and add more code if needed.</p>

<p>From my own test, it seems your suspicion is correct. I have tried a variety of id strings and chosen each of them in turn:</p>

<ul>
<li><code>00</code> â Yes (<code>chosen_inline_result</code> gotten)</li>
<li><code>$0</code> â Yes</li>
<li><code>0</code> â No</li>
<li><code>1</code> â Yes</li>
</ul>

<p>As the author of telepot, I can't think of anywhere a result id of <code>0</code> may get filtered out inadvertently. So I am presuming it's a Telegram issue.</p>

<p>As illustrated above, it's easy to get around. You can prepend almost any character in front to get back the <code>chosen_inline_result</code>.</p>

<p>In case anyone is interested, here's my testing code:</p>

<pre><code>import sys
import threading
import telepot
from telepot.namedtuple import InlineQueryResultArticle, InputTextMessageContent

def on_inline_query(msg):
    def compute():
        query_id, from_id, query_string = telepot.glance(msg, flavor='inline_query')
        print('%s: Computing for: %s' % (threading.current_thread().name, query_string))

        articles = [InlineQueryResultArticle(
                        id='00', title='ID=00',
                        input_message_content=InputTextMessageContent(
                            message_text='ID=00')),
                    InlineQueryResultArticle(
                        id='$0', title='ID=$0',
                        input_message_content=InputTextMessageContent(
                            message_text='ID=$0')),
                    InlineQueryResultArticle(
                        id='0', title='ID=0',
                        input_message_content=InputTextMessageContent(
                            message_text='ID=0')),
                    InlineQueryResultArticle(
                        id='1', title='ID=1',
                        input_message_content=InputTextMessageContent(
                            message_text='ID=1')),]

        return dict(results=articles)

    answerer.answer(msg, compute)

def on_chosen_inline_result(msg):
    result_id, from_id, query_string = telepot.glance(msg, flavor='chosen_inline_result')
    print('Chosen Inline Result:', result_id, from_id, query_string)

TOKEN = sys.argv[1]  # get token from command-line

bot = telepot.Bot(TOKEN)
answerer = telepot.helper.Answerer(bot)

bot.message_loop({'inline_query': on_inline_query,
                  'chosen_inline_result': on_chosen_inline_result},
                 run_forever='Listening ...')
</code></pre>

python telegram-bot