Skip to content

Instantly share code, notes, and snippets.

@abakum
Last active March 20, 2018 05:16
Show Gist options
  • Save abakum/c457f3f53b29ebf3f5eaae90f97d3788 to your computer and use it in GitHub Desktop.
Save abakum/c457f3f53b29ebf3f5eaae90f97d3788 to your computer and use it in GitHub Desktop.
curl+telegram
#!/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=<-"
#!/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=<-"
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=<-"
@abakum
Copy link
Author

abakum commented Mar 12, 2018

Пишем официальному боту @Botfather​ и создаем нового бота — отвечаем на вопросы, получаем [token]
Пишем нашему только что созданному боту, добавляем его в чат и смотрим [chat_id] (например, из url берутся только цифры и в начале ставится минус).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment