Last active
March 20, 2018 05:16
-
-
Save abakum/c457f3f53b29ebf3f5eaae90f97d3788 to your computer and use it in GitHub Desktop.
curl+telegram
This file contains hidden or 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/sh | |
# your data here | |
chatID=-123456789 | |
botToken=987654321:AABBCCDDEEFFGGHH | |
# post photo | |
photo="$1" | |
shift | |
( | |
for x | |
do | |
echo $x | |
done | |
)|curl -s "https://api.telegram.org/bot"$botToken"/sendPhoto" -F chat_id=$chatID -F "photo=@$photo" -F "caption=<-" |
This file contains hidden or 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/sh | |
# your data here | |
chatID=-123456789 | |
botToken=987654321:AABBCCDDEEFFGGHH | |
# post message | |
( | |
for x | |
do | |
echo $x | |
done | |
)|curl -s "https://api.telegram.org/bot"$botToken"/sendMessage" -F chat_id=$chatID -F "text=<-" | |
This file contains hidden or 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
chcp 65001 | |
# your data here | |
chatID=-123456789 | |
botToken=987654321:AABBCCDDEEFFGGHH | |
:echo ^{^"chat_id^": ^"%chatID%^", ^"text^": ^"мама\nмыла\nраму^"^}|curl -s -H "Content-Type: application/json; charset=UTF-8" -d @- https://api.telegram.org/bot%botToken%/sendMessage | |
( | |
for %%x in (%*) do echo %%~x | |
)|curl -s https://api.telegram.org/bot%botToken%/sendMessage -F chat_id=%chatID% -F "text=<-" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Пишем официальному боту @Botfather и создаем нового бота — отвечаем на вопросы, получаем [token]
Пишем нашему только что созданному боту, добавляем его в чат и смотрим [chat_id] (например, из url берутся только цифры и в начале ставится минус).