]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
from #32
authorTom Gilbert <tom@linuxbrit.co.uk>
Wed, 4 Jan 2006 17:20:31 +0000 (17:20 +0000)
committerTom Gilbert <tom@linuxbrit.co.uk>
Wed, 4 Jan 2006 17:20:31 +0000 (17:20 +0000)
data/rbot/plugins/lastfm.rb
data/rbot/plugins/markov.rb
data/rbot/plugins/quotes.rb
data/rbot/plugins/rubyurl.rb [new file with mode: 0644]

index 81b203f6a74e8a5b36717050e2a018a3bf56cc3d..1d48b6d0d13d21ae2999e600c9bc4d3350131f4f 100644 (file)
@@ -9,11 +9,8 @@ class LastFmPlugin < Plugin
 
   def do_lastfm (m, params)
     begin
-      if params[:action] == "neighbors" then
+      if params[:action] == "neighbors" || params[:action] == "neighbours" then
         params[:action]="neighbours"
-      elsif params[:action] == "neighbours" then
-        m.reply "Thats not how you spell neighbors, you dolt!"
-        return
       end
       data = open("http://ws.audioscrobbler.com/1.0/user/#{params[:user]}/#{params[:action]}.txt")
       m.reply "#{params[:action]} for #{params[:user]}:"
index 8d78831074a1ce0ed5690f77a84b64bddc13eb80..4f9895f673124873027b1614c8ff056bb10fbe2b 100644 (file)
@@ -2,6 +2,7 @@ class MarkovPlugin < Plugin
   def initialize
     super
     @registry.set_default([])
+    @registry['enabled'] = false unless @registry.has_key?('enabled')
     @lastline = false
   end
 
index 674a9ed6c71bee9e825426f5641f9a7ae0167579..6094737c1143403928e6d532c8e19ce25128299a 100644 (file)
@@ -99,7 +99,7 @@ class QuotePlugin < Plugin
       when "whenquote"
         return "whenquote [<channel>] <num> => show when quote <num> was added. You only need to supply <channel> if you are addressing #{@bot.nick} privately"
       else
-        return "Quote module (Quote storage and retrieval) topics: addquote, getquote, searchquote, topicquote, countquote, whoquote, whenquote"
+        return "Quote module (Quote storage and retrieval) topics: addquote, delquote, getquote, searchquote, topicquote, countquote, whoquote, whenquote"
     end
   end
   def listen(m)
diff --git a/data/rbot/plugins/rubyurl.rb b/data/rbot/plugins/rubyurl.rb
new file mode 100644 (file)
index 0000000..23019dc
--- /dev/null
@@ -0,0 +1,39 @@
+require "rubygems"
+require "shorturl"
+
+class RubyURL < Plugin
+
+  # return a help string when the bot is asked for help on this plugin
+  def help(plugin, topic="")
+    return "rubyurl <your long url>"
+  end
+
+  # reply to a private message that we've registered for
+  def privmsg(m)
+
+    # m.params contains the rest of the message, m.plugin contains the first
+    # word (useful because it's possible to register for multiple commands)
+    unless(m.params)
+      m.reply "incorrect usage. " + help(m.plugin)
+    end
+
+    # TODO: might want to add a check here to validate the url
+    # if they call 'rubyurl help' backwards, don't return a lame link
+
+    if (m.params == "help")
+      m.reply "Try again. Correct usage is: " + help(m.plugin)
+      return false
+    end
+
+    # call the ShortURL library with the value of the url
+    url = ShortURL.shorten(m.params)
+
+
+    m.reply "Your RubyURL: #{url}"
+
+  end
+end
+
+# create an instance of the RubyURL class and register it as a plugin
+rubyurl = RubyURL.new
+rubyurl.register("rubyurl")