11import asyncio
22import copy
3+ from curses .ascii import isdigit
34import json
45import random
56import string
@@ -117,9 +118,7 @@ async def get_pass_challenge(uid: str, user_id: str, way: str):
117118 "x-rpc-channel" : "miyousheluodi" ,
118119 "x-rpc-device_id" : random_hex (32 ),
119120 "x-rpc-device_name" : "" .join (
120- random .sample (
121- string .ascii_lowercase + string .digits , random .randint (1 , 10 )
122- )
121+ random .sample (string .ascii_lowercase + string .digits , random .randint (1 , 10 ))
123122 ),
124123 "x-rpc-device_model" : "Mi 10" ,
125124 "Referer" : "https://app.mihoyo.com" ,
@@ -186,17 +185,11 @@ async def other_api(gt: str, challenge: str):
186185 )
187186 return validate , challenge
188187 else :
189- Logger .info (
190- "[第三方]" , info = "➤➤" , result = str (data ), result_type = False
191- )
188+ Logger .info ("[第三方]" , info = "➤➤" , result = str (data ), result_type = False )
192189 return "j" , "j"
193190
194191
195192async def rrocr (gt : str , challenge : str , referer : str ):
196- ji_fen = await gain_num ("rr" )
197- if int (ji_fen ) < 10 :
198- Logger .info ("[人人打码]" , info = "➤➤" , result = "积分不足" , result_type = False )
199- return "j" , "j"
200193 params = {
201194 "appkey" : config .rrocr_key ,
202195 "gt" : gt ,
@@ -232,10 +225,6 @@ async def rrocr(gt: str, challenge: str, referer: str):
232225
233226
234227async def ttocr (gt : str , challenge : str , referer : str ):
235- ji_fen = await gain_num ("tt" )
236- if int (ji_fen ) < 10 :
237- Logger .info ("[套套打码]" , info = "➤➤" , result = "积分不足" , result_type = False )
238- return "j" , "j"
239228 data = {
240229 "appkey" : config .ttocr_key ,
241230 "gt" : gt ,
@@ -256,6 +245,9 @@ async def ttocr(gt: str, challenge: str, referer: str):
256245 Logger .info ("[套套打码]" , info = "➤➤" , result = "验证失败" , result_type = False )
257246 return "j" , "j"
258247 get_id = get_id .json ()
248+ if get_id ["status" ] == 4001 :
249+ Logger .info ("[套套打码]" , info = "➤➤" , result = "积分不足" , result_type = False )
250+ return "j" , "j"
259251 result_id = get_id ["resultid" ]
260252 Logger .info ("[套套打码]" , info = "➤➤" , result = "等待15s获取结果" , result_type = True )
261253 await asyncio .sleep (15 )
@@ -329,16 +321,18 @@ async def gain_num(choice) -> Optional[str]:
329321 success = option .get ("success_info" )
330322 try :
331323 data = await aiorequests .get (option .get ("url" ))
324+ if data .status_code != 200 :
325+ return None
326+ data = data .json ()
327+ if data .get (success [0 ]) == success [1 ]:
328+ key_num = data .get (info , None )
329+ if key_num is not None :
330+ return key_num
332331 except Exception as e :
333332 Logger .info (
334- f"[{ choice } 打码]查询积分" , info = "➤➤" , result = f"请求失败{ e } " , result_type = False
333+ f"[{ choice } 打码]查询积分" ,
334+ info = "➤➤" ,
335+ result = f"请求失败{ e } " ,
336+ result_type = False ,
335337 )
336338 return None
337- if data .status_code != 200 :
338- return None
339- data = data .json ()
340- if data .get (success [0 ]) == success [1 ]:
341- key_num = data .get (info , None )
342- if key_num is None :
343- return None
344- return str (key_num )
0 commit comments