6 # return a help string when the bot is asked for help on this plugin
7 def help(plugin, topic="")
8 return "rubyurl <your long url>"
11 def shorten(m, params)
12 if (params[:url] == "help")
13 m.reply help(m.plugin)
19 to_uri = URI.parse(url)
20 # We don't accept 'generic' URLs because almost everything gets in there
21 raise URI::InvalidURIError if to_uri.class == URI::Generic
22 rescue URI::InvalidURIError
23 m.reply "#{url} doesn't look like an URL to me ..."
27 short = WWW::ShortURL.shorten(url)
29 m.reply "#{url} shortened to #{short} on RubyURL"
34 # create an instance of the RubyURL class and register it as a plugin
36 rubyurl.map "rubyurl :url", :action => 'shorten'