diff --git a/.github/workflows/AutoSignin.yml b/.github/workflows/AutoSignin.yml index 54a2450..7ca56fa 100644 --- a/.github/workflows/AutoSignin.yml +++ b/.github/workflows/AutoSignin.yml @@ -29,4 +29,4 @@ jobs: pip install -r requirements.txt - name: Run script run: | - python3 main.py "${{ secrets.cookie }}" "${{ secrets.teleid }}" "${{ secrets.teletoken }}" \ No newline at end of file + python3 main.py "${{ secrets.cookie }}" "${{ secrets.teleid }}" "${{ secrets.teletoken }}" "${{ secrets.SCKEY }}" \ No newline at end of file diff --git a/README.md b/README.md index 137d19d..81d1c9b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ![](https://upimage.alexhchu.com/2020/11/22/e9b4bcf8e6a1d.png) -2、进入设置,设置变量`cookie`和`teleid` `teletoken`(这两个可选) +2、进入设置,设置变量`cookie`和`teleid` `teletoken` `SCKEY`(这三个可选) [如何获取变量内容?请点这里](#变量内容获取) @@ -75,6 +75,12 @@ ![](https://upimage.alexhchu.com/2020/11/22/0428751a3925e.png) +### SCKEY获取 + +访问[ServerChan官网](http://sc.ftqq.com/?c=code),用你的Github账户登录,在`发送信息`可以看到你的SCKEY + +![](https://upimage.alexhchu.com/2020/12/05/dff25704763d8.png) + ## Q&A ## 错误代码 diff --git a/main.py b/main.py index 53b2462..7fcbf58 100644 --- a/main.py +++ b/main.py @@ -4,19 +4,22 @@ import json import telepot tele_enable=False +sc_enable=False sign='https://n.cg.163.com/api/v2/sign-today' current='https://n.cg.163.com/api/v2/client-settings/@current' cookie=sys.argv[1] teleid=sys.argv[2] teletoken=sys.argv[3] +sckey=sys.argv[4] if cookie=="": print('[网易云游戏自动签到]未设置cookie,正在退出……') sys.exit() if teleid!="" and teletoken!="": tele_enable=True bot=telepot.Bot(teletoken) - +if sckey!="": + sc_enable=True getheader={ 'Host': 'n.cg.163.com', @@ -63,20 +66,38 @@ def send(id,message): if tele_enable: bot.sendMessage(id, message, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None) +def scsend(SCKEY,message): + sc_url='http://sc.ftqq.com/{}.send?text=网易云游戏自动签到脚本&desp={}'.format(SCKEY,message) + if sc_enable: + r.get(url=sc_url) + +class ScriptError(Exception): + pass + +class GetInfoError(ScriptError): + pass + +class CheckInError(ScriptError): + pass + + if __name__ == "__main__": me=getme(current,getheader) if(me.status_code!=200): message='[网易云游戏自动签到]验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue' send(teleid,message) + scsend(sckey,message) print(message) - sys.exit() + raise GetInfoError sign=signin(sign,signheader) if(sign.status_code==200): message='[网易云游戏自动签到]签到成功!' send(teleid,message) + scsend(sckey,message) print(message) else: message='[网易云游戏自动签到]签到失败,回显状态码为{}\n具体错误信息如下:\n{}'.format(sign.status_code,sign.text) send(teleid,message) + scsend(sckey,message) print(message) - sys.exit() + raise(CheckInError)