import itchat
import os
usageMsg = u"使用方法:\n1.运行CMD命令:xxx (xxx为命令)\n" \
u"-例如关机命令:\nshutdown -s -t 0 \n" \
u"2.启用命令助手(默认开启):ast\n" \
u"3.关闭命令助手:astc"
flag = 1 #消息助手开关
@itchat.msg_register('Text')
def text_reply(msg):
global flag
message = msg['Text']
fromName = msg['FromUserName']
toName = msg['ToUserName']
if toName == "filehelper":
if flag==0:
if message == "ast":
flag = 1
itchat.send("命令助手已开启", "filehelper")
elif flag==1:
if message == "astc":
flag = 0
itchat.send("命令助手已关闭", "filehelper")
if message=="cmd":
flag=2
itchat.send("cmd命令已开启", "filehelper")
elif flag == 2:
os.system(message)
else:
pass
# itchat.send("123", fromName)
if __name__ == '__main__':
itchat.auto_login(hotReload=True)
itchat.send(usageMsg, "filehelper")
itchat.run()