Created
September 25, 2018 20:49
-
-
Save timoteoramos/260b6e8cdd1496555d5e0750ae38e954 to your computer and use it in GitHub Desktop.
telegram-stdout.py
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
#!/usr/bin/python3 | |
# Remember to install the pyBotTelegramAPI package (usually from pip) | |
# It should works with Python 3.4 and above | |
import telebot, socket, subprocess, sys | |
BOT_TOKEN='<YOUR BOT TOKEN>' | |
DESTINATION='<DESTINATION ID>' | |
cmd = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE) | |
out, err = cmd.communicate() | |
tb = telebot.TeleBot(BOT_TOKEN) | |
tb.send_message(DESTINATION, '<b>%s#</b> %s\n\n<pre>%s</pre>' % (socket.gethostname(), ' '.join(sys.argv[1:]), out.decode('utf-8')), parse_mode='HTML') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment