X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Furban.rb;h=a24ac072091f7ed3d4d75031da89460060d94829;hb=26d2e36ff08de4e3bbf510616d4c8dac6da9d6d0;hp=1a4b9d74e34562d823a7e487cbc8238a2f600fd1;hpb=a7c40c145f5be6c7c99752bb0af93c0735971694;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/urban.rb b/data/rbot/plugins/urban.rb index 1a4b9d74..a24ac072 100644 --- a/data/rbot/plugins/urban.rb +++ b/data/rbot/plugins/urban.rb @@ -1,95 +1,77 @@ class UrbanPlugin < Plugin + URBAN = 'http://www.urbandictionary.com/define.php?term=' def help( plugin, topic="") "urban [word] [n]: give the [n]th definition of [word] from urbandictionary.com. urbanday: give the word-of-the-day at urban" end + def format_definition(total, num, word, desc, ex) + "#{Bold}#{word} (#{num}/#{total})#{Bold}: " + + desc.ircify_html(:limit => 300) + " " + + "#{ex}".ircify_html(:limit => 100) + end + + def get_def(m, word, n = nil) + n = n ? n.to_i : 1 + u = URBAN + URI.escape(word) + u += '&skip=' + n.to_s if n + s = @bot.httputil.get(u) + + notfound = s.match %r{