Print links for all mentioned tickets
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:
parent
aeaa93d82e
commit
0d22b8e05b
@ -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
34
test.py
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user