使用微信远程开启自己的服务器

笔者的环境大概是这样的,家里有一台NAS常年开机,一台装有显卡的台式机有时候需要启动来跑一些深度学习的任务,最近做了一个微信机器人号,基于itchat,可以随时远程打开电脑。代码如下:

#coding=utf8
import os
import itchat, time
from itchat.content import *

@itchat.msg_register([TEXT])
def text_reply(msg):
    print msg['Text'], msg['FromUserName']
    if msg['Text']=="open":
        if msg['FromUserName']=='@3dd409049295bf9b52d7e7708f75d40ba15229a9556eaea85c8c5a45e9e7f20e':
            os.system("./openComputer.sh")
            itchat.send("ok", msg['FromUserName'])
itchat.auto_login(enableCmdQR=2, hotReload=True)

itchat.run()

此外,知乎上还有一篇用微信来远程调参的文章,但是微信登录实在是不稳定,就此作罢。