Merge pull request #2 from GamerNoTitle/serverchan

添加ServerChange推送服务 #1
This commit is contained in:
Pesy Wu 2020-12-05 21:20:03 +08:00 committed by GitHub
commit 2bb4f161c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 5 deletions

View File

@ -29,4 +29,4 @@ jobs:
pip install -r requirements.txt
- name: Run script
run: |
python3 main.py "${{ secrets.cookie }}" "${{ secrets.teleid }}" "${{ secrets.teletoken }}"
python3 main.py "${{ secrets.cookie }}" "${{ secrets.teleid }}" "${{ secrets.teletoken }}" "${{ secrets.SCKEY }}"

View File

@ -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
## 错误代码

27
main.py
View File

@ -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)