Kaptain.
Telegram /
LinkedIn /
Email /
GIT /
RSS /
GPG /
Заказ печатных плат

№ 9465 В разделе
Programming
от October 21st, 2018,
В подшивках: Python, Telegram
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:
{"chatID":"@radio70logbook","message":"test"}
Example script: send Zabbix notifications to Telegram channel
#!/bin/bash
source /etc/profile
json_escape () {
printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()).strip("\""))'
}
chat_id="-3459475309874"
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:
https://git.blindage.org/21h/telegram-post-bot
Fortune cookie: nullifidian n. & a. (Person) having no religious faith or belief, f. med. L nullifidius fr L nullus none + fides faith; see IAN
Leave a Reply