This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
сервис_telegram [2025/06/10 08:52] val |
сервис_telegram [2025/10/13 16:32] (current) val |
||
---|---|---|---|
Line 2: | Line 2: | ||
* [[https://linuxscriptshub.com/send-telegram-message-linux-scripts/]] | * [[https://linuxscriptshub.com/send-telegram-message-linux-scripts/]] | ||
+ | * [[https://core.telegram.org/bots/tutorial|From BotFather to 'Hello World']] | ||
+ | * [[https://dev.to/nathannosudo/bash-script-to-send-a-message-in-telegram-from-your-terminal-20c7|Bash Script to Send a Message in Telegram from your Terminal!]] | ||
+ | * [[https://stackoverflow.com/questions/32423837/telegram-bot-how-to-get-a-group-chat-id|Telegram Bot - how to get a group chat id?]] | ||
<code> | <code> | ||
+ | BotFather | ||
+ | |||
+ | /newbot | ||
+ | |||
+ | choose name: Val spec N | ||
+ | |||
+ | choose username: ValspecNbot | ||
+ | |||
+ | ... | ||
+ | You will find it at t.me/Valspec2bot | ||
+ | ... | ||
+ | Use this token to access the HTTP API: | ||
+ | NNNNNNNNNNNN:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
+ | ... | ||
+ | </code><code> | ||
+ | t.me/ValspecNbot | ||
+ | |||
+ | /start | ||
+ | |||
+ | test | ||
+ | ... | ||
+ | </code><code> | ||
+ | https://api.telegram.org/botNNNNNNNNNNNN:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM/getUpdates | ||
+ | </code><code> | ||
+ | ... | ||
+ | "chat": { | ||
+ | "id": YYYYYYYYYY | ||
+ | ... | ||
+ | </code><code> | ||
$ cat send-to-telegram.sh | $ cat send-to-telegram.sh | ||
</code><code> | </code><code> | ||
Line 9: | Line 41: | ||
[ "$1" ] && MESSAGE=$1 || MESSAGE="Hello, world!" | [ "$1" ] && MESSAGE=$1 || MESSAGE="Hello, world!" | ||
- | TOKEN="768604181156:AAGB1Qwvd-DAPhFbQiMKR3InggtIvPPEtT8" | + | #MESSAGE=$(cat) |
- | CHAT_ID="1776721761" | + | |
+ | TOKEN="NNNNNNNNNNNN:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" | ||
+ | CHAT_ID="YYYYYYYYYY" | ||
curl -s -X POST https://api.telegram.org/bot$TOKEN/sendMessage -d chat_id=$CHAT_ID -d text="$MESSAGE" | curl -s -X POST https://api.telegram.org/bot$TOKEN/sendMessage -d chat_id=$CHAT_ID -d text="$MESSAGE" | ||
+ | </code><code> | ||
+ | $ time sudo ipa-server-install; ./send-to-telegram.sh FINISH | ||
+ | </code> | ||
+ | |||
+ | * [[Использование библиотеки PAM#Использование pam_exec для регистрации подключений]] | ||
+ | <code> | ||
+ | debian:~# chmod 700 /usr/local/bin/send-to-telegram.sh | ||
+ | </code><code> | ||
+ | BotFather | ||
+ | |||
+ | ### /mybots | ||
+ | ### /deletebot | ||
+ | ... | ||
</code> | </code> |