diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-30 17:07:58 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-30 17:07:58 +0000 |
commit | 3be59fb29b5f503916648a476fa0ec607070ca56 (patch) | |
tree | 95aec510eb7000bf34d6f0c591be115f3a8ffffb /data | |
parent | 394b1ddf3ed866e20e0f67d2b4d9431587c9c1de (diff) |
Make rss feed handle lookup case insensitive
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/azgame.rb | 10 | ||||
-rw-r--r-- | data/rbot/plugins/rss.rb | 26 |
2 files changed, 16 insertions, 20 deletions
diff --git a/data/rbot/plugins/azgame.rb b/data/rbot/plugins/azgame.rb index f2da4fa2..ec804789 100644 --- a/data/rbot/plugins/azgame.rb +++ b/data/rbot/plugins/azgame.rb @@ -31,7 +31,7 @@ class AzGame @plugin = plugin
@lang = lang.to_sym
@word = word.downcase
- @range = [AZ_RULES[lang][:first], AZ_RULES[lang][:last]]
+ @range = [AZ_RULES[lang][:first].dup, AZ_RULES[lang][:last].dup]
def @range.to_s
return "%s -- %s" % self
end
@@ -380,16 +380,11 @@ class AzGamePlugin < Plugin debug "getting random word from dictionary, matching #{random}"
p = @bot.httputil.get_cached(rules[:url] % URI.escape(random))
debug p
- debug "here 1"
lemmi = Array.new
- debug "here 2"
good = rules[:good]
- debug "here 3"
# We look for a lemma composed by a single word and of length at least two
p.scan(/<span class="hwd">(.*?)<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i) { |prelemma, discard|
- debug "here 4"
lemma = prelemma.downcase
- debug "here 5"
debug "checking lemma #{lemma} (#{prelemma}) and discarding #{discard}"
next if wc.key?(lemma.to_sym)
if lemma =~ /^[a-z]+$/
@@ -400,11 +395,8 @@ class AzGamePlugin < Plugin debug "funky characters, not good"
end
}
- debug "here 6"
next if lemmi.empty?
- debug "here 7"
word = lemmi[rand(lemmi.length)]
- debug "here 8"
end
rescue => e
error "error #{e.inspect} while looking up a word"
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index dcbccb8c..16e1e643 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -118,6 +118,10 @@ class RSSFeedsPlugin < Plugin kill_threads
if @registry.has_key?(:feeds)
@feeds = @registry[:feeds]
+ @feeds.keys.grep(/[A-Z]/) { |k|
+ @feeds[k.downcase] = @feeds[k]
+ @feeds.delete(k)
+ }
else
@feeds = Hash.new
end
@@ -204,7 +208,7 @@ class RSSFeedsPlugin < Plugin rev = false
end
- feed = @feeds.fetch(handle, nil)
+ feed = @feeds.fetch(handle.downcase, nil)
unless feed
m.reply "I don't know any feeds named #{handle}"
return
@@ -246,7 +250,7 @@ class RSSFeedsPlugin < Plugin reply = String.new
@@mutex.synchronize {
@feeds.each { |handle, feed|
- next if wanted and !handle.match(wanted)
+ next if wanted and !handle.match(/#{wanted}/i)
reply << "#{feed.handle}: #{feed.url} (in format: #{feed.type ? feed.type : 'default'})"
(reply << " (watched)") if feed.watched_by?(m.replyto)
reply << "\n"
@@ -264,7 +268,7 @@ class RSSFeedsPlugin < Plugin reply = String.new
@@mutex.synchronize {
watchlist.each { |handle, feed|
- next if wanted and !handle.match(wanted)
+ next if wanted and !handle.match(/#{wanted}/i)
next unless feed.watched_by?(m.replyto)
reply << "#{feed.handle}: #{feed.url} (in format: #{feed.type ? feed.type : 'default'})\n"
}
@@ -284,8 +288,8 @@ class RSSFeedsPlugin < Plugin return
end
type = params[:type]
- if @feeds.fetch(handle, nil) && !force
- m.reply "There is already a feed named #{handle} (URL: #{@feeds[handle].url})"
+ if @feeds.fetch(handle.downcase, nil) && !force
+ m.reply "There is already a feed named #{handle} (URL: #{@feeds[handle.downcase].url})"
return
end
unless url
@@ -293,7 +297,7 @@ class RSSFeedsPlugin < Plugin return
end
@@mutex.synchronize {
- @feeds[handle] = RssBlob.new(url,handle,type)
+ @feeds[handle.downcase] = RssBlob.new(url,handle,type)
}
reply = "Added RSS #{url} named #{handle}"
if type
@@ -310,7 +314,7 @@ class RSSFeedsPlugin < Plugin return
end
@@mutex.synchronize {
- @feeds.delete(feed.handle)
+ @feeds.delete(feed.handle.downcase)
}
m.okay unless pass
return
@@ -318,10 +322,10 @@ class RSSFeedsPlugin < Plugin def replace_rss(m, params)
handle = params[:handle]
- if @feeds.key?(handle)
+ if @feeds.key?(handle.downcase)
del_rss(m, {:handle => handle}, true)
end
- if @feeds.key?(handle)
+ if @feeds.key?(handle.downcase)
m.reply "can't replace #{feed.handle}"
else
add_rss(m, params, true)
@@ -341,7 +345,7 @@ class RSSFeedsPlugin < Plugin end
feed = nil
@@mutex.synchronize {
- feed = @feeds.fetch(handle, nil)
+ feed = @feeds.fetch(handle.downcase, nil)
}
if feed
@@mutex.synchronize {
@@ -358,7 +362,7 @@ class RSSFeedsPlugin < Plugin end
def unwatch_rss(m, params, pass=false)
- handle = params[:handle]
+ handle = params[:handle].downcase
unless @feeds.has_key?(handle)
m.reply("dunno that feed")
return
|