INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / RSS / GPG

Python bot for posting notifications to Telegram channels, groups or private

№ 9465 В разделе "Programming" от October 21st, 2018,
В подшивках: ,

This bot can accept messages from another applications through socket file connection and post it to Telegram. You can use it for posting notifications from Git hooks, tasks in cron, weather and another sources.

Sample message:


Example script: send Zabbix notifications to Telegram channel

source /etc/profile

json_escape () {
    printf '%s' "$1" | python -c 'import json,sys; print(json.dumps("\""))'

post_title=$(json_escape "$1")
post_body=$(json_escape "$2")

echo "{\"chatID\":\"${chat_id}\",\"message\":\"${post_title}\n\n${post_body}\"}" | \
    nc -U /run/telegram-GrapeBlessedBot.sock

Source code:

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *



Fortune cookie: "Missionaries are perfect nuisances and leave every place worse than they found it." [Charles Dickens]