summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/urban.rb
diff options
context:
space:
mode:
authorMark Kretschmann <markey@web.de>2006-08-23 16:37:07 +0000
committerMark Kretschmann <markey@web.de>2006-08-23 16:37:07 +0000
commit63dd4c071f29828020ccc0138a6e939b4116187c (patch)
treec7202b58ecb42674dd1ec6c248d0ad8ede78ac1b /data/rbot/plugins/urban.rb
parenta0ab9e6d8022db22dd66412bb7a9087098e2faa2 (diff)
Show the page number again.
Diffstat (limited to 'data/rbot/plugins/urban.rb')
-rw-r--r--data/rbot/plugins/urban.rb20
1 files changed, 7 insertions, 13 deletions
diff --git a/data/rbot/plugins/urban.rb b/data/rbot/plugins/urban.rb
index c317eab1..246251ec 100644
--- a/data/rbot/plugins/urban.rb
+++ b/data/rbot/plugins/urban.rb
@@ -16,18 +16,11 @@ class UrbanPlugin < Plugin
end
def privmsg( m )
-
- unless(m.params && m.params.length > 0)
- m.reply "incorrect usage: " + help(m.plugin)
- return
- end
-
- paramArray = m.params.split(' ')
definitionN = 0
- if m.params == 'random' then
- uri = URI.parse( "http://www.urbandictionary.com/random.php" )
- else
- if( paramArray.last.to_i != 0 ) then
+
+ if m.params
+ paramArray = m.params.split(' ')
+ if paramArray.last.to_i != 0
definitionN = paramArray.last.to_i - 1
query = m.params.chomp( paramArray.last )
query.rstrip!
@@ -35,6 +28,8 @@ class UrbanPlugin < Plugin
query = m.params
end
uri = URI.parse( "http://www.urbandictionary.com/define.php?term=#{ URI.escape query}" )
+ else
+ uri = URI.parse( "http://www.urbandictionary.com/random.php" )
end
soup = BeautifulSoup.new( @bot.httputil.get_cached( uri ) )
@@ -45,14 +40,13 @@ class UrbanPlugin < Plugin
output = Array.new
if results[definitionN] then
results[definitionN].p.contents.each { |s| output.push( strip_tags( s.to_s ) ) }
- m.reply "\002#{title}\002 - #{output}"
+ m.reply "\002#{title}\002 - #{output} (#{definitionN+1}/#{results.length})"
else
m.reply "#{query} does not have #{definitionN + 1} definitions."
end
else
m.reply "#{m.params} not found."
end
-
end
def strip_tags(html)