diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2012-02-28 06:29:55 +0000 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2012-02-28 06:30:29 +0000 |
commit | 4c864f9a89d3ea597aefb505e4887ae9f536e9a7 (patch) | |
tree | 7727bc32364f3a6f2a4ad700e604edc87c1055c8 | |
parent | Add IN_PROGRESS, CONFIRMED (diff) | |
download | rbot-bugzilla-4c864f9a89d3ea597aefb505e4887ae9f536e9a7.tar.gz rbot-bugzilla-4c864f9a89d3ea597aefb505e4887ae9f536e9a7.tar.bz2 rbot-bugzilla-4c864f9a89d3ea597aefb505e4887ae9f536e9a7.zip |
Support 'bug X comment Y' and 'bug X#cY' as commands and detection in text.
-rw-r--r-- | bugzilla.rb | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/bugzilla.rb b/bugzilla.rb index d428ddb..13f19fe 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -389,7 +389,7 @@ class BugzillaPlugin < Plugin 'STATUS' => status, 'REPORTER' => reporter, 'ASSIGNEE' => assignee, - 'URL' => showbugurl.gsub('@BUGNO@', bugno).gsub('@COMMENT@', comment), + 'URL' => showbugurl.gsub('@BUGNO@', bugno).gsub('@COMMENT@', comment.length > 0 ? '#c'+comment : '' ), } output = template.dup mapping.each { |k,v| @@ -533,10 +533,11 @@ class BugzillaPlugin < Plugin def listen(m) return if m.address? return unless lurk?(m) - return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)(#c[0-9]+)?/i + 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) end @@ -560,14 +561,19 @@ class BugzillaPlugin < Plugin # Answer to a bug information request, long form. def buglong(m, params) begin - 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 + comment = "" + if params[:garbage] == 'comment' and params[:comment] =~ /^(?:#|#c)?([0-9]+)$/ + comment = $1 + end + if params[:number].chomp("#") =~ /#?([0-9]+)(?:(?:#c|comment #?)([0-9]+))?/i + bugno = $1 + comment = $2 if $2 + bugno.gsub!(/^#/,'') + else + m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help." + return + end + comment.gsub!(/^#c?/,'') if params[:zilla] and bugno check_zilla(params[:zilla]) @@ -585,17 +591,23 @@ class BugzillaPlugin < Plugin # Answer to a bug information request, short form. def bug(m, params) begin - 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 + comment = "" + if params[:garbage] == 'comment' and params[:comment] =~ /^(?:#|#c)?([0-9]+)$/ + comment = $1 + end + if params[:number].chomp("#") =~ /#?([0-9]+)(?:(?:#c|comment #?)([0-9]+))?/i + bugno = $1 + comment = $2 if $2 + bugno.gsub!(/^#/,'') + else + m.reply "Wrong parameters - invalid bugnumber, see 'help bug' for help." + return + end + comment.gsub!(/^#c?/,'') + 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, comment) @@ -1035,19 +1047,25 @@ plugin = BugzillaPlugin.new plugin.default_auth( 'modify', false ) plugin.default_auth( 'view', true ) -plugin.map 'bug :number', +plugin.map 'bug :number :garbage :comment', :requirements => { :number => /^[^ ]+$/, + :garbage => /^[^ ]+$/, + :comment => /^[^ ]+$/, }, + :defaults => { :garbage => "", :comment => "" }, :action => 'bug', :thread => 'yes', :auth_path => 'view' -plugin.map 'bugl :zilla :number', +plugin.map 'bugl :zilla :number :garbage :comment', :requirements => { :number => /^[^ ]+$/, - :zilla => /^[^ ]+$/ + :zilla => /^[^ ]+$/, + :garbage => /^[^ ]+$/, + :comment => /^[^ ]+$/, }, + :defaults => { :garbage => "", :comment => "" }, :action => 'buglong', :thread => 'yes', :auth_path => 'view' @@ -1082,7 +1100,7 @@ plugin.map 'zilla instance add :zilla :baseurl', :action => 'instance_add', :requirements => { :zilla => /^[^ ]+$/, - :baseurl => /^https?:\/\/.*/ + :baseurl => /^https?:\/\/.*/, }, :auth_path => 'modify' @@ -1090,7 +1108,7 @@ plugin.map 'zilla instance set :zilla :setting :value', :action => 'instance_set', :requirements => { :zilla => /^[^\. ]+$/, - :setting => OPTIONS_INPUT_1 + :setting => OPTIONS_INPUT_1, }, :auth_path => 'modify' @@ -1109,7 +1127,7 @@ plugin.map 'zilla instance show :zilla :full', :action => 'instance_show', :requirements => { :zilla => /^[^ ]+$/, - :full => /^full|registry$/ + :full => /^full|registry$/, }, :defaults => { :full => "registry" }, :auth_path => 'view' |