Last active
January 18, 2019 04:29
-
-
Save wolterlw/4c08cee2bb87c2a84f32718e3d93e5e7 to your computer and use it in GitHub Desktop.
Minimal bash script to push messages to telegram via bot API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. create a bot using @BotFather | |
# 2. create a public channel, add the bot as it's administrator | |
# 3. fill in the required information below | |
# 4. do a test run. In the response there will be a chat_id, which is a bunch of numbers | |
# now it's possible to make the channel private and use chat_id instead of the public name | |
bot_token=#YOUR_BOT_TOKEN | |
chat_id=#UR_CHANNEL_ID | |
api_call="https://api.telegram.org/bot$bot_token/sendMessage" | |
curl \ | |
--data-urlencode "chat_id=$chat_id" \ | |
--data-urlencode "text=$@" \ | |
$api_call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment