summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorRaine Virta <rane@kapsi.fi>2009-10-21 18:52:41 +0300
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-10-21 19:03:51 +0200
commit402c66aa5228f734e88abd7b3cdc482f71239553 (patch)
treedebcca2eae2274e17abeab721cea5ab0729089fb /data
parent49ddfa785796f3ae4550ace918fd8282bd91e42a (diff)
urban: fix page detection logic
numpages = s[%r{<div id='paginator'>.*?</div>}m].scan(/\d+/) ^ produces an error when regex returns nil
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/urban.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/data/rbot/plugins/urban.rb b/data/rbot/plugins/urban.rb
index f4355061..68ffadba 100644
--- a/data/rbot/plugins/urban.rb
+++ b/data/rbot/plugins/urban.rb
@@ -21,7 +21,9 @@ class UrbanPlugin < Plugin
notfound = s.match %r{<i>.*?</i> isn't defined}
- numpages = s[%r{<div id='paginator'>.*?</div>}m].scan(/\d+/).collect {|x| x.to_i}.max || 1
+ numpages = if s[%r{<div id='paginator'>.*?</div>}m]
+ $&.scan(/\d+/).collect {|x| x.to_i}.max
+ else 1 end
rv = Array.new
s.scan(%r{<td class='index'[^>]*>.*?(\d+)\..*?</td>.*?<td class='word'>(?:<a.*?>)?([^>]+)(?:</a>)?</td>.*?<div class='definition'>(.+?)</div>.*?<div class='example'>(.+?)</div>}m) do |num, wrd, desc, ex|