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

45 lines
1.7 KiB
Python
Raw Normal View History

2021-02-01 15:13:11 +00:00
import re
from graia.application import MessageChain
from graia.application.message.elements.internal import Plain
from core.template import sendMessage
from .bugtracker import bug
async def bugtracker(kwargs: dict):
msg = kwargs['trigger_msg']
msg = re.sub('bug ', '', msg)
q = re.match(r'(.*)\-(.*)', msg)
if q:
result = await bug(q.group(1) + '-' + q.group(2))
msgchain = MessageChain.create([Plain(result)])
await sendMessage(kwargs, msgchain)
async def regex_bugtracker(kwargs: dict):
msg = kwargs[MessageChain].asDisplay()
2021-02-02 13:43:01 +00:00
if msg.find('[Webhook]') != -1:
2021-02-03 07:40:17 +00:00
return
2021-02-01 15:13:11 +00:00
if msg[0] == '!':
msg = re.sub('!', '', msg)
msg = re.sub('bug ', '', msg)
q = re.match(r'(.*)\-(.*)', msg)
if q:
result = await bug(q.group(1) + '-' + q.group(2))
msgchain = MessageChain.create([Plain(result)])
await sendMessage(kwargs, msgchain)
findlink = re.findall(r'(https://bugs.mojang.com/browse/.*?-\d*)', msg)
2021-02-01 15:13:11 +00:00
for link in findlink:
print(link)
matchbug = re.match(r'https://bugs.mojang.com/browse/(.*?-\d*)', link)
2021-02-01 15:13:11 +00:00
if matchbug:
await sendMessage(kwargs, await bug(matchbug.group(1)))
command = {'bug': bugtracker}
regex = {'bug_regex': regex_bugtracker}
help = {'bug': {'module': '查询Mojira上的漏洞编号。', 'help': '~bug <mojiraid> 查询Mojira上的漏洞编号。'},
2021-02-01 15:25:57 +00:00
'bug_regex': {'module': '正则自动查询Mojira上的漏洞编号。',
'help': '提示正则自动查询Mojira漏洞已开启所有消息开头为!<mojiraid>和来自Mojira的链接将会被自动查询并发送梗概内容。'}}