Skip to content
Snippets Groups Projects
Commit 49ff23ce authored by Sven Mäder's avatar Sven Mäder :speech_balloon:
Browse files

Init

parents
No related branches found
No related tags found
No related merge requests found
*.mbp
# RT Links Maubot
A [maubot](https://github.com/maubot/maubot) that sends clickable markdown formatted links when it sees RT ticket numbers in a given format.
## Usage
`rt123456` - Responds with `[123456](https://rt.phys.ethz.ch/rt/Ticket/Display.html?id=123456)`
# Target maubot version
maubot: 0.1.0
# The unique ID for the plugin. Java package naming style. (i.e. use your own domain, not xyz.maubot)
id: isg.rda.rtlinks
# A PEP 440 compliant version string.
version: 0.2.0
# The SPDX license identifier for the plugin. https://spdx.org/licenses/
# Optional, assumes all rights reserved if omitted.
license: GPL3
# The list of modules to load from the plugin archive.
# Modules can be directories with an __init__.py file or simply python files.
# Submodules that are imported by modules listed here don't need to be listed separately.
# However, top-level modules must always be listed even if they're imported by other modules.
modules:
- rtlinks
# The main class of the plugin. Format: module/Class
# If `module` is omitted, will default to last module specified in the module list.
# Even if `module` is not omitted here, it must be included in the modules list.
# The main class must extend maubot.Plugin
main_class: RTLinksPlugin
# Whether or not instances need a database
database: false
# Extra files that the upcoming build tool should include in the mbp file.
#extra_files:
#- base-config.yaml
#- LICENSE
# List of dependencies
#dependencies:
#- foo
#soft_dependencies:
#- bar>=0.1
from typing import List, Tuple
from maubot import Plugin, MessageEvent
from maubot.handlers import command
class RTLinksPlugin(Plugin):
@command.passive("((^| )([rR][tT]#?))([0-9]{6})", multiple=True)
async def handler(self, evt: MessageEvent, subs: List[Tuple[str, str]]) -> None:
await evt.mark_read()
msg_lines = []
for sub in subs:
number = sub[4]
link = "https://rt.phys.ethz.ch/rt/Ticket/Display.html?id={}".format(number)
markdown = "[rt#{}]({})".format(number, link)
msg_lines.append(markdown)
if msg_lines:
await evt.respond("\n".join(msg_lines))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment