commit
4dc5aac500
130
main.py
130
main.py
|
@ -8,11 +8,11 @@ sc_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]
|
cookies=sys.argv[1].split('#')
|
||||||
teleid=sys.argv[2]
|
teleid=sys.argv[2]
|
||||||
teletoken=sys.argv[3]
|
teletoken=sys.argv[3]
|
||||||
sckey=sys.argv[4]
|
sckey=sys.argv[4]
|
||||||
if cookie=="":
|
if cookies=="":
|
||||||
print('[网易云游戏自动签到]未设置cookie,正在退出……')
|
print('[网易云游戏自动签到]未设置cookie,正在退出……')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if teleid!="" and teletoken!="":
|
if teleid!="" and teletoken!="":
|
||||||
|
@ -21,23 +21,11 @@ if teleid!="" and teletoken!="":
|
||||||
if sckey!="":
|
if sckey!="":
|
||||||
sc_enable=True
|
sc_enable=True
|
||||||
|
|
||||||
getheader={
|
class Error(Exception):
|
||||||
'Host': 'n.cg.163.com',
|
pass
|
||||||
'Connection': 'keep-alive',
|
|
||||||
'Accept': 'application/json, text/plain, */*',
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
|
|
||||||
'X-Platform': '0',
|
|
||||||
'Authorization': str(cookie),
|
|
||||||
'Origin': 'https://cg.163.com',
|
|
||||||
'Sec-Fetch-Site': 'same-site',
|
|
||||||
'Sec-Fetch-Mode': 'cors',
|
|
||||||
'Sec-Fetch-Dest': 'empty',
|
|
||||||
'Referer': 'https://cg.163.com/',
|
|
||||||
'Accept-Encoding': 'gzip, deflate, br',
|
|
||||||
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5'
|
|
||||||
}
|
|
||||||
|
|
||||||
signheader={
|
def signin(url,cookie):
|
||||||
|
header={
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'Accept-Encoding': 'gzip, deflate, br',
|
'Accept-Encoding': 'gzip, deflate, br',
|
||||||
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
|
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
|
||||||
|
@ -54,11 +42,25 @@ signheader={
|
||||||
'X-Platform': '0'
|
'X-Platform': '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
def signin(url,header):
|
|
||||||
result=r.post(url=url,headers=header)
|
result=r.post(url=url,headers=header)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getme(url,header):
|
def getme(url,cookie):
|
||||||
|
header={
|
||||||
|
'Host': 'n.cg.163.com',
|
||||||
|
'Connection': 'keep-alive',
|
||||||
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
|
||||||
|
'X-Platform': '0',
|
||||||
|
'Authorization': str(cookie),
|
||||||
|
'Origin': 'https://cg.163.com',
|
||||||
|
'Sec-Fetch-Site': 'same-site',
|
||||||
|
'Sec-Fetch-Mode': 'cors',
|
||||||
|
'Sec-Fetch-Dest': 'empty',
|
||||||
|
'Referer': 'https://cg.163.com/',
|
||||||
|
'Accept-Encoding': 'gzip, deflate, br',
|
||||||
|
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5'
|
||||||
|
}
|
||||||
result=r.get(url=url,headers=header)
|
result=r.get(url=url,headers=header)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -71,33 +73,65 @@ def scsend(SCKEY,message):
|
||||||
if sc_enable:
|
if sc_enable:
|
||||||
r.get(url=sc_url)
|
r.get(url=sc_url)
|
||||||
|
|
||||||
class ScriptError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class GetInfoError(ScriptError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class CheckInError(ScriptError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
me=getme(current,getheader)
|
success=[]
|
||||||
if(me.status_code!=200):
|
failure=[]
|
||||||
message='[网易云游戏自动签到]验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'
|
msg=[]
|
||||||
send(teleid,message)
|
print(len(cookies))
|
||||||
scsend(sckey,message)
|
for i in cookies:
|
||||||
print(message)
|
print(i)
|
||||||
raise GetInfoError
|
cookie=i
|
||||||
sign=signin(sign,signheader)
|
autherror=False
|
||||||
|
signerror=False
|
||||||
|
try:
|
||||||
|
me=getme(current,cookie)
|
||||||
|
except:
|
||||||
|
message='第{}个账号验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'.format(cookies.index(i)+1)
|
||||||
|
failure.append(cookie)
|
||||||
|
msg.append(message)
|
||||||
|
autherror=True
|
||||||
|
|
||||||
|
if(me.status_code!=200 and autherror!=True):
|
||||||
|
message='第{}个账号验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'.format(cookies.index(i)+1)
|
||||||
|
failure.append(cookie)
|
||||||
|
msg.append(message)
|
||||||
|
|
||||||
|
try:
|
||||||
|
sign=signin(sign,cookie)
|
||||||
|
except:
|
||||||
|
message='第{}个账号签到失败,回显状态码为{},具体错误信息如下:{}'.format(cookies.index(i)+1,sign.status_code,sign.text)
|
||||||
|
failure.append(cookie)
|
||||||
|
msg.append(message)
|
||||||
|
signerror=True
|
||||||
|
|
||||||
if(sign.status_code==200):
|
if(sign.status_code==200):
|
||||||
message='[网易云游戏自动签到]签到成功!'
|
message='第{}个账号签到成功!'.format(cookies.index(i)+1)
|
||||||
send(teleid,message)
|
success.append(cookie)
|
||||||
scsend(sckey,message)
|
msg.append(message)
|
||||||
print(message)
|
elif(signerror!=True):
|
||||||
else:
|
message='第{}个账号签到失败,回显状态码为{},具体错误信息如下:{}'.format(cookies.index(i)+1,sign.status_code,sign.text)
|
||||||
message='[网易云游戏自动签到]签到失败,回显状态码为{}\n具体错误信息如下:\n{}'.format(sign.status_code,sign.text)
|
failure.append(cookie)
|
||||||
send(teleid,message)
|
msg.append(message)
|
||||||
scsend(sckey,message)
|
outputmsg=str(msg).replace("[",'').replace(']','').replace(',','<br>').replace('\'','')
|
||||||
print(message)
|
teleinfomsg='''
|
||||||
raise(CheckInError)
|
感谢使用来自GamerNoTitle的网易云游戏自动签到脚本!
|
||||||
|
今日签到结果如下:
|
||||||
|
成功数量:{0}/{2}
|
||||||
|
失败数量:{1}/{2}
|
||||||
|
具体情况如下:
|
||||||
|
{3}
|
||||||
|
'''.format(len(success),len(failure),len(cookies),outputmsg)
|
||||||
|
scinfomsg='''
|
||||||
|
感谢使用来自<a herf='https://bili33.top'>GamerNoTitle</a>的<a herf='https://github.com/GamerNoTitle/wyycg-autocheckin'>网易云游戏自动签到脚本</a>!<br>
|
||||||
|
今日签到结果如下:<br>
|
||||||
|
成功数量:{0}/{2}<br>
|
||||||
|
失败数量:{1}/{2}<br>
|
||||||
|
具体情况如下:<br>
|
||||||
|
{3}
|
||||||
|
'''.format(len(success),len(failure),len(cookies),outputmsg)
|
||||||
|
|
||||||
|
scsend(sckey,scinfomsg)
|
||||||
|
send(teleid,teleinfomsg)
|
||||||
|
print(scinfomsg)
|
||||||
|
if(len(msg)!=0):
|
||||||
|
raise Error
|
Loading…
Reference in New Issue
Block a user