From 1b94f4d1ee38c8db44d01a34578b786d56b77e7c Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Fri, 4 Dec 2020 17:47:09 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9E=84=E5=BB=BAServerChan=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=87=BD=E6=95=B0=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 53b2462..ea2d634 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,28 @@ 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/{SCKEY}.send?text=网易云游戏自动签到脚本&desp={message}' + if sc_enable: + r.get(url=sc_url) + 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() 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() From 51e9ba08cd8481773522bd0c8393fcf53519c185 Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Sat, 5 Dec 2020 18:51:58 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=8A=A0=E5=85=A5ServerChan=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index ea2d634..6d57ebd 100644 --- a/main.py +++ b/main.py @@ -67,7 +67,7 @@ def send(id,message): 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/{SCKEY}.send?text=网易云游戏自动签到脚本&desp={message}' + sc_url='http://sc.ftqq.com/{}.send?text=网易云游戏自动签到脚本&desp={}'.format(SCKEY,message) if sc_enable: r.get(url=sc_url) From 6e5e21de811c84b7e91dfdf392cb3e335f93da4e Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Sat, 5 Dec 2020 19:15:12 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=AE=8C=E5=96=84ServerChan=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/AutoSignin.yml | 2 +- README.md | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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 281e695..334e4e1 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ![](https://upimage.alexhchu.com/2020/11/22/e9b4bcf8e6a1d.png) -2、进入设置,设置变量`cookie`和`teleid` `teletoken`(这两个可选) +2、进入设置,设置变量`cookie`和`teleid` `teletoken` `SCKEY`(这三个可选) [如何获取变量内容?请点这里](#变量内容获取) @@ -73,6 +73,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 ### 出现错误 telepot.exception.TelegramError From a698297365771694879a183bcbf0dbaa082de7dd Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Sat, 5 Dec 2020 19:15:12 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=AE=8C=E5=96=84ServerChan=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/AutoSignin.yml | 2 +- README.md | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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 281e695..334e4e1 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ![](https://upimage.alexhchu.com/2020/11/22/e9b4bcf8e6a1d.png) -2、进入设置,设置变量`cookie`和`teleid` `teletoken`(这两个可选) +2、进入设置,设置变量`cookie`和`teleid` `teletoken` `SCKEY`(这三个可选) [如何获取变量内容?请点这里](#变量内容获取) @@ -73,6 +73,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 ### 出现错误 telepot.exception.TelegramError From 88ca48f4f7f163aea66bdeef15dfe5a16fa5e526 Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Sat, 5 Dec 2020 19:47:07 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=B9=B6=E6=8E=A8=E9=80=81=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6d57ebd..d1a17c1 100644 --- a/main.py +++ b/main.py @@ -71,6 +71,10 @@ def scsend(SCKEY,message): if sc_enable: r.get(url=sc_url) +class ScriptError(Exception): + print("[网易云游戏自动签到]脚本发生错误,请查看运行记录!") + + if __name__ == "__main__": me=getme(current,getheader) if(me.status_code!=200): @@ -78,7 +82,7 @@ if __name__ == "__main__": send(teleid,message) scsend(sckey,message) print(message) - sys.exit() + raise ScriptError sign=signin(sign,signheader) if(sign.status_code==200): message='[网易云游戏自动签到]签到成功!' @@ -90,4 +94,4 @@ if __name__ == "__main__": send(teleid,message) scsend(sckey,message) print(message) - sys.exit() + raise(ScriptError) From d26cc6ec20487dbd218a6dc35a41d16a165cd368 Mon Sep 17 00:00:00 2001 From: GamerNoTitle Date: Sat, 5 Dec 2020 20:39:14 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=87=8D=E6=96=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index d1a17c1..7fcbf58 100644 --- a/main.py +++ b/main.py @@ -72,7 +72,13 @@ def scsend(SCKEY,message): r.get(url=sc_url) class ScriptError(Exception): - print("[网易云游戏自动签到]脚本发生错误,请查看运行记录!") + pass + +class GetInfoError(ScriptError): + pass + +class CheckInError(ScriptError): + pass if __name__ == "__main__": @@ -82,7 +88,7 @@ if __name__ == "__main__": send(teleid,message) scsend(sckey,message) print(message) - raise ScriptError + raise GetInfoError sign=signin(sign,signheader) if(sign.status_code==200): message='[网易云游戏自动签到]签到成功!' @@ -94,4 +100,4 @@ if __name__ == "__main__": send(teleid,message) scsend(sckey,message) print(message) - raise(ScriptError) + raise(CheckInError)