Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, datetime
- import subprocess
- import os
- import telepot
- from telepot.loop import MessageLoop
- from telepot.namedtuple import ReplyKeyboardMarkup
- #libraties
- now = datetime.datetime.now()
- def handle(msg):
- chat_id = msg['chat']['id'] # Receiving the message from telegram
- command = msg['text'] # Getting text from the message
- markup = ReplyKeyboardMarkup(keyboard=[['Snapshot','HTPC']], one_time_keyboard=False, resize_keyboard=True)
- print ('Received:')
- print(command)
- #commands
- if command == '/start':
- bot.sendMessage(chat_id, 'What can I do for you?', reply_markup=markup)
- if command == '/hi':
- bot.sendMessage (chat_id, str("Hi! Shufflepanda"))
- elif command == '/time':
- bot.sendMessage (chat_id, str(now))
- elif command == 'Snapshot':
- subprocess.call(['/home/A11BoxPr0jectAdm/telepot/send_camshot.sh'])
- elif command == '/snapshot':
- subprocess.call(['/home/A11BoxPr0jectAdm/telepot/send_camshot.sh'])
- elif command == '/entree':
- os.system ('curl -s "http://192.168.1.30:8702/json.htm?type=command¶m=switchscene&idx=3&switchcmd=Toggle"')
- elif command == '/salon':
- os.system ('curl -s "http://192.168.1.30:8702/json.htm?type=command¶m=switchscene&idx=2&switchcmd=Toggle"')
- elif command == 'HTPC':
- os.system ('curl -s "http://192.168.1.30:8702/json.htm?type=command¶m=switchlight&idx=5&switchcmd=Toggle"')
- os.system ('curl -s "http://192.168.1.30:8702/json.htm?type=command¶m=switchlight&idx=5&switchcmd=Toggle"')
- bot = telepot.Bot('put.your.telegram.bot.ID')
- MessageLoop(bot, handle).run_as_thread()
- print ('I am listening ...')
- while 1:
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment