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/bugtracker/__init__.py

32 lines
1.2 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.

import re
from core.elements import MessageSession
from core.decorator import command, regex
from .bugtracker import bugtracker_get
@command('bug', alias='b', help_doc='~bug <MojiraID> {查询Mojira上的漏洞编号内容}',
developers=['OasisAkari'], allowed_none=False)
async def bugtracker(msg: MessageSession):
mojira_id = msg.parsed_msg['<MojiraID>']
if mojira_id:
q = re.match(r'(.*-.*)', mojira_id)
if q:
result = await bugtracker_get(q.group(1))
await msg.sendMessage(result)
@regex('bug_regex', pattern=r'^\!(?:bug |)(.*)-(.*)', mode='M',
desc='正则自动查询Mojira漏洞所有消息开头为!<mojiraid>和来自Mojira的链接将会被自动查询并发送梗概内容。',
developers=['OasisAkari'])
async def regex_bugtracker(msg: MessageSession):
result = await bugtracker_get(msg.matched_msg.group(1) + '-' + msg.matched_msg.group(2))
return await msg.sendMessage(result)
"""rlink = re.compile(r'https://bugs\.mojang\.com/browse/(.*?-\d*)')
findlink = re.findall(rlink, display_msg)
for link in findlink:
matchbug = re.match(rlink, link)
if matchbug:
await msg.sendMessage(await bugtracker_get(matchbug.group(1)))"""