diff options
author | Dmitry Kim <dmitry point kim at gmail point com> | 2007-04-06 14:17:34 +0000 |
---|---|---|
committer | Dmitry Kim <dmitry point kim at gmail point com> | 2007-04-06 14:17:34 +0000 |
commit | 7999621ee6a8a0b0884eae38096f33e983c3a1ad (patch) | |
tree | 6d61f902de22dd55a3267fde61edfbee20b56f38 /data | |
parent | 620a8f02cb5d0d711b90f75937a8d268750c2715 (diff) |
- (contrib/plugins/ri) removed the old contrib version
+ (plugins/ri) plugin header
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/contrib/plugins/ri.rb | 83 | ||||
-rw-r--r-- | data/rbot/plugins/ri.rb | 22 |
2 files changed, 17 insertions, 88 deletions
diff --git a/data/rbot/contrib/plugins/ri.rb b/data/rbot/contrib/plugins/ri.rb deleted file mode 100644 index 99292f1c..00000000 --- a/data/rbot/contrib/plugins/ri.rb +++ /dev/null @@ -1,83 +0,0 @@ -# Author: Michael Brailsford <brailsmt@yahoo.com> -# aka brailsmt -# Purpose: To respond to requests for information from the ri command line -# utility. - -class RiPlugin < Plugin - - @@handlers = { - "ri" => "ri_handler", - "msgri" => "msgri_handler" - } - - #{{{ - def initialize - super - @cache = Hash.new - end - #}}} - #{{{ - def privmsg(m) - if not m.params - m.reply "uhmm... whatever" - return - end - - meth = self.method(@@handlers[m.plugin]) - meth.call(m) - end - #}}} - #{{{ - def cleanup - @cache = nil - end - #}}} - #{{{ - def ri_handler(m) - response = "" - if @cache[m.params] - response = @cache[m.params] - else - IO.popen("-") {|p| - if(p) - response = p.readlines.join "\n" - @cache[m.params] = response - else - $stderr = $stdout - exec("ri", m.params) - end - } - @cache[m.params] = response - end - - @bot.say m.sourcenick, response - m.reply "Finished \"ri #{m.params}\"" - end - #}}} - #{{{ - def msgri_handler(m) - response = "" - tell_nick, query = m.params.split() - if @cache[query] - response = @cache[query] - else - IO.popen("-") {|p| - if(p) - response = p.readlines.join "\n" - @cache[m.params] = response - else - $stderr = $stdout - exec("ri", query) - end - } - @cache[query] = response - end - - @bot.say tell_nick, response - m.reply "Finished telling #{tell_nick} about \"ri #{query}\"" - end - #}}} -end -plugin = RiPlugin.new -plugin.register("ri") -plugin.register("msgri") diff --git a/data/rbot/plugins/ri.rb b/data/rbot/plugins/ri.rb index f55cdf4d..5bde894c 100644 --- a/data/rbot/plugins/ri.rb +++ b/data/rbot/plugins/ri.rb @@ -1,15 +1,27 @@ +#-- vim:sw=2:et +#++ +# +# :title: 'ri' -- ruby documentation plugin +# +# Author: Michael Brailsford <brailsmt@yahoo.com> aka brailsmt +# Author:: dmitry kim <dmitry dot kim at gmail dot com> +# Copyright:: (C) 2007, dmitry kim +# Copyright:: (C) Michael Brailsford +# License:: MIT +# + class RiPlugin < Plugin + RI_COMMAND = %w{ri -f simple -T} + BotConfig.register BotConfigIntegerValue.new('ri.max_length', :default => 512, :desc => "Maximum length of ri entry (in bytes) which is ok to be sent to channels") - - RI_COMMAND = %w{ri -f simple -T} - def help(plugin, topic="") "ri <something> => returns ruby documentation for <something>" end + def ri(m, params) args = RI_COMMAND.dup if a = params[:something] @@ -34,6 +46,6 @@ class RiPlugin < Plugin return end end + plugin = RiPlugin.new -plugin.map 'ri :something', - :requirements => {:something => /^((-c)|(\w\S+))$/} +plugin.map 'ri :something', :requirements => {:something => /^((-c)|(\w\S+))$/} |