You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2005/12/09 20:49:14 UTC

svn commit: r355583 - /maven/sandbox/issue/rbot/jira.rb

Author: jvanzyl
Date: Fri Dec  9 11:49:11 2005
New Revision: 355583

URL: http://svn.apache.org/viewcvs?rev=355583&view=rev
Log:
o updating jira bot to create issues and add questions to the FAQ

Modified:
    maven/sandbox/issue/rbot/jira.rb

Modified: maven/sandbox/issue/rbot/jira.rb
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rbot/jira.rb?rev=355583&r1=355582&r2=355583&view=diff
==============================================================================
--- maven/sandbox/issue/rbot/jira.rb (original)
+++ maven/sandbox/issue/rbot/jira.rb Fri Dec  9 11:49:11 2005
@@ -1,49 +1,75 @@
-require 'jira4r'
+require 'issue'
 require 'yaml'
 
+# faq counter: totals, by each contributor. a report would be nice.
+
 class JiraPlugin < Plugin
 
   @server = nil
-  @url = nil
-
-  def privmsg(m)
 
-    unless(m.params)
+  def jira(m,params)
+    unless(params)
       m.reply "incorrect usage. " + help(m.plugin)
     end
-
+    
     # Using the jira library directly seems to crash rbot ...
     # so i'm just exec'ing the command line tool used to query
     # JIRA from the command line.
-    
-    issue = getServer().getIssue( m.params.to_s.upcase )
+
+    issue = getServer().getIssue( params[:issue].to_s.upcase )
+    puts issue
+    url = getServer().issueUrl(issue)
+    puts url
     user = getServer().getUser( issue['reporter'] )
     m.reply( " " )
-    string =  "   Issue: #{issue['key']}\n"
-    string << "     URL: #{@url}/browse/#{issue['key']}\n"
+    string = ""
+    string << "     URL: #{url}\n"
     string << "  Status: #{issue['status']}\n"
     string << " Summary: #{issue['summary']}\n" 
     string << "Reporter: #{user['fullname']} (#{issue['reporter']})"
     m.reply( string )
     m.reply( " " )
   end
+
+  # Need to know which person submitted the entry 
+  def faqa(m,params)        
+    unless(m.params)
+      m.reply "incorrect usage. " + help(m.plugin)
+    end
+    who = params[:who]
+    summary = params[:phrase].join( " " )
+    fields = getServer().createIssue2( 'MNGFAQ', summary, 'none', '1', who, 'minor' )
+    getServer().closeIssue( fields )
+  end
+  
+  # Need to know which person submitted the entry 
+  def faqq(m,params)        
+    unless(m.params)
+      m.reply "incorrect usage. " + help(m.plugin)
+    end
+    who = params[:who]
+    summary = params[:phrase].join( " " )
+    puts who
+    puts summary
+    fields = getServer().createIssue2( 'MNGFAQ', summary, 'none', '1', who, 'minor' )
+  end  
   
+  def issue(m,params)
+    fields = getServer().createIssue2( params[:project], params[:summary], params[:description], '1', params[:assignee], 'minor' )
+    m.reply( fields['key'] )
+    m.reply( " created." )    
+  end
+
   def getServer
     if @server == nil
-      jira = YAML::load( File.open( File.join( ENV['HOME'], 'jira.yaml' ) ) )
-      
-      user = jira['user'] 
-      password = jira['password']      
-      @url = jira['server']
-      
-      @server = JIRA::Server.new( @url )
-      @server.login( user, password )
+      @server = IssueManager.new()
     end
-    return @server
+    @server
   end
 end
 
 plugin = JiraPlugin.new
-plugin.register("jira")
-
-
+plugin.map 'jira :issue'
+plugin.map 'faqa :who *phrase'
+plugin.map 'faqq :who *phrase'
+plugin.map 'issue :project :summary :description :assignee'