Update main.py
This commit is contained in:
parent
5a52deec8c
commit
87e278e6d9
118
main.py
118
main.py
|
@ -3,29 +3,33 @@ import requests as r
|
||||||
import json
|
import json
|
||||||
import telepot
|
import telepot
|
||||||
|
|
||||||
tele_enable=False
|
tele_enable = False
|
||||||
sc_enable=False
|
sc_enable = False
|
||||||
sign='https://n.cg.163.com/api/v2/sign-today'
|
sign_url = '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'
|
||||||
|
|
||||||
cookies=sys.argv[1].split('#')
|
|
||||||
teleid=sys.argv[2]
|
cookies = sys.argv[1].split('#')
|
||||||
teletoken=sys.argv[3]
|
teleid = sys.argv[2]
|
||||||
sckey=sys.argv[4]
|
teletoken = sys.argv[3]
|
||||||
if cookies=="":
|
sckey = sys.argv[4]
|
||||||
|
|
||||||
|
if cookies == "":
|
||||||
print('[网易云游戏自动签到]未设置cookie,正在退出……')
|
print('[网易云游戏自动签到]未设置cookie,正在退出……')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if teleid!="" and teletoken!="":
|
if teleid != "" and teletoken != "":
|
||||||
tele_enable=True
|
tele_enable = True
|
||||||
bot=telepot.Bot(teletoken)
|
bot = telepot.Bot(teletoken)
|
||||||
if sckey!="":
|
if sckey != "":
|
||||||
sc_enable=True
|
sc_enable = True
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def signin(url,cookie):
|
|
||||||
header={
|
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',
|
||||||
|
@ -42,11 +46,12 @@ def signin(url,cookie):
|
||||||
'X-Platform': '0'
|
'X-Platform': '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
result=r.post(url=url,headers=header)
|
result = r.post(url=url, headers=header)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getme(url,cookie):
|
|
||||||
header={
|
def getme(url, cookie):
|
||||||
|
header = {
|
||||||
'Host': 'n.cg.163.com',
|
'Host': 'n.cg.163.com',
|
||||||
'Connection': 'keep-alive',
|
'Connection': 'keep-alive',
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
@ -61,80 +66,85 @@ def getme(url,cookie):
|
||||||
'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'
|
||||||
}
|
}
|
||||||
result=r.get(url=url,headers=header)
|
result = r.get(url=url, headers=header)
|
||||||
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)
|
|
||||||
|
|
||||||
def scsend(SCKEY,message):
|
def send(id, message):
|
||||||
sc_url='http://sc.ftqq.com/{}.send?text=网易云游戏自动签到脚本&desp={}'.format(SCKEY,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:
|
if sc_enable:
|
||||||
r.get(url=sc_url)
|
r.get(url=sc_url)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
success=[]
|
success = []
|
||||||
failure=[]
|
failure = []
|
||||||
msg=[]
|
msg = []
|
||||||
print(len(cookies))
|
print(len(cookies))
|
||||||
for i in cookies:
|
for i in cookies:
|
||||||
print(i)
|
print(i)
|
||||||
cookie=i
|
cookie = i
|
||||||
autherror=False
|
autherror = False
|
||||||
signerror=False
|
signerror = False
|
||||||
|
sign_return = NULL
|
||||||
|
me = NULL
|
||||||
try:
|
try:
|
||||||
me=getme(current,cookie)
|
me = getme(current, cookie)
|
||||||
except:
|
except:
|
||||||
message='第{}个账号验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'.format(cookies.index(i)+1)
|
message = '第{}个账号验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'.format(
|
||||||
|
cookies.index(i) + 1)
|
||||||
failure.append(cookie)
|
failure.append(cookie)
|
||||||
msg.append(message)
|
msg.append(message)
|
||||||
autherror=True
|
autherror = True
|
||||||
|
|
||||||
if(me.status_code!=200 and autherror!=True):
|
if me.status_code != 200 and not autherror:
|
||||||
message='第{}个账号验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'.format(cookies.index(i)+1)
|
message = '第{}个账号验证失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'.format(
|
||||||
|
cookies.index(i) + 1)
|
||||||
failure.append(cookie)
|
failure.append(cookie)
|
||||||
msg.append(message)
|
msg.append(message)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sign=signin(sign,cookie)
|
sign_return = signin(sign_url, cookie)
|
||||||
except:
|
except:
|
||||||
print("No.{}: sign except block 1".format(cookies.index(cookie)+1))
|
message = '第{}个账号签到失败,回显状态码为{},具体错误信息如下:{}'.format(cookies.index(i) + 1, sign_return.status_code, sign_return.text)
|
||||||
message='第{}个账号签到失败,回显状态码为{},具体错误信息如下:{}'.format(cookies.index(i)+1,sign.status_code,sign.text)
|
|
||||||
failure.append(cookie)
|
failure.append(cookie)
|
||||||
msg.append(message)
|
msg.append(message)
|
||||||
signerror=True
|
signerror = True
|
||||||
|
|
||||||
if(sign.status_code==200):
|
if sign.status_code == 200:
|
||||||
print("No.{}: Success signed".format(cookies.index(cookie)+1))
|
message = '第{}个账号签到成功!'.format(cookies.index(i) + 1)
|
||||||
message='第{}个账号签到成功!'.format(cookies.index(i)+1)
|
|
||||||
success.append(cookie)
|
success.append(cookie)
|
||||||
msg.append(message)
|
msg.append(message)
|
||||||
elif(signerror!=True and sign.status_code!=200):
|
elif not signerror:
|
||||||
print('No.{}: Signerror False but failed'.format(cookies.index(cookie)+1))
|
message = '第{}个账号签到失败,回显状态码为{},具体错误信息如下:{}'.format(cookies.index(i) + 1, sign_return.status_code, sign_return.text)
|
||||||
message='第{}个账号签到失败,回显状态码为{},具体错误信息如下:{}'.format(cookies.index(i)+1,sign.status_code,sign.text)
|
|
||||||
failure.append(cookie)
|
failure.append(cookie)
|
||||||
msg.append(message)
|
msg.append(message)
|
||||||
outputmsg=str(msg).replace("[",'').replace(']','').replace(',','<br>').replace('\'','')
|
outputmsg = str(msg).replace("[", '').replace(']', '').replace(',', '<br>').replace('\'', '')
|
||||||
teleinfomsg='''
|
teleinfomsg = '''
|
||||||
感谢使用来自GamerNoTitle的网易云游戏自动签到脚本!
|
感谢使用来自GamerNoTitle的网易云游戏自动签到脚本!
|
||||||
今日签到结果如下:
|
今日签到结果如下:
|
||||||
成功数量:{0}/{2}
|
成功数量:{0}/{2}
|
||||||
失败数量:{1}/{2}
|
失败数量:{1}/{2}
|
||||||
具体情况如下:
|
具体情况如下:
|
||||||
{3}
|
{3}
|
||||||
'''.format(len(success),len(failure),len(cookies),outputmsg)
|
'''.format(len(success), len(failure), len(cookies), outputmsg)
|
||||||
scinfomsg='''
|
scinfomsg = '''
|
||||||
感谢使用来自<a herf='https://bili33.top'>GamerNoTitle</a>的<a herf='https://github.com/GamerNoTitle/wyycg-autocheckin'>网易云游戏自动签到脚本</a>!<br>
|
感谢使用来自<a herf='https://bili33.top'>GamerNoTitle</a>的<a herf='https://github.com/GamerNoTitle/wyycg-autocheckin'>网易云游戏自动签到脚本</a>!<br>
|
||||||
今日签到结果如下:<br>
|
今日签到结果如下:<br>
|
||||||
成功数量:{0}/{2}<br>
|
成功数量:{0}/{2}<br>
|
||||||
失败数量:{1}/{2}<br>
|
失败数量:{1}/{2}<br>
|
||||||
具体情况如下:<br>
|
具体情况如下:<br>
|
||||||
{3}
|
{3}
|
||||||
'''.format(len(success),len(failure),len(cookies),outputmsg)
|
'''.format(len(success), len(failure), len(cookies), outputmsg)
|
||||||
|
|
||||||
scsend(sckey,scinfomsg)
|
scsend(sckey, scinfomsg)
|
||||||
send(teleid,teleinfomsg)
|
send(teleid, teleinfomsg)
|
||||||
print(scinfomsg)
|
print(scinfomsg)
|
||||||
if(len(failure)!=0):
|
if (len(failure) != 0):
|
||||||
raise Error
|
raise Error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user