捕捉并处理错误信息(待测试)
This commit is contained in:
parent
04fb10a51c
commit
9edf4306a2
36
main.py
36
main.py
|
@ -6,20 +6,31 @@ import telepot
|
||||||
tele_enable=False
|
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'
|
||||||
with open('cookie.txt','r') as f:
|
cookie=''
|
||||||
cookie=f.read()
|
try:
|
||||||
f.close
|
with open('cookie.txt','r') as f:
|
||||||
|
cookie=f.read()
|
||||||
|
f.close
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
print('[网易云游戏自动签到]无法读取Cookie,请检查是否正确设置Cookie!错误回显为:\n{}'.format(e))
|
||||||
|
sys.exit()
|
||||||
|
except Exception as e:
|
||||||
|
print('[网易云游戏自动签到]无法读取Cookie,回显为\n{}'.format(e))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
with open('teleid.txt','r') as f:
|
try:
|
||||||
teleid=f.read()
|
with open('teleid.txt','r') as f:
|
||||||
f.close()
|
teleid=f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
with open('teletoken.txt','r') as f:
|
with open('teletoken.txt','r') as f:
|
||||||
teletoken=f.read()
|
teletoken=f.read()
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
if teletoken!='' and teleid!='':
|
|
||||||
tele_enable=True
|
tele_enable=True
|
||||||
|
except:
|
||||||
|
tele_enable=False
|
||||||
|
|
||||||
|
if tele_enable:
|
||||||
bot=telepot.Bot(teletoken)
|
bot=telepot.Bot(teletoken)
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +81,9 @@ 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)
|
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__":
|
||||||
|
if cookie=='':
|
||||||
|
print('[网易云游戏自动签到]未设置Cookie!正在退出……')
|
||||||
|
sys.exit()
|
||||||
me=getme(current,getheader)
|
me=getme(current,getheader)
|
||||||
if(me.status_code!=200):
|
if(me.status_code!=200):
|
||||||
message='[网易云游戏自动签到]签到失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'
|
message='[网易云游戏自动签到]签到失败!请检查Cookie是否过期!或者附上报错信息到 https://github.com/GamerNoTitle/wyycg-autosignin/issues 发起issue'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user