diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2008-10-10 23:08:13 +0000 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2008-10-10 23:08:13 +0000 |
commit | c23c0acd01d43b452a9cf95d2e95975c566dd64d (patch) | |
tree | 560aa256cb64434061cf6af30c45ec259160966a /gentoo-tinyurl.rb | |
parent | Variant of searching borrowed from jeeves and based on the normal rbot google. (diff) | |
download | rbot-gentoo-c23c0acd01d43b452a9cf95d2e95975c566dd64d.tar.gz rbot-gentoo-c23c0acd01d43b452a9cf95d2e95975c566dd64d.tar.bz2 rbot-gentoo-c23c0acd01d43b452a9cf95d2e95975c566dd64d.zip |
Add automatic URL listener code.
Diffstat (limited to 'gentoo-tinyurl.rb')
-rw-r--r-- | gentoo-tinyurl.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gentoo-tinyurl.rb b/gentoo-tinyurl.rb new file mode 100644 index 0000000..5bbab71 --- /dev/null +++ b/gentoo-tinyurl.rb @@ -0,0 +1,30 @@ +require "shorturl" +class GentooShortenURLs < Plugin + def initialize + super + end + def lurk?(m) + replyto = nil + replyto = m.replyto.to_s if m.is_a?(Irc::UserMessage) + return true + return false unless replyto + end + def listen(m) + return if m.address? + return unless lurk?(m) + return unless m.message =~ /(\b|^)[a-z]+:\/\/.*($|\s)/i + m.message.split.each do |word| + next unless word =~ /(\b|^)[a-z]+:\/\/.*($|\s)/i + next unless word.length >= 32 + shrink(m, {:url => word}) + end + end + def shrink(m, params) + short = ShortURL.shorten(params[:url], :tinyurl) + m.reply short + end +end +plugin = GentooShortenURLs.new +plugin.map 't :url', + :action => 'shrink', + :auth_path => 'view' |