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
2022-06-28 06:11:03 +00:00
from core.builtins.message import MessageSession
2022-07-31 08:27:58 +00:00
from core.component import on_command
2021-08-07 07:56:48 +00:00
from modules.wiki.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
2021-10-24 10:55:45 +00:00
usr = on_command('user', alias=['u'],
developers=['OasisAkari'])
2021-08-01 14:26:55 +00:00
2021-10-24 10:55:45 +00:00
2022-07-26 18:07:50 +00:00
@usr.handle('<username> [-p] {获取一个MediaWiki用户的信息。-p - 生成一张图片。)}')
2021-08-01 14:26:55 +00:00
async def user(msg: 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(
await get_user_info(interwikis[match_interwiki.group(1)], match_interwiki.group(2),
pic=msg.parsed_msg['-p']))
2022-07-26 18:07:09 +00:00
await msg.finish(await get_user_info(metaurl, username, pic=msg.parsed_msg['-p']))
2021-08-01 14:26:55 +00:00
else:
2022-07-26 18:07:09 +00:00
await msg.finish('未设置起始wiki。')