-
Notifications
You must be signed in to change notification settings - Fork 83
/
Locker
37 lines (32 loc) · 1.1 KB
/
Locker
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
33
34
35
36
37
# -*- coding: utf-8-*-
# 关闭系统插件
import logging
import sys
import time
import subprocess
import httplib
reload(sys)
sys.setdefaultencoding('utf8')
WORDS = ["GUANDENG"]
SLUG = "halt"
def handle(text, mic, profile, wxbot=None):
logger = logging.getLogger(__name__)
try:
mic.say('将要关闭系统', cache=True)
# input = mic.activeListen(MUSIC=True)
# if input is not None and any(word in input for word in [u"确认", u"好", u"是", u"OK"]):
mic.say('授权成功,开始连接百度', cache=True)
time.sleep(3)
http_client=httplib.HTTPConnection('baidu.com',80,timeout=20)
http_client.request('GET','')
r=http_client.getresponse()
print r.status
print r.read()
# subprocess.Popen("shutdown -h now", shell=True)
# return
# mic.say('授权失败,操作已取消,请重新尝试', cache=True)
except Exception, e:
logger.error(e)
mic.say('抱歉,关闭系统失败', cache=True)
def isValid(text):
return any(word in text for word in [u"关机", u"关闭系统"])