Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- import datetime
- import telepot
- from subprocess import call
- import subprocess
- import os
- from telepot.loop import MessageLoop
- def handle(msg):
- chat_id = msg['chat']['id']
- command = msg['text']
- print ('Got command: %s')%command
- if command == '/time':
- bot.sendMessage(chat_id, str(datetime.datetime.now()))
- elif command == '/speed':
- x = subprocess.check_output(['speedtest-cli','--share'])
- bot.sendMessage(chat_id,x)
- elif command == '/ip':
- x = subprocess.check_output(['curl','ipinfo.io/ip'])
- bot.sendMessage(chat_id,x)
- elif command == '/disk':
- x = subprocess.check_output(['df'])
- bot.sendMessage(chat_id,x)
- elif command == '/mem':
- x = subprocess.check_output(['cat','/proc/meminfo'])
- bot.sendMessage(chat_id,x)
- elif command == '/stat':
- bot.sendMessage(chat_id,'Number five is alive!')
- elif command == '/ddns':
- x = subprocess.check_output(['python','/opt/telepi/ddns.py'])
- bot.sendMessage(chat_id,x)
- elif command == '/services':
- x = subprocess.check_output('service --status-all|grep "+"', shell = True)
- bot.sendMessage(chat_id,x)
- bot = telepot.Bot('*** your telebot token from step 2*********')
- MessageLoop(bot, handle).run_as_thread()
- print('I am listening ...')
- while 1:
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement