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/user/__init__.py
多羅狼 1f0f2924a2
i18n
2023-06-17 19:52:42 +08:00

28 lines
1.1 KiB
Python

import re
from core.builtins import Bot
from core.component import module
from modules.wiki.utils.dbutils import WikiTargetInfo
from .user import get_user_info
usr = module('user', alias='u',
developers=['OasisAkari'])
@usr.handle('<username> [-p] {{user.help.desc}}', options_desc={'-p': '{user.help.option.p}'})
async def user(msg: Bot.MessageSession):
target = WikiTargetInfo(msg)
get_url = target.get_start_wiki()
if get_url:
metaurl = get_url
username = msg.parsed_msg['<username>']
match_interwiki = re.match(r'(.*?):(.*)', username)
if match_interwiki:
interwikis = target.get_interwikis()
if match_interwiki.group(1) in interwikis:
return await msg.finish(
await get_user_info(msg, interwikis[match_interwiki.group(1)], match_interwiki.group(2),
pic=msg.parsed_msg['-p']))
await msg.finish(await get_user_info(msg, metaurl, username, pic=msg.parsed_msg['-p']))
else:
await msg.finish(msg.locale.t('wiki.message.not_set'))