2
votes

I have a bot set up in telegram, and a webhook setup to my website. I want to make an automated script which will regularly test the bot by sending messages.

To emulate a telegram message, I used the following curl command:

curl -v -k -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache"  -d '{
"update_id":10000,
"message":{
  "date":1441645532,
  "chat":{
     "last_name":"Test Lastname",
     "id":1111111,
     "type": "private",
     "first_name":"Test Firstname",
     "username":"Testusername"
  },
  "message_id":1365,
  "from":{
     "last_name":"Test Lastname",
     "id":1111111,
     "first_name":"Test Firstname",
     "username":"Testusername"
  },
  "text":"/start"
}
}' "https://YOUR.BOT.URL:YOURPORT/"

This triggered the bot and my bot responded. But, to validate the bot responded or not, I have to check my telegram app. Is there any way that I can automate this process as well?

1

1 Answers

0
votes

You can you python-telegram-bot library instead of sending HTTP requests. And look how they wrote tests for it.