Sha256: b6100157a216bd32d266a963eea2b6dd9b10bc23c413dbd8fd481789969a6ec3
Contents?: true
Size: 617 Bytes
Versions: 2
Compression:
Stored size: 617 Bytes
Contents
require 'open-uri' module Cinch module Plugins class Shorturl include Cinch::Plugin match /(http:\/\/[^ ]*)/, :use_prefix => false set :plugin_name, 'shorturl' set :help, <<EOT Shorturl catches urls said on channel and shorten then EOT def shorten(url) url = open("http://tinyurl.com/api-create.php?url=#{URI.escape(url)}").read url == "Error" ? nil : url rescue OpenURI::HTTPError nil end def new(bot) @bot = bot end def execute(m,url) m.reply("Shortening: " + shorten(url)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cogbot-0.0.3 | plugins/shorturl.rb |
cogbot-0.0.2 | plugins/shorturl.rb |