-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (27 loc) · 969 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from time import sleep
from telepot import Bot
from wakeonlan import send_magic_packet
from config import *
HELP_MESSAGE = """type turnon <pc name> to turn on a pc, \ntype list to see the list of pc"""
def manage(msg):
global run
text = msg['text'] . strip() . split(" ")
command = text[0] . lower()
if command == "help":
bot.sendMessage(user_id, HELP_MESSAGE)
elif command == "list":
bot.sendMessage(user_id, list(hosts.keys()))
elif command == "turnon":
pc = text[1]
if pc in hosts:
send_magic_packet(hosts[pc])
bot.sendMessage(user_id, "Turned on " + pc)
else:
bot.sendMessage(user_id, "Invalid pc name")
else:
bot.sendMessage(user_id, "Invalid command")
bot = Bot(addressBot)
bot.message_loop(manage)
bot.sendMessage(user_id, "Hi, type help to see the commands")
while True:
sleep(600)