diff options
author | Tom Gilbert <tom@linuxbrit.co.uk> | 2006-01-21 21:22:41 +0000 |
---|---|---|
committer | Tom Gilbert <tom@linuxbrit.co.uk> | 2006-01-21 21:22:41 +0000 |
commit | 119892c09183cf09ef5247664ec3d9daa7b7a042 (patch) | |
tree | 1f43472413abc351bddb4d6e7a4bc624c33e2e07 /data/rbot/plugins | |
parent | ddbe1833c44cc67a2a70d6548960a25b80166633 (diff) |
bunch of changes.
Another of Chris' plugins. A contributed russian.lang from ruskie (honest,
that's his nick!). Some tweaks to error handling. Some modified user/auth
handling (from DevRandom) still a bit more to do on that tho..
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/tinyurl.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/data/rbot/plugins/tinyurl.rb b/data/rbot/plugins/tinyurl.rb new file mode 100644 index 00000000..b74969d9 --- /dev/null +++ b/data/rbot/plugins/tinyurl.rb @@ -0,0 +1,39 @@ +require "rubygems" +require "shorturl" + +class TinyURL < Plugin + include WWW + + # return a help string when the bot is asked for help on this plugin + def help(plugin, topic="") + return "tinyurl <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, :tinyurl) + + m.reply "tinyurl: #{url}" + + end +end + +# create an instance of the RubyURL class and register it as a plugin +tinyurl = TinyURL.new +tinyurl.register("tinyurl") |