Print links for all mentioned tickets
All checks were successful
Run Limnoria Plugin Tests / test (pull_request) Successful in 10s
Run Limnoria Plugin Tests / test (push) Successful in 10s

Up to now this plugin only printed the link for the first encountered
ticket id. With this change links for all tickets are printed instead.
This commit is contained in:
Dunedan 2024-09-21 10:40:50 +02:00
parent aeaa93d82e
commit 0d22b8e05b
Signed by untrusted user: Dunedan
GPG Key ID: 885B16854284E0B2
2 changed files with 50 additions and 19 deletions

View File

@ -49,12 +49,9 @@ def doPrivmsg(self, irc, msg):
if channels and channel not in channels:
return
matchobj = self.ticket_pattern.search(payload)
if matchobj is None:
return
ticket_number = matchobj.group(1)
ticket_url = self.registryValue('ticketUrl')
for ticket_number in sorted(set(self.ticket_pattern.findall(payload))):
url = f'{ticket_url.rstrip("/")}/{ticket_number}'
self.log.info(f'Fetching title for {url}')

34
test.py
View File

@ -124,3 +124,37 @@ def test_ticket_id_at_the_beginning(self):
"https://gitea.wildfiregames.com/0ad/0ad/issues/1234")
self.assertIsNone(self.irc.takeMsg())
def test_match_multiple_ticket_ids(self):
obj = self.irc.getCallback('wfg')
obj.doPrivmsg(
self.irc,
ircmsgs.privmsg(self.config["supybot.plugins.wfg.channels"][0],
"References for this are #1234, #1234,#1235 and #1236")
)
msg = self.irc.takeMsg()
self.assertIsInstance(msg, ircmsgs.IrcMsg)
self.assertEqual(msg.nick, "")
self.assertEqual(msg.args[0], self.config["supybot.plugins.wfg.channels"][0])
self.assertEqual(msg.args[1],
"#1234 - [PATCH] Read formations from json files – "
"https://gitea.wildfiregames.com/0ad/0ad/issues/1234")
msg = self.irc.takeMsg()
self.assertIsInstance(msg, ircmsgs.IrcMsg)
self.assertEqual(msg.nick, "")
self.assertEqual(msg.args[0], self.config["supybot.plugins.wfg.channels"][0])
self.assertEqual(msg.args[1],
"#1235 - selection box moves when moving the camera – "
"https://gitea.wildfiregames.com/0ad/0ad/issues/1235")
msg = self.irc.takeMsg()
self.assertIsInstance(msg, ircmsgs.IrcMsg)
self.assertEqual(msg.nick, "")
self.assertEqual(msg.args[0], self.config["supybot.plugins.wfg.channels"][0])
self.assertEqual(msg.args[1],
"#1236 - WP Theming - Fine Footer – "
"https://gitea.wildfiregames.com/0ad/0ad/issues/1236")
self.assertIsNone(self.irc.takeMsg())