Sha256: f8a25612065712c3b578a8df25703e209502552a4627773d4e9eeddc8a6cf09b
Contents?: true
Size: 603 Bytes
Versions: 14
Compression:
Stored size: 603 Bytes
Contents
require 'open-uri' module Cinch module Plugins class Shorturl include Cinch::Plugin match /short (https?:\/\/[^ ]*)/ 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
14 entries across 14 versions & 1 rubygems