Automated messages to the Telegram bot using curl or script
Initial Steps
Open Telegram App
Go to botfather and create a new bot
Create a chat group and add the bot to it
Post creating bot you would have got the botid:auth-token
Open URL
$ TELEGRAM_BOT_TOKEN=your-bot-id:your-auth-token $ curl https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates | jq .message.chat.id
Sending message using curl
$ curl -X POST -H ‘Content-Type: application/json’ -d ‘{“chat_id”: “
SEND MESSAGE FROM SHELL
import requests
# telegram url
telegramURL = 'https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/'
def send_message(msgText):
params = {'chat_id':<CHATID-FROM-PREVIOUS-STEP>, 'text': msgText}
response = requests.post(telegramURL + 'sendMessage', data=params)
return response
send_message("Hello! World")