A
A
Alexey Samoilov2015-08-25 15:58:41
Python
Alexey Samoilov, 2015-08-25 15:58:41

How to get result in getUpdates Telegram API method?

Good afternoon.

I'm trying to get data using the getUpdates Telegram API method - I found this guide.

I write to my bot - t1Bot
Then I use the method:

import requests
BOT_TOKEN = '132176590:AAE2dUVDjj9epTIIe6KIYtlvvmnc1S-YHSM'

MethodGetUpdates = 'https://api.telegram.org/bot{token}/getUpdates'.format(token=BOT_TOKEN)


while True:
    response = requests.post(MethodGetUpdates)
    result = response.json()
    print result


I get the following result
>>

{u'ok': True, u'result': []}

After all, the result should look like this:
{
"result": [
{
"message": {
"text": "/start",
" date": 1435176541,
"chat": {
"username": "yourusername",
"first_name": "yourfirstname",
"id": 65535
},
-----

But the result is empty.
What am I doing wrong?

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav, 2015-08-25
@crackedmind

What do you write to him and where? If in a group, then by default it accepts messages starting with / and where the name of the bot is mentioned. To accept all text /setprivacy disabled do with BotFather

N
Nikolai Pinevich, 2017-02-07
@Afres

This method returns only new messages. If the bot has already responded to some messages sent to it, then it has already received them (most likely by the same method) and they are marked as received by the Telegram server. Accordingly, they will no longer be returned with each new request, otherwise you would receive the entire message history every time since the bot was created. In this case, you have two options:
Keep a log of messages received by the bot and use it at your discretion.
Play around with the offset parameter of the getUpdates method. More details here: https://core.telegram.org/bots/api#getupdates
For example: https://api.telegram.org/botXXXXXXXXXX/getUpdates?...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question