aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2021-06-18 22:25:25 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2021-06-18 22:25:25 -0700
commitb7dd157b41e1c3a57c098a6a5402899784b2041f (patch)
treecabf43bc2d72a584a93acbf9c4bb4fba267e05a0
parentUpdate for newer HTMLEntities. (diff)
downloadrbot-bugzilla-b7dd157b41e1c3a57c098a6a5402899784b2041f.tar.gz
rbot-bugzilla-b7dd157b41e1c3a57c098a6a5402899784b2041f.tar.bz2
rbot-bugzilla-b7dd157b41e1c3a57c098a6a5402899784b2041f.zip
bugzilla: support bug aliases
Closes: https://bugs.gentoo.org/356123 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r--bugzilla.rb32
1 files changed, 25 insertions, 7 deletions
diff --git a/bugzilla.rb b/bugzilla.rb
index d9af38f..a1f0e6a 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -533,13 +533,31 @@ class BugzillaPlugin < Plugin
def listen(m)
return if m.address?
return unless lurk?(m)
- return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)(?:(?:#c| comment #?)([0-9]+))?/i
- bugno = $1
- comment = $2 || ""
- bugno.gsub!(/^#/,'')
- comment.gsub!(/^#c?/,'')
- zilla = get_zilla(m)
- m.reply zilla.summary(bugno, comment)
+ # bug 1234
+ # bug 1234#c1234
+ # bug 1234 comment 1234
+ # bug 1234 comment #1234
+ # bug #1234
+ # bug #1234#c1234
+ # bug #1234 comment 1234
+ # bug #1234 comment #1234
+ # bug #gcc
+ # bug #gcc#c1234
+ # bug #gcc comment 1234
+ # bug #gcc comment #1234
+ #
+ # bug aliases can contain
+ # 0-9, a-z, A-Z
+ # and then every punctuation except ","
+ message_re = /\bbug(?:[[:space:]]*)(?:#?([0-9]+|#[-[:alnum:]~`!@#$%^&*()_+={}\]\[\\/|:;\'"<>.?]{3,40}))(?:(?:#c| comment #?)([0-9]+))?/i
+ message.scan(message_re).each do |bug_comment|
+ bugno = bug_comment[0]
+ comment = bug_comment[1] || ""
+ bugno.gsub!(/^#/,'')
+ comment.gsub!(/^#c?/,'')
+ zilla = get_zilla(m)
+ m.reply zilla.summary(bugno, comment)
+ end
end
# Function checking when a new channel is joined