Archived
1
0
Fork 0

quick fix for arcaea module

This commit is contained in:
yzhh 2023-03-17 22:16:12 +08:00
parent 08bf8836b3
commit 69e175487d
4 changed files with 9 additions and 9 deletions

View file

@ -132,7 +132,7 @@ async def _(msg: Bot.MessageSession):
if query_code is not None:
if not unofficial:
try:
resp = await get_info_official(query_code)
resp = await get_info_official(msg, query_code)
if resp['success']:
await msg.finish(resp['msg'])
else:
@ -146,7 +146,7 @@ async def _(msg: Bot.MessageSession):
unofficial = True
if unofficial:
try:
resp = await get_info(query_code)
resp = await get_info(msg, query_code)
await msg.finish(resp)
except Exception:
traceback.print_exc()
@ -180,7 +180,7 @@ async def _(msg: Bot.MessageSession):
get_friendcode_from_db = ArcBindInfoManager(msg).get_bind_friendcode()
if get_friendcode_from_db is not None:
usercode = get_friendcode_from_db
await msg.finish(Plain(await get_song_info(songname, diff, usercode)))
await msg.finish(Plain(await get_song_info(msg, songname, diff, usercode)))
@arc.command('bind <friendcode/username> {{arcaea.bind.help}}')

View file

@ -13,7 +13,7 @@ assets_path = os.path.abspath('./assets/arcaea')
api_url = Config("botarcapi_url")
async def get_info(usercode):
async def get_info(msg, usercode):
headers = {"User-Agent": Config('botarcapi_agent')}
try:
get_ = await get_url(api_url + f"user/info?usercode={usercode}&recent=1&withsonginfo=True",
@ -59,7 +59,7 @@ async def get_info(usercode):
else:
usrptt = usrptt / 100
time_played = datetime.fromtimestamp(recent['time_played'] / 1000)
result = [Plain(msg.locale.t('arcaea.info.message.result', username=username, potential=potential, trackname=trackname, difficulty=difficulty, score=score, pure=pure, shiny_pure=shiny_pure, far=far, lost=lost, realptt=realptt, ptt=ptt, time_played=time_played.strftime("%Y-%m-%d %H:%M:%S")))]
result = [Plain(msg.locale.t('arcaea.info.message.result', username=username, potential=usrptt, trackname=trackname, difficulty=difficulty, score=score, pure=pure, shiny_pure=shiny_pure, far=far, lost=lost, realptt=realptt, ptt=ptt, time_played=time_played.strftime("%Y-%m-%d %H:%M:%S")))]
if os.path.exists(imgpath):
result.append(Image(imgpath))
else:

View file

@ -27,7 +27,7 @@ async def get_songinfo(songid):
return False
async def get_info_official(usercode):
async def get_info_official(msg, usercode):
try:
getuserinfo_json = await get_url(f'{apiurl}user/{usercode}', headers=headers, status_code=200, fmt='json')
except ValueError as e:

View file

@ -14,7 +14,7 @@ api_url_official = Config('arcapi_official_url')
headers_official = {'Authorization': Config('arcapi_official_token')}
async def get_song_info(sid, diff: int, usercode=None):
async def get_song_info(msg, sid, diff: int, usercode=None):
headers = {"User-Agent": Config('botarcapi_agent')}
try:
song_info = await get_url(f'{api_url}song/info?songname={sid}', headers=headers, status_code=200,
@ -95,6 +95,6 @@ async def get_song_info(sid, diff: int, usercode=None):
return '\n'.join(msg)
elif song_info['status'] in errcode:
return Plain(f'{msg.locale.t("arcaea.message.failed.errcode")}{errcode[song_info["status"]]}')
return f'{msg.locale.t("arcaea.message.failed.errcode")}{errcode[song_info["status"]]}'
else:
return Plain(msg.locale.t('arcaea.message.failed') + song_info)
return msg.locale.t('arcaea.message.failed') + song_info