完善程序并加入Telegram推送(待测试)
This commit is contained in:
parent
24c83b189d
commit
04fb10a51c
12
.github/workflows/AutoSignin.yml
vendored
12
.github/workflows/AutoSignin.yml
vendored
|
@ -27,6 +27,16 @@ jobs:
|
||||||
- name: Install requests #安装requests
|
- name: Install requests #安装requests
|
||||||
run: |
|
run: |
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
- name: set var
|
||||||
|
run: |
|
||||||
|
echo ${{ secrets.cookie }} > cookie.txt
|
||||||
|
echo ${{ secrets.teleid }} > teleid.txt
|
||||||
|
echo ${{ secrets.teletoken }} > teletoken.txt
|
||||||
- name: Run script
|
- name: Run script
|
||||||
run: |
|
run: |
|
||||||
python3 main.py ${{ secrets.cookie }}
|
python3 main.py
|
||||||
|
- name: remove var
|
||||||
|
run: |
|
||||||
|
rm cookie.txt
|
||||||
|
rm teleid.txt
|
||||||
|
rm teletoken.txt
|
||||||
|
|
42
main.py
42
main.py
|
@ -1,10 +1,27 @@
|
||||||
import sys
|
import sys
|
||||||
import requests as r
|
import requests as r
|
||||||
import json
|
import json
|
||||||
|
import telepot
|
||||||
|
|
||||||
|
tele_enable=False
|
||||||
sign='https://n.cg.163.com/api/v2/sign-today'
|
sign='https://n.cg.163.com/api/v2/sign-today'
|
||||||
current='https://n.cg.163.com/api/v2/client-settings/@current'
|
current='https://n.cg.163.com/api/v2/client-settings/@current'
|
||||||
cookie=sys.argv[1]
|
with open('cookie.txt','r') as f:
|
||||||
|
cookie=f.read()
|
||||||
|
f.close
|
||||||
|
|
||||||
|
with open('teleid.txt','r') as f:
|
||||||
|
teleid=f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
with open('teletoken.txt','r') as f:
|
||||||
|
teletoken=f.read()
|
||||||
|
f.close
|
||||||
|
|
||||||
|
if teletoken!='' and teleid!='':
|
||||||
|
tele_enable=True
|
||||||
|
bot=telepot.Bot(teletoken)
|
||||||
|
|
||||||
|
|
||||||
getheader={
|
getheader={
|
||||||
'Host': 'n.cg.163.com',
|
'Host': 'n.cg.163.com',
|
||||||
|
@ -39,7 +56,7 @@ signheader={
|
||||||
'X-Platform': '0'
|
'X-Platform': '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
def post(url,header):
|
def signin(url,header):
|
||||||
result=r.post(url=url,headers=header)
|
result=r.post(url=url,headers=header)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -48,10 +65,21 @@ def getme(url,header):
|
||||||
print(result)
|
print(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
me=getme(current,getheader)
|
me=getme(current,getheader)
|
||||||
print(me.text,end='\n')
|
if(me.status_code!=200):
|
||||||
signin=post(sign,signheader)
|
message='[网易云游戏自动签到]签到失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'
|
||||||
print(signin.text,end='\n')
|
send(teleid,message)
|
||||||
print(signin.status_code)
|
print(message)
|
||||||
|
sys.exit()
|
||||||
|
sign=signin(sign,signheader)
|
||||||
|
if(sign.status_code==200):
|
||||||
|
message='[网易云游戏自动签到]签到成功!'
|
||||||
|
send(teleid,message)
|
||||||
|
print(message)
|
||||||
|
else:
|
||||||
|
message='[网易云游戏自动签到]签到失败,回显状态码为{}\n具体错误信息如下:\n{}'.format(sign.status_code,sign.text)
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
requests
|
requests
|
||||||
|
telepot
|
Loading…
Reference in New Issue
Block a user