remove some function that uses official api from arcaea module
616sb
This commit is contained in:
parent
760fa0154d
commit
b3e35d83e2
4 changed files with 31 additions and 95 deletions
|
@ -8,9 +8,7 @@ from core.component import module
|
|||
from core.utils.http import get_url
|
||||
from .dbutils import ArcBindInfoManager
|
||||
from .getb30 import getb30
|
||||
from .getb30_official import getb30_official
|
||||
from .info import get_info
|
||||
from .info_official import get_info_official
|
||||
from .initialize import arcb30init
|
||||
from .song import get_song_info
|
||||
from .utils import get_userinfo
|
||||
|
@ -25,21 +23,11 @@ class WithErrCode(Exception):
|
|||
pass
|
||||
|
||||
|
||||
@arc.command('b30 [<friendcode>] {{arcaea.b30.help}}',
|
||||
'b30 official [<friendcode>] {{arcaea.message.official}}',
|
||||
'b30 unofficial [<friendcode>] {{arcaea.message.unofficial}}')
|
||||
@arc.command('b30 [<friendcode>] {{arcaea.b30.help}}')
|
||||
async def _(msg: Bot.MessageSession):
|
||||
if not os.path.exists(assets_path):
|
||||
await msg.finish(msg.locale.t("arcaea.message.assets.not_found", prefix=msg.prefixes[0]))
|
||||
query_code = None
|
||||
prefer_uses = msg.options.get('arc_api', None)
|
||||
official = msg.parsed_msg.get('official', False)
|
||||
unofficial = msg.parsed_msg.get('unofficial', False)
|
||||
if not unofficial and not official and prefer_uses is False:
|
||||
unofficial = True
|
||||
if not official and prefer_uses is True:
|
||||
official = True
|
||||
|
||||
friendcode: str = msg.parsed_msg.get('<friendcode>', False)
|
||||
if friendcode:
|
||||
if friendcode.isdigit():
|
||||
|
@ -54,68 +42,39 @@ async def _(msg: Bot.MessageSession):
|
|||
if get_friendcode_from_db is not None:
|
||||
query_code = get_friendcode_from_db
|
||||
if query_code is not None:
|
||||
if not unofficial:
|
||||
try:
|
||||
resp = await getb30_official(query_code)
|
||||
if resp["status"]:
|
||||
msgchain = [Plain(msg.locale.t("arcaea.b30.message.success", b30=resp["b30"], r10=resp["r10"],
|
||||
last5list=resp["last5list"]))]
|
||||
if 'file' in resp and msg.Feature.image:
|
||||
msgchain.append(Image(path=resp['file']))
|
||||
await msg.sendMessage(msgchain, allow_split_image=False)
|
||||
try:
|
||||
resp = await getb30(query_code)
|
||||
if resp['status']:
|
||||
msgchain = [Plain(msg.locale.t("arcaea.b30.message.success", b30=resp["b30"], r10=resp["r10"],
|
||||
last5list=resp["last5list"]))]
|
||||
if 'file' in resp and msg.Feature.image:
|
||||
msgchain.append(Image(path=resp['file']))
|
||||
await msg.finish(msgchain)
|
||||
else:
|
||||
if 'errcode' in resp:
|
||||
raise WithErrCode(resp['errcode'])
|
||||
else:
|
||||
raise
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
if not official and prefer_uses is None:
|
||||
await msg.sendMessage(msg.locale.t("arcaea.message.official.fetch.failed.fallback"))
|
||||
unofficial = True
|
||||
else:
|
||||
await msg.finish(msg.locale.t("arcaea.message.official.fetch.failed"))
|
||||
if unofficial:
|
||||
try:
|
||||
resp = await getb30(query_code)
|
||||
if resp['status']:
|
||||
msgchain = [Plain(msg.locale.t("arcaea.b30.message.success", b30=resp["b30"], r10=resp["r10"],
|
||||
last5list=resp["last5list"]))]
|
||||
if 'file' in resp and msg.Feature.image:
|
||||
msgchain.append(Image(path=resp['file']))
|
||||
await msg.finish(msgchain)
|
||||
else:
|
||||
if 'errcode' in resp:
|
||||
raise WithErrCode(resp['errcode'])
|
||||
else:
|
||||
raise
|
||||
except WithErrCode as e:
|
||||
err_key = "arcaea.errcode." + str(e.args[0])
|
||||
err_msg = msg.locale.t(err_key)
|
||||
if err_key != err_msg:
|
||||
await msg.finish(msg.locale.t("arcaea.message.failed.fetch") + err_msg)
|
||||
else:
|
||||
await msg.finish(msg.locale.t("arcaea.message.unofficial.fetch.failed"))
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
except WithErrCode as e:
|
||||
err_key = "arcaea.errcode." + str(e.args[0])
|
||||
err_msg = msg.locale.t(err_key)
|
||||
if err_key != err_msg:
|
||||
await msg.finish(msg.locale.t("arcaea.message.failed.fetch") + err_msg)
|
||||
else:
|
||||
await msg.finish(msg.locale.t("arcaea.message.unofficial.fetch.failed"))
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
await msg.finish(msg.locale.t("arcaea.message.unofficial.fetch.failed"))
|
||||
else:
|
||||
await msg.finish(msg.locale.t("arcaea.message.user.unbound", prefix=msg.prefixes[0]))
|
||||
|
||||
|
||||
@arc.command('info [<friendcode>] {{arcaea.info.help}}',
|
||||
'info official [<friendcode>] {{arcaea.message.official}}',
|
||||
'info unofficial [<friendcode>] {{arcaea.message.unofficial}}', )
|
||||
@arc.command('info [<friendcode>] {{arcaea.info.help}}')
|
||||
async def _(msg: Bot.MessageSession):
|
||||
if not os.path.exists(assets_path):
|
||||
await msg.sendMessage(msg.locale.t("arcaea.message.assets.not_found", prefix=msg.prefixes[0]))
|
||||
return
|
||||
query_code = None
|
||||
prefer_uses = msg.options.get('arc_api', None)
|
||||
unofficial = msg.parsed_msg.get('unofficial', False)
|
||||
official = msg.parsed_msg.get('official', False)
|
||||
if not unofficial and not official and prefer_uses is False:
|
||||
unofficial = True
|
||||
|
||||
if not official and prefer_uses is True:
|
||||
official = True
|
||||
friendcode = msg.parsed_msg.get('<friendcode>', False)
|
||||
if friendcode:
|
||||
if friendcode.isdigit():
|
||||
|
@ -130,27 +89,12 @@ async def _(msg: Bot.MessageSession):
|
|||
if get_friendcode_from_db is not None:
|
||||
query_code = get_friendcode_from_db
|
||||
if query_code is not None:
|
||||
if not unofficial:
|
||||
try:
|
||||
resp = await get_info_official(msg, query_code)
|
||||
if resp['success']:
|
||||
await msg.finish(resp['msg'])
|
||||
else:
|
||||
if not official and prefer_uses is None:
|
||||
await msg.sendMessage(msg.locale.t("arcaea.message.official.fetch.failed.fallback"))
|
||||
unofficial = True
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
if not official and prefer_uses is None:
|
||||
await msg.sendMessage(msg.locale.t("arcaea.message.official.fetch.failed.fallback"))
|
||||
unofficial = True
|
||||
if unofficial:
|
||||
try:
|
||||
resp = await get_info(msg, query_code)
|
||||
await msg.finish(resp)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
await msg.finish(msg.locale.t("arcaea.message.unofficial.fetch.failed"))
|
||||
try:
|
||||
resp = await get_info(msg, query_code)
|
||||
await msg.finish(resp)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
await msg.finish(msg.locale.t("arcaea.message.unofficial.fetch.failed"))
|
||||
else:
|
||||
await msg.finish(msg.locale.t("arcaea.message.user.unbound", prefix=msg.prefixes[0]))
|
||||
|
||||
|
@ -258,11 +202,3 @@ async def _(msg: Bot.MessageSession):
|
|||
rank += 1
|
||||
r.append(f'{rank}. {x["title"]["en"]} ({x["status"]})')
|
||||
await msg.finish('\n'.join(r))
|
||||
|
||||
|
||||
@arc.command('switch {{arcaea.switch.help}}')
|
||||
async def _(msg: Bot.MessageSession):
|
||||
value = msg.options.get('arc_api', True)
|
||||
set_value = msg.data.edit_option('arc_api', not value)
|
||||
await msg.finish(msg.locale.t("arcaea.switch.message.success.official"
|
||||
if not value else "arcaea.switch.message.success.unofficial"))
|
||||
|
|
0
modules/arcaea/recyclebin/__init__.py
Normal file
0
modules/arcaea/recyclebin/__init__.py
Normal file
|
@ -9,9 +9,9 @@ import uuid
|
|||
from config import Config
|
||||
from core.logger import Logger
|
||||
from core.utils.http import get_url
|
||||
from .drawb30img import drawb30
|
||||
from .drawsongimg import dsimg
|
||||
from .utils import autofix_b30_song_background
|
||||
from modules.arcaea.drawb30img import drawb30
|
||||
from modules.arcaea.drawsongimg import dsimg
|
||||
from modules.arcaea.utils import autofix_b30_song_background
|
||||
|
||||
assets_path = os.path.abspath('./assets/arcaea')
|
||||
|
Reference in a new issue