Skip to content

Instantly share code, notes, and snippets.

@xdtianyu
Last active May 31, 2017 03:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save xdtianyu/9be47aac3ab530e66f5bd2008a9df90a to your computer and use it in GitHub Desktop.
Save xdtianyu/9be47aac3ab530e66f5bd2008a9df90a to your computer and use it in GitHub Desktop.
TOKEN = 'xx:xx-xx'
CHAT_ID = 'xxx'
#!/bin/bash
cmd="$@"
C=''
for i in "$@"; do
case "$i" in
*\'*)
i=`printf "%s" "$i" | sed "s/'/'\"'\"'/g"`
;;
*) : ;;
esac
C="$C '$i'"
done
eval "$C"
/opt/watcher/venv/bin/python /opt/watcher/tel.py "$cmd" completed.
#!/usr/bin/env python2
import telegram
import config
def tel(message):
if len(message) > 0:
bot = telegram.Bot(config.TOKEN)
bot.sendMessage(config.CHAT_ID, message)
if __name__ == "__main__":
import sys
tel(' '.join(str(x) for x in sys.argv[1:]))
@xdtianyu
Copy link
Author

tel sleep 30

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