aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2010-10-27 07:05:49 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2010-10-27 07:05:49 +0000
commita4a8acd9e0bd171f03dec8d424b0f152c04e5235 (patch)
tree3688ec977742445cacc69d1cd5ee0268c3306532
parentFix case sensitivity issue. (diff)
parentAdd support for comment ids. Improve error handling in case of invalid bug ids. (diff)
downloadrbot-bugzilla-a4a8acd9e0bd171f03dec8d424b0f152c04e5235.tar.gz
rbot-bugzilla-a4a8acd9e0bd171f03dec8d424b0f152c04e5235.tar.bz2
rbot-bugzilla-a4a8acd9e0bd171f03dec8d424b0f152c04e5235.zip
Merge remote branch 'origin/master'
-rw-r--r--bugzilla.rb47
1 files changed, 31 insertions, 16 deletions
diff --git a/bugzilla.rb b/bugzilla.rb
index b75b891..474c7eb 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -258,7 +258,7 @@ class BugzillaPlugin < Plugin
def guess_showbugurl
@showbugurl = baseurl
@showbugurl += "/" unless baseurl[-1..-1] == "/"
- @showbugurl += "show_bug.cgi?id=@BUGNO@"
+ @showbugurl += "show_bug.cgi?id=@BUGNO@@COMMENT@"
end
# Guess at the URL for the XML format of any given bug.
@@ -327,10 +327,10 @@ class BugzillaPlugin < Plugin
end
# Return the summary for a given bug.
- def summary(bugno)
+ def summary(bugno, comment="")
raise EInvalidInstance.new(self.name, "No XML data URL available") if dataurl == nil
- bugdata = REXML::Document.new(@bot.httputil.get(dataurl.gsub("@BUGNO@", bugno)))
+ bugdata = REXML::Document.new(@bot.httputil.get(dataurl.gsub("@BUGNO@", bugno).gsub("@COMMENT@", "")))
raise EErrorLoading.new(name, bugno) unless bugdata
@@ -377,7 +377,8 @@ class BugzillaPlugin < Plugin
assignee = shrink_email(assignee)
mapping = {
- 'BUGNO' => bugno,
+ 'BUGNO' => bugno,
+ 'COMMENT' => comment,
'DESC' => desc,
'PRODUCT' => product,
'COMPONENT' => component,
@@ -388,7 +389,7 @@ class BugzillaPlugin < Plugin
'STATUS' => status,
'REPORTER' => reporter,
'ASSIGNEE' => assignee,
- 'URL' => showbugurl.gsub('@BUGNO@', bugno),
+ 'URL' => showbugurl.gsub('@BUGNO@', bugno).gsub('@COMMENT@', comment),
}
output = template.dup
mapping.each { |k,v|
@@ -532,11 +533,12 @@ class BugzillaPlugin < Plugin
def listen(m)
return if m.address?
return unless lurk?(m)
- return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)/i
+ return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)(#c[0-9]+)?/i
bugno = $1
+ comment = $2 || ""
bugno.gsub!(/^#/,'')
zilla = get_zilla(m)
- m.reply zilla.summary(bugno)
+ m.reply zilla.summary(bugno, comment)
end
# Function checking when a new channel is joined
@@ -558,9 +560,15 @@ class BugzillaPlugin < Plugin
# Answer to a bug information request, long form.
def buglong(m, params)
begin
- bugno = params[:number].chomp("#")
- bugno.gsub!(/^#/,'')
-
+ if params[:number].chomp("#") =~ /#?([0-9]+)(#c[0-9]+)?/i
+ bugno = $1
+ comment = $2 || ""
+ bugno.gsub!(/^#/,'')
+ else
+ m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help."
+ return
+ end
+
if params[:zilla] and bugno
check_zilla(params[:zilla])
zilla = @zillas[params[:zilla]]
@@ -568,7 +576,7 @@ class BugzillaPlugin < Plugin
m.reply "Wrong parameters - unknown zilla, see 'help bug' for help."
return
end
- m.reply zilla.summary(bugno)
+ m.reply zilla.summary(bugno, comment)
rescue ::Exception => e
m.reply e.message
end
@@ -577,13 +585,20 @@ class BugzillaPlugin < Plugin
# Answer to a bug information request, short form.
def bug(m, params)
begin
- bugno = params[:number].chomp("#")
- bugno.gsub!(/^#/,'')
+ if params[:number].chomp("#") =~ /#?([0-9]+)(#c[0-9]+)?/i
+ bugno = $1
+ comment = $2 ? $2 : ""
+ bugno.gsub!(/^#/,'')
+ else
+ m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help."
+ return
+ end
zilla = get_zilla(m)
- if not zilla
+
+ if not zilla
m.reply "Wrong parameters - unknown zilla, see 'help bug' for help."
end
- m.reply zilla.summary(bugno)
+ m.reply zilla.summary(bugno, comment)
rescue ::Exception => e
m.reply e.message
end
@@ -601,7 +616,7 @@ class BugzillaPlugin < Plugin
m.reply "Wrong parameters (no bugzilla specified), see 'help bugstats' for help."
return
end
-
+
title = "#{zilla.name.capitalize} bug status totals"
# Build our URL