Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/arcaea/__init__.py

58 lines
2.2 KiB
Python
Raw Normal View History

2021-12-06 15:32:27 +00:00
import os
2023-02-05 14:33:33 +00:00
from core.builtins import Bot
from core.builtins import Image
2023-03-04 08:51:56 +00:00
from core.component import module
2021-12-06 15:32:27 +00:00
2023-04-05 02:22:37 +00:00
arc = module('arcaea', developers=['OasisAkari'], desc='{arcaea.help.desc}',
2023-03-04 08:51:56 +00:00
alias={'b30': 'arcaea b30', 'a': 'arcaea', 'arc': 'arcaea'})
assets_path = os.path.abspath('./assets/')
2021-12-06 15:32:27 +00:00
@arc.handle()
@arc.handle('<no_one_cares>')
2023-02-05 14:33:33 +00:00
async def _(msg: Bot.MessageSession):
2023-04-28 11:47:14 +00:00
await msg.finish([msg.locale.t("arcaea.message.sb616", Image(assets_path + '/noc.jpg'), Image(assets_path + '/aof.jpg')])
@arc.command('download {{arcaea.download.help}}')
async def _(msg: Bot.MessageSession):
if not webrender:
await msg.finish([message.no_webrender")])
resp = await get_url(webrender + 'source?url=https://webapi.lowiro.com/webapi/serve/static/bin/arcaea/apk/', 200,
fmt='json')
if resp:
await msg.finish([Plain(msg.locale.t("arcaea.download.message.success", version=resp["value"]["version"],
url=resp['value']['url']))])
@arc.command('random {{arcaea.random.help}}')
async def _(msg: Bot.MessageSession):
if not webrender:
await msg.finish([msg.locale.t("arcaea.message.no_webrender")])
resp = await get_url(webrender + 'source?url=https://webapi.lowiro.com/webapi/song/showcase/', 200, fmt='json')
if resp:
value = resp["value"][0]
image = f'{assets_path}/jacket/{value["song_id"]}.jpg'
result = [Plain(value["title"]["en"])]
if os.path.exists(image):
result.append(Image(path=image))
await msg.finish(result)
@arc.command('rank free {{arcaea.rank.help.free}}', 'rank paid {{arcaea.rank.help.paid}}')
async def _(msg: Bot.MessageSession):
if not webrender:
await msg.finish([.no_webrender")])
if msg.parsed_msg.get('free', False):
resp = await get_url(webrender + 'source?url=https://webapi.lowiro.com/webapi/song/rank/free/', 200, fmt='json')
else:
resp = await get_url(webrender + 'source?url=https://webapi.lowiro.com/webapi/song/rank/paid/', 200, fmt='json')
if resp:
r = []
rank = 0
for x in resp['value']:
rank += 1
r.append(f'{rank}. {x["title"]["en"]} ({x["status"]})')
await msg.finish('\n'.join(r))