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

29 lines
1.1 KiB
Python
Raw Normal View History

2021-08-01 14:26:55 +00:00
import re
2023-02-05 14:33:33 +00:00
from core.builtins import Bot
2023-03-04 08:51:56 +00:00
from core.component import module
from modules.wiki.utils.dbutils import WikiTargetInfo
2022-07-26 18:07:09 +00:00
from .user import get_user_info
2021-08-01 14:26:55 +00:00
2023-06-01 17:08:10 +00:00
usr = module('user', alias='u',
2023-04-30 03:30:59 +00:00
developers=['OasisAkari'])
2021-08-01 14:26:55 +00:00
2021-10-24 10:55:45 +00:00
2023-05-21 06:41:50 +00:00
@usr.handle('<username> [-p] {{user.help.desc}}', options_desc={'-p': '{user.help.option.p}'})
2023-02-05 14:33:33 +00:00
async def user(msg: Bot.MessageSession):
2022-07-26 18:07:09 +00:00
target = WikiTargetInfo(msg)
get_url = target.get_start_wiki()
2021-08-01 14:26:55 +00:00
if get_url:
metaurl = get_url
username = msg.parsed_msg['<username>']
2022-07-26 18:07:09 +00:00
match_interwiki = re.match(r'(.*?):(.*)', username)
if match_interwiki:
interwikis = target.get_interwikis()
if match_interwiki.group(1) in interwikis:
2022-07-31 08:33:20 +00:00
return await msg.finish(
2023-06-17 11:52:42 +00:00
await get_user_info(msg, interwikis[match_interwiki.group(1)], match_interwiki.group(2),
2022-07-31 08:33:20 +00:00
pic=msg.parsed_msg['-p']))
2023-06-17 11:52:42 +00:00
await msg.finish(await get_user_info(msg, metaurl, username, pic=msg.parsed_msg['-p']))
2021-08-01 14:26:55 +00:00
else:
2023-05-21 06:41:50 +00:00
await msg.finish(msg.locale.t('wiki.message.not_set'))