How to get an outgoing message ID in telepot module?
<p>I'm using telepot module to create a telegram bot using python.
I need to get the message Id of an outgoing message to be able to check if the user will reply to that message or not. The piece of code below clarifies what I want to do:</p>

<pre><code>import telepot

bot = telepot.Bot('Some Token')

def handle(msg):
    chat_id = msg['chat']['id']
    message_id = msg['message_id']                  # I can get Id of incoming messages here 
    command = msg['text']

    if command == '/command':                       # Message (incoming) 1 sent by user
        bot.sendMessage(chat_id, 'Some message')    # Message (outgoing) 2 sent by bot

    elif ('''msg was in reply of message 2'''):     # Message (incoming) 3 sent by user    (MY PROBLEM IS HERE!!!)
        # Do something
        pass


bot.message_loop(handle, run_forever = 'Running ...')
</code></pre>

<p>So as you can see in the code above I need to check if message 3 was in reply to message 2. However, I can't get the ID of message 2 because it's an outgoing message from bot (Not an incoming message by user which I can get it's ID).
So how can I achieve that?</p>

<p>thanks.</p>

<p>You should be able to get <code>message_id</code> of the sent message:</p>

<pre><code>&gt;&gt;&gt; import telepot
&gt;&gt;&gt; from pprint import pprint
&gt;&gt;&gt; bot = telepot.Bot('TOKEN')
&gt;&gt;&gt; sent = bot.sendMessage(9999999, 'Hello')
&gt;&gt;&gt; pprint(sent)
{u'chat': {u'first_name': u'Nick', u'id': 9999999, u'type': u'private'},
 u'date': 1473567584,
 u'from': {u'first_name': u'My Bot',
           u'id': 111111111,
           u'username': u'MyBot'},
 u'message_id': 21756,
 u'text': u'Hello'}
</code></pre>

python telegram telegram-bot python-telegram-bot