How to create a “Bash” Telegram Bot in 2 minutes in 5 lines
海豹
About me
Code
1 while true
2 do
3 who=`who` && [ $? -eq 0 ] && [ "$who" != "$lastwho" ] && curl --data "chat_id=80973595&text=$who" -X GET https://api.telegram.org/bot_token/sendMessage && lastwho=$who
4 sleep 1
5 done
Compressed
while true; do; who=`who` && [ $? -eq 0 ] && [ "$who" != "$lastwho" ] && curl --data "chat_id=80973595&text=$who" -X GET https://api.telegram.org/bot_token/sendMessage && lastwho=$who; sleep 1; done
1. Prepare Bot Token
Telegram: @botfather
Live Demo
2. Get Your User ID
Telegram: @RawDataBot
Live Demo
3. Fetch Your Data
who=`who`
4. Comparing Your Data
[ $? -eq 0 ] && [ "$who" != "$lastwho" ]
5. Send the Message
curl --data "chat_id=id&text=$who" -X GET https://api.telegram.org/bot_token/sendMessage
6. Put it in a Loop
While true�do
done
7. Run it in tmux
Live Demo
Thanks For Listening