[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/supplementary_scripts/rbot
From: Casey Link <unnamedrambler () gmail ! com>
Date: 2008-09-01 3:32:18
Message-ID: 1220239938.366327.23260.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 855537 by link:
Updated the rbot bug script to work with the new version of bugs.kde.org. Also, the \
script will now respond to channel messages that include bug numbers/urls.
M +55 -43 bug.rb
--- trunk/extragear/multimedia/amarok/supplementary_scripts/rbot/bug.rb \
#855536:855537 @@ -1,52 +1,64 @@
-#(C) Berkus Madfire
-#Needs xmlsimple from http://www.maik-schmidt.de/xml-simple.html
+#-- vim:sw=2:et
+#++
+# Author:: Berkus Madfire
+# Author:: Casey Link <unnamedrambler@gmail.com>
+#
+# Copyright:: (C) Berkus Madfire
+# Copyright:: (C) 2008 Casey Link
+#
+# License:: GPL v2
+require 'rexml/document'
-require 'net/http'
-require 'xmlsimple'
+class KDEBugPlugin < Plugin
+ include REXML
+ def help(plugin,topic="")
+ "bug #<number> - displays bugs.kde.org information for given bug number"
+ end
+ def message(m)
+ a = m.message.to_s.scan(/(?:bug|#|show_bug.cgi\?id=)+([0-9]{5,8})/)
+ m.reply bug(a[0]) if a.length > 0
+ end
-class KDEBugPlugin < Plugin
- def riphtml s
- s.gsub(/<[^>]+>/, \
'').gsub(/&/,'&').gsub(/"/,'"').gsub(/</,'<').gsub(/>/,'>').gsub(/&ellip;/,'...').gsub(/'/, \
"'").gsub("\n",'')
- return s
+ def bug(a)
+ if a.length == 0
+ return "You called the wrong number..."
+ end
+ begin
+ uri = "http://bugs.kde.org/xml.cgi?id=#{a}"
+ xml = @bot.httputil.get_response(uri)
+ doc = Document.new xml.body
+ bug = doc.root.elements["bug"]
+ if xml.message == "OK"
+ if bug.attributes["error"] == "NotFound"
+ return "Bug #{a} was not found in Bugzilla."
+ else
+ str = "PRODUCT: #{bug.elements["product"].text}"
+ if res = XPath.first( doc, "/bugzilla/bug/component" ) then
+ str += " / #{bug.elements["component"].text}"
+ end
+ str += " | STATUS: #{bug.elements["bug_status"].text}"
+ if res = XPath.first( doc, "/bugzilla/bug/resolution" ) then
+ str += " | RESOLUTION: #{bug.elements["resolution"].text}"
+ end
+ str += " | URL: http://bugs.kde.org/show_bug.cgi?id=#{a} | DESCRIPTION: \
#{bug.elements["short_desc"].text.ircify_html}" + return str
+ end
+ else
+ return "Request to bugs.kde.org failed. Message not OK."
+ end
+ rescue
+ return "Request to bugs.kde.org failed"
+ end
end
- def help(plugin,topic="")
- "bug #<number> - displays bugs.kde.org information for given bug number"
- end
-
def privmsg(m)
- unless m.params
- m.reply("incorrect usage: "+help(m.plugin))
- return
- end
- a = m.params.scan(/^#?([0-9]+)/)
- if a.length == 0
- m.reply("You called the wrong number...")
- return
- end
-# m.reply("Please wait, querying...")
- begin
- h = Net::HTTP.new("bugs.kde.org", 80)
- resp = h.get("/xml.cgi?id=#{a}", nil)
- if resp.message == "OK"
- bug = XmlSimple.xml_in(resp.body)
- if bug['bug'][0]['error'] == 'NotFound'
- m.reply("Bug #{a} was not found in Bugzilla.")
- else
- str = "PRODUCT: #{bug['bug'][0]['product']}"
- str += " / #{bug['bug'][0]['component']}" if bug['bug'][0]['component']
- str += " | STATUS: #{bug['bug'][0]['bug_status']}"
- str += " | RESOLUTION: #{bug['bug'][0]['resolution']}" if \
bug['bug'][0]['resolution']
- str += " | URL: http://bugs.kde.org/show_bug.cgi?id=#{a} | DESCRIPTION: \
#{riphtml(bug['bug'][0]['short_desc'].to_s)}"
- m.reply(str)
- end
- else
- m.reply("Request to bugs.kde.org failed. Message not OK.")
- end
- rescue
- m.reply("Request to bugs.kde.org failed")
- end
+ unless m.params
+ m.reply("incorrect usage: "+help(m.plugin))
+ return
+ end
+ a = m.params.scan(/^#?([0-9]+)/)
+ m.reply bug(a)
end
end
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic