[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2024-02-10 Thread Robin H. Johnson
commit: 242113aa6a719477ddf8246ed9a6104f2b7b9d63
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sat Feb 10 19:22:07 2024 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Feb 10 19:22:07 2024 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=242113aa

fix: missing field

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index a4d88f5..8af205a 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -566,7 +566,7 @@ class BugzillaPlugin < Plugin
 # bug aliases can contain
 # 0-9, a-z, A-Z
 # and then every punctuation except ","
-m.scan(MESSAGE_RE).each do |bug_comment|
+m.message.scan(MESSAGE_RE).each do |bug_comment|
   bugno = bug_comment[0]
   comment = bug_comment[1] || ""
   bugno.gsub!(/^#/,'')



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2024-02-10 Thread Robin H. Johnson
commit: 0b0ca1a283eb592a08974ae7bb00d33a600a5ceb
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sat Feb 10 19:13:03 2024 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Feb 10 19:13:03 2024 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=0b0ca1a2

fix: variable naming error

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index 5000e4a..a4d88f5 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -546,6 +546,7 @@ class BugzillaPlugin < Plugin
   # This function is used to check if an user requested bug
   # information inline in the text of a message rather than directly
   # to the bot.
+  MESSAGE_RE = 
/\bbug(?:[[:space:]]*)(?:#?([0-9]+|#[-[:alnum:]~`!@#$%^&*()_+={}\]\[\\\/|:;\'"<>.?]{3,40}))(?:(?:#c|
 comment #?)([0-9]+))?/i
   def listen(m)
 return if m.address?
 return unless lurk?(m)
@@ -565,8 +566,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.scan(message_re).each do |bug_comment|
+m.scan(MESSAGE_RE).each do |bug_comment|
   bugno = bug_comment[0]
   comment = bug_comment[1] || ""
   bugno.gsub!(/^#/,'')



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2024-02-09 Thread Robin H. Johnson
commit: 18a4ab9ac73695a7e55bc4b17b428967629f5104
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sat Feb 10 05:30:18 2024 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Feb 10 05:30:18 2024 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=18a4ab9a

fix: cannot compare string and int

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index ed23915..5000e4a 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -214,7 +214,7 @@ class BugzillaPlugin < Plugin
 end
 
 def max_announce
-  @registry["zilla.#{name}.max_announce"] || 5
+  @registry["zilla.#{name}.max_announce"]&.to_i || 5
 end
 
 def max_announce=(val)
@@ -429,7 +429,7 @@ class BugzillaPlugin < Plugin
 
   buglist = search(recent_url)
   buglist.delete_at(0)
-  upper_bound = [buglist.size, max_announce].min
+  upper_bound = [buglist.size, max_announce&.to_i].min
 
   if (buglist.size > upper_bound)
 first_skip = buglist[0][0].to_i



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2024-02-09 Thread Robin H. Johnson
commit: 68f157e15941877f5a16d233c2815421c5493653
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Fri Feb  9 19:43:59 2024 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Fri Feb  9 19:44:39 2024 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=68f157e1

feat: report how many bugs get skipped and make it configurable

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 32 
 1 file 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 
   # or  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] || ""



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2021-06-18 Thread Robin H. Johnson
commit: b7dd157b41e1c3a57c098a6a5402899784b2041f
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sat Jun 19 05:25:25 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Jun 19 05:25:25 2021 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=b7dd157b

bugzilla: support bug aliases

Closes: https://bugs.gentoo.org/356123
Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 32 +---
 1 file 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



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2015-11-15 Thread Robin H. Johnson
commit: 172ea72b8d730a44268db23b5fe954a8cd15de4b
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Nov 16 04:22:29 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Nov 16 04:22:29 2015 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=172ea72b

Update for newer HTMLEntities.

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index 97743cc..d9af38f 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -21,7 +21,7 @@ require 'htmlentities'
 
 module BugzillaStringExtensions
   def decode_entities
-return HTMLEntities.decode_entities(self)
+return HTMLEntities.new().decode(self)
   end
 end
 String.send(:include, BugzillaStringExtensions)



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2015-11-15 Thread Robin H. Johnson
commit: b82b012c7122e06f805155a62fa6727ad401f390
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Nov 16 04:22:18 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Nov 16 04:22:18 2015 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=b82b012c

Update for newer Ruby.

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index 13f19fe..97743cc 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -435,13 +435,13 @@ class BugzillaPlugin < Plugin
 
 def search(urlparams, params = nil)
   url = buglisturl + '&' + urlparams
-  searchdata = CSV::Reader.create(@bot.httputil.get(url)).to_a
+  searchdata = CSV.parse(@bot.httputil.get(url))
   return searchdata
 end
 
 def report(urlparams, params = nil)
   url = 

[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2015-11-15 Thread Robin H. Johnson
commit: 2560e4f2c846790efdf74f059111d01349a77ea4
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Nov 16 04:22:29 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Nov 16 04:27:06 2015 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=2560e4f2

Update for newer HTMLEntities.

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index 97743cc..d9af38f 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -21,7 +21,7 @@ require 'htmlentities'
 
 module BugzillaStringExtensions
   def decode_entities
-return HTMLEntities.decode_entities(self)
+return HTMLEntities.new().decode(self)
   end
 end
 String.send(:include, BugzillaStringExtensions)



[gentoo-commits] proj/rbot-bugzilla:master commit in: /

2015-11-15 Thread Robin H. Johnson
commit: 6340025d9ae6139c414c337bc92cfcc177a2a5b1
Author: Doug Freed  mtu  edu>
AuthorDate: Mon Nov 16 04:22:18 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Nov 16 04:26:54 2015 +
URL:https://gitweb.gentoo.org/proj/rbot-bugzilla.git/commit/?id=6340025d

CSV: Update for newer Ruby.

CSV::Reader is no longer available after Ruby 1.9; we need to do it
differently.

Signed-off-by: Robin H. Johnson  gentoo.org>

 bugzilla.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bugzilla.rb b/bugzilla.rb
index 13f19fe..97743cc 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -435,13 +435,13 @@ class BugzillaPlugin < Plugin
 
 def search(urlparams, params = nil)
   url = buglisturl + '&' + urlparams
-  searchdata = CSV::Reader.create(@bot.httputil.get(url)).to_a
+  searchdata = CSV.parse(@bot.httputil.get(url))
   return searchdata
 end
 
 def report(urlparams, params = nil)
   url =