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/mcplayer/__init__.py
2023-12-07 01:55:11 +08:00

38 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from core.builtins import Bot, Plain, Image, Url
from core.component import module
from .mojang_api import *
mcplayer = module(
bind_prefix='mcplayer',
desc='{mcplayer.help.desc}',
developers=['Dianliang233'],
)
@mcplayer.command('<username_or_uuid> {{mcplayer.help}}')
async def main(msg: Bot.MessageSession, username_or_uuid: str):
arg = username_or_uuid
try:
if len(arg) == 32:
name = await uuid_to_name(arg)
uuid = arg
elif len(arg) == 36 and arg.count('-') == 4:
uuid = arg.replace('-', '')
name = await uuid_to_name(arg)
else:
name = arg
uuid = await name_to_uuid(arg)
namemc = 'https://namemc.com/profile/' + name
sac = await uuid_to_skin_and_cape(uuid)
if sac:
render = sac['render']
skin = sac['skin']
cape = sac['cape']
chain = [Plain(f'{name}{uuid}\nNameMC{Url(namemc)}'), Image(render), Image(skin)]
if cape:
chain.append(Image(cape))
await msg.finish(chain)
else:
await msg.finish(f'{name}{uuid}\nNameMC{Url(namemc)}')
except ValueError:
await msg.finish(msg.locale.t('mcplayer.message.not_found', player=arg))