Home>
Using official Telegram Bot API
The problem is that when I send a getUpdates request, I get data about a person's message, the message_id in the json response only changes when a person sends a message, what are the official methods to not re-send a response to the "/start" message?
import requests
token= 'TOKEN'
url= f'https://api.telegram.org/bot{token}'
def check_last_message(txt):
message= requests.get(url + '/getUpdates?offset=-1').json()
if message['result'][0]['message']['text']== txt:
chat_id= message['result'][0]['message']['from']['id']
message_id= message['result'][0]['message']['message_id']
return chat_id, message_id
else:
return 0
def send_message(method, chat_id, text):
send= requests.get(url + f'/{method}?chat_id={chat_id}&
text={text}')
print(send.json()['ok'])
def main():
send_message('sendMessage', check_last_message('/start')[0], 'Hello')
if __name__== '__main__':
main()
@Qwertiy no more? Can you somehow update the list of messages? they seem to be removed after 24 hours, but it's a long time.
Robot2022-01-17 20:38:13Related questions
- python : make sure that the buttons are not detected
- python : AttributeError: 'NoneType' object has no attribute 'startswith'
- python : How to transfer the value of a variable from one handler to another. Using FSM
- TypeError: 'list' object is not callable. Literally today I started learning Python and telebot API and I don’t understand what
- python : Sending a file using telegramAPI
- python : Bot on aiogram does not see the answer to someone else's message
- python : How to send a single message in response to the user via bot.send_message
- python : Filter data with pydantic by values
- python : Error with matrix multiplication. Numpy
- Can't uninstall/install Python
DB use...
Qwertiy2022-01-17 20:03:37