diff options
author | 2024-02-09 11:43:59 -0800 | |
---|---|---|
committer | 2024-02-09 11:44:39 -0800 | |
commit | 68f157e15941877f5a16d233c2815421c5493653 (patch) | |
tree | afe4c1785cf2b6d6144259519e971d96eb5a62d0 | |
parent | bugzilla: support bug aliases (diff) | |
download | rbot-bugzilla-68f157e15941877f5a16d233c2815421c5493653.tar.gz rbot-bugzilla-68f157e15941877f5a16d233c2815421c5493653.tar.bz2 rbot-bugzilla-68f157e15941877f5a16d233c2815421c5493653.zip |
feat: report how many bugs get skipped and make it configurable
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | bugzilla.rb | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/bugzilla.rb b/bugzilla.rb index a1f0e6a..ed23915 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -34,7 +34,7 @@ VALID_RESO = ['FIXED', 'INVALID', 'WONTFIX', 'LATER', 'REMIND', 'DUPLICATE', 'W # Each zilla instance may have these parameters # TODO: Add 'nicename' that is used for output to IRC. Defaults to name.capitialize -OPTIONS = [ 'name', 'baseurl', 'dataurl', 'showbugurl', 'reporturl', 'buglisturl', 'template' ] +OPTIONS = [ 'name', 'baseurl', 'dataurl', 'showbugurl', 'reporturl', 'buglisturl', 'template', 'max_announce' ] # Now life gets fun, these are regular expresses to check the above arrays _STATUS_INPUT = (DONE_STATUS+OPEN_STATUS+['ALL']).uniq.join('|') @@ -100,7 +100,7 @@ class BugzillaPlugin < Plugin "Bug ##{@bugno} not found in #{@zilla}" end end - + # Exception class for bugs that are security-locked # It is thrown when the XML document does not contain either a <bug> # or <issue> element that is recognised. @@ -213,6 +213,14 @@ class BugzillaPlugin < Plugin @template = @registry["zilla.#{name}.template"] = val end + def max_announce + @registry["zilla.#{name}.max_announce"] || 5 + end + + def max_announce=(val) + @registry["zilla.#{name}.max_announce"] = val + end + def lastseenid return @registry["zilla.#{name}.lastseenid"] end @@ -314,7 +322,7 @@ class BugzillaPlugin < Plugin @client = nil end - + # TODO: Promote EMAIL_REPLACEMENTS to a config hash instead, with a nice # large set of defaults. EMAIL_REPLACEMENTS = { 'gentoo.org' => 'g.o', 'gentooexperimental.org' => 'ge.o' } @@ -421,16 +429,24 @@ class BugzillaPlugin < Plugin buglist = search(recent_url) buglist.delete_at(0) - upper_bound = [buglist.size, 5].min + upper_bound = [buglist.size, max_announce].min + + if (buglist.size > upper_bound) + first_skip = buglist[0][0].to_i + last_skip = buglist[-(upper_bound+1)][0].to_i + @registry["zilla.#{@name}.announcements"].each do |chan| + @bot.say chan, "(too many new bugs, skipping Bug IDs #{first_skip}..#{last_skip})" + end + self.lastseenid = last_skip + end + buglist[-upper_bound..-1].each do |bug| bugsummary = summary(bug[0]) - @registry["zilla.#{@name}.announcements"].each do |chan| @bot.say chan, "New bug: #{bugsummary}" end + self.lastseenid = bug[0].to_i end - - self.lastseenid = buglist[-1][0].to_i if buglist.size > 0 end def search(urlparams, params = nil) @@ -549,7 +565,7 @@ class BugzillaPlugin < Plugin # 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_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] || "" |