summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/dictclient.rb4
-rw-r--r--data/rbot/plugins/factoids.rb2
-rw-r--r--data/rbot/plugins/games/quiz.rb44
-rw-r--r--data/rbot/plugins/games/uno.rb12
-rwxr-xr-xdata/rbot/plugins/geoip.rb18
-rw-r--r--data/rbot/plugins/imdb.rb4
-rw-r--r--data/rbot/plugins/iplookup.rb10
-rw-r--r--data/rbot/plugins/lastfm.rb18
-rw-r--r--data/rbot/plugins/rss.rb4
-rw-r--r--data/rbot/plugins/slashdot.rb6
-rw-r--r--data/rbot/plugins/urban.rb2
-rw-r--r--lib/rbot/botuser.rb4
-rw-r--r--lib/rbot/core/auth.rb2
-rw-r--r--lib/rbot/core/utils/filters.rb6
-rw-r--r--lib/rbot/core/utils/httputil.rb2
-rwxr-xr-xlib/rbot/core/utils/wordlist.rb4
16 files changed, 69 insertions, 73 deletions
diff --git a/data/rbot/plugins/dictclient.rb b/data/rbot/plugins/dictclient.rb
index 34276dad..f55defa4 100644
--- a/data/rbot/plugins/dictclient.rb
+++ b/data/rbot/plugins/dictclient.rb
@@ -91,7 +91,7 @@ class DictClientPlugin < Plugin
# the DICT object is automatically disconnected. the return value of the block
# is returned from this method.
# if an IRC message argument is passed, the error message will be replied
- def with_dict(m=nil &block)
+ def with_dict(m=nil, &block)
server, port = @bot.config['dictclient.server'].split ':' if @bot.config['dictclient.server']
server ||= 'dict.org'
port ||= DICT::DEFAULT_PORT
@@ -159,7 +159,7 @@ class DictClientPlugin < Plugin
if results
results.collect {|database, matches|
@bot.config['dictclient.match_format'].gsub(
- '<matches>', matches.collect {|m| format_headword m}.join(', ')
+ '<matches>', matches.collect {|hit| format_headword hit}.join(', ')
).gsub(
'<database>', format_database(database)
)
diff --git a/data/rbot/plugins/factoids.rb b/data/rbot/plugins/factoids.rb
index 3ca19017..452efb98 100644
--- a/data/rbot/plugins/factoids.rb
+++ b/data/rbot/plugins/factoids.rb
@@ -65,7 +65,7 @@ class FactoidsPlugin < Plugin
def index(f)
fact = f.to_s
return if fact.empty?
- self.map { |f| f[:fact] }.index(fact)
+ self.map { |fs| fs[:fact] }.index(fact)
end
def delete(f)
diff --git a/data/rbot/plugins/games/quiz.rb b/data/rbot/plugins/games/quiz.rb
index 63a5dde4..d2e4ab97 100644
--- a/data/rbot/plugins/games/quiz.rb
+++ b/data/rbot/plugins/games/quiz.rb
@@ -285,8 +285,10 @@ class QuizPlugin < Plugin
jokers = q.registry[nick].jokers
rank = 0
- q.rank_table.each_index { |rank| break if nick.downcase == q.rank_table[rank][0].downcase }
- rank += 1
+ q.rank_table.each do |place|
+ rank += 1
+ break if nick.downcase == place[0].downcase
+ end
m.reply "#{nick}'s score is: #{score} Rank: #{rank} Jokers: #{jokers}"
else
@@ -313,45 +315,41 @@ class QuizPlugin < Plugin
stats = q.registry[nick]
# Find player in table
- found_player = false
- i = 0
- q.rank_table.each_index do |i|
- if nick.downcase == q.rank_table[i][0].downcase
- found_player = true
+ old_rank = nil
+ q.rank_table.each_with_index do |place, i|
+ if nick.downcase == place[0].downcase
+ old_rank = i
break
end
end
# Remove player from old position
- if found_player
- old_rank = i
- q.rank_table.delete_at( i )
- else
- old_rank = nil
+ if old_rank
+ q.rank_table.delete_at( old_rank )
end
# Insert player at new position
- inserted = false
- q.rank_table.each_index do |i|
- if stats.score > q.rank_table[i][1].score
+ new_rank = nil
+ q.rank_table.each_with_index do |place, i|
+ if stats.score > place[1].score
q.rank_table[i,0] = [[nick, stats]]
- inserted = true
+ new_rank = i
break
end
end
# If less than all other players' scores, append to table
- unless inserted
- i += 1 unless q.rank_table.empty?
+ unless new_rank
+ new_rank = q.rank_table.length
q.rank_table << [nick, stats]
end
# Print congratulations/condolences if the player's rank has changed
- unless old_rank.nil?
- if i < old_rank
- m.reply "#{nick} ascends to rank #{i + 1}. Congratulations :)"
- elsif i > old_rank
- m.reply "#{nick} slides down to rank #{i + 1}. So Sorry! NOT. :p"
+ if old_rank
+ if new_rank < old_rank
+ m.reply "#{nick} ascends to rank #{new_rank + 1}. Congratulations :)"
+ elsif new_rank > old_rank
+ m.reply "#{nick} slides down to rank #{new_rank + 1}. So Sorry! NOT. :p"
end
end
else
diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb
index 75154362..ab0ea161 100644
--- a/data/rbot/plugins/games/uno.rb
+++ b/data/rbot/plugins/games/uno.rb
@@ -772,9 +772,9 @@ class UnoGame
}
return false
end
- if p = get_player(user)
+ if pl = get_player(user)
announce _("%{p} is already playing %{uno} here") % {
- :p => p, :uno => UNO
+ :p => pl, :uno => UNO
}
return false
end
@@ -831,12 +831,12 @@ class UnoGame
deal(p, @picker)
@picker = 0
end
- score = @players.inject(0) do |sum, p|
- if p.cards.length > 0
+ score = @players.inject(0) do |sum, pl|
+ if pl.cards.length > 0
announce _("%{p} still had %{cards}") % {
- :p => p, :cards => p.cards.join(' ')
+ :p => pl, :cards => pl.cards.join(' ')
}
- sum += p.cards.inject(0) do |cs, c|
+ sum += pl.cards.inject(0) do |cs, c|
cs += c.score
end
end
diff --git a/data/rbot/plugins/geoip.rb b/data/rbot/plugins/geoip.rb
index c67f1095..c76310d5 100755
--- a/data/rbot/plugins/geoip.rb
+++ b/data/rbot/plugins/geoip.rb
@@ -70,6 +70,12 @@ module ::GeoIP
end
end
+ JUMP_TABLE = {
+ "ipinfodb" => Proc.new { |ip| ipinfodb(ip) },
+ "kapsi" => Proc.new { |ip| kapsi(ip) },
+ "geoiptool" => Proc.new { |ip| geoiptool(ip) },
+ }
+
def self.resolve(hostname, api)
raise InvalidHostError unless valid_host?(hostname)
@@ -79,15 +85,9 @@ module ::GeoIP
raise InvalidHostError
end
- jump_table = {
- "ipinfodb" => Proc.new { |ip| ipinfodb(ip) },
- "kapsi" => Proc.new { |ip| kapsi(ip) },
- "geoiptool" => Proc.new { |ip| geoiptool(ip) },
- }
-
- raise BadAPIError unless jump_table.key?(api)
+ raise BadAPIError unless JUMP_TABLE.key?(api)
- return jump_table[api].call(ip)
+ return JUMP_TABLE[api].call(ip)
end
end
@@ -153,7 +153,7 @@ class GeoIpPlugin < Plugin
if m.replyto.class == Channel
# check if there is an user on the channel with nick same as input given
- user = m.replyto.users.find { |user| user.nick == params[:input] }
+ user = m.replyto.users.find { |usr| usr.nick == params[:input] }
if user
m.reply host2output(user.host, user.nick)
diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb
index a12b7784..e1209124 100644
--- a/data/rbot/plugins/imdb.rb
+++ b/data/rbot/plugins/imdb.rb
@@ -309,8 +309,8 @@ class Imdb
}
end
- urls.map { |url|
- info = info_name(url, :movies_by_year => true)
+ urls.map { |u|
+ info = info_name(u, :movies_by_year => true)
debug info.inspect
diff --git a/data/rbot/plugins/iplookup.rb b/data/rbot/plugins/iplookup.rb
index 495aa614..65867a50 100644
--- a/data/rbot/plugins/iplookup.rb
+++ b/data/rbot/plugins/iplookup.rb
@@ -116,12 +116,12 @@ module ArinWhois
def get_parsed_data
return unless chunks = parse_chunks
- results = split_array_at(parse_chunks) {|chunk|chunk.customer?}
- results.map do |chunks|
+ results = split_array_at(chunks) {|chunk|chunk.customer?}
+ results.map do |data|
{
- :customer => chunks.select{|x|x.customer?}[0],
- :net => chunks.select{|x|x.network?}[0],
- :contacts => chunks.select{|x|x.contact?}
+ :customer => data.select{|x|x.customer?}[0],
+ :net => data.select{|x|x.network?}[0],
+ :contacts => data.select{|x|x.contact?}
}
end
end
diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb
index 2e4c5114..4255e8a5 100644
--- a/data/rbot/plugins/lastfm.rb
+++ b/data/rbot/plugins/lastfm.rb
@@ -194,11 +194,11 @@ class LastFmPlugin < Plugin
elsif venue
begin
venues = search_venue_by(:name => venue.to_s, :limit => 1)
- rescue Exception => e
- error e
+ rescue Exception => err
+ error err
m.reply _("an error occurred looking for venue %{venue}: %{e}") % {
:venue => venue.to_s,
- :e => e.message
+ :e => err.message
}
end
@@ -453,11 +453,11 @@ class LastFmPlugin < Plugin
if results > 0
begin
hits = []
- doc.root.each_element("results/trackmatches/track") do |track|
+ doc.root.each_element("results/trackmatches/track") do |trck|
hits << _("%{bold}%{t}%{bold} by %{bold}%{a}%{bold} (%{n} listeners)") % {
- :t => track.elements["name"].text,
- :a => track.elements["artist"].text,
- :n => track.elements["listeners"].text,
+ :t => trck.elements["name"].text,
+ :a => trck.elements["artist"].text,
+ :n => trck.elements["listeners"].text,
:bold => Bold
}
end
@@ -608,8 +608,8 @@ class LastFmPlugin < Plugin
begin
res = @bot.httputil.get_response(uri)
raise _("no response body") unless res.body
- rescue Exception => e
- m.reply _("I had problems accessing last.fm: %{e}") % {:e => e.message}
+ rescue Exception => err
+ m.reply _("I had problems accessing last.fm: %{e}") % {:e => err.message}
return
end
doc = Document.new(res.body)
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb
index 6b163619..4280c52a 100644
--- a/data/rbot/plugins/rss.rb
+++ b/data/rbot/plugins/rss.rb
@@ -935,8 +935,8 @@ class RSSFeedsPlugin < Plugin
stop_watches
# Read watches from list.
- watchlist.each{ |handle, feed|
- watchRss(feed, m)
+ watchlist.each{ |hndl, fd|
+ watchRss(fd, m)
}
m.okay if m
end
diff --git a/data/rbot/plugins/slashdot.rb b/data/rbot/plugins/slashdot.rb
index 69f1566f..2c4a2361 100644
--- a/data/rbot/plugins/slashdot.rb
+++ b/data/rbot/plugins/slashdot.rb
@@ -75,9 +75,9 @@ class SlashdotPlugin < Plugin
debug xml.inspect
begin
doc = Document.new xml
- rescue REXML::ParseException => e
- warning e.inspect
- m.reply "couldn't parse output XML: #{e.class}"
+ rescue REXML::ParseException => err
+ warning err.inspect
+ m.reply "couldn't parse output XML: #{err.class}"
return
end
unless doc
diff --git a/data/rbot/plugins/urban.rb b/data/rbot/plugins/urban.rb
index 6c10ed4b..d6688306 100644
--- a/data/rbot/plugins/urban.rb
+++ b/data/rbot/plugins/urban.rb
@@ -34,7 +34,7 @@ class UrbanPlugin < Plugin
return m.reply("#{Bold}#{word}#{Bold} not found") if rv.empty?
if notfound
- suggestions = rv.map { |s| Underline + s[1] + Underline }.uniq.join ', '
+ suggestions = rv.map { |str| Underline + str[1] + Underline }.uniq.join ', '
m.reply "#{Bold}#{word}#{Bold} not found. maybe you mean #{suggestions}?"
return
end
diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb
index f7e41d97..4e93beb4 100644
--- a/lib/rbot/botuser.rb
+++ b/lib/rbot/botuser.rb
@@ -90,8 +90,8 @@ class Bot
#
def initialize(cmd)
cmdpath = sanitize_command_path(cmd).split('::')
- seq = cmdpath.inject(["*"]) { |list, cmd|
- list << (list.length > 1 ? list.last + "::" : "") + cmd
+ seq = cmdpath.inject(["*"]) { |list, cc|
+ list << (list.length > 1 ? list.last + "::" : "") + cc
}
@path = seq.map { |k|
k.to_sym
diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb
index 30f99ecf..465f8f5d 100644
--- a/lib/rbot/core/auth.rb
+++ b/lib/rbot/core/auth.rb
@@ -713,7 +713,7 @@ class AuthModule < CoreBotModule
def auth_list_users(m, params)
# TODO name regexp to filter results
- list = @bot.auth.save_array.inject([]) { |list, x| ['everyone', 'owner'].include?(x[:username]) ? list : list << x[:username] }
+ list = @bot.auth.save_array.inject([]) { |lst, x| ['everyone', 'owner'].include?(x[:username]) ? lst : lst << x[:username] }
if defined?(@destroy_q)
list.map! { |x|
@destroy_q.include?(x) ? x + _(" (queued for destruction)") : x
diff --git a/lib/rbot/core/utils/filters.rb b/lib/rbot/core/utils/filters.rb
index 463e6f38..d188aa3f 100644
--- a/lib/rbot/core/utils/filters.rb
+++ b/lib/rbot/core/utils/filters.rb
@@ -177,10 +177,10 @@ module ::Irc
def load_filters(options={})
case options[:path]
when nil
- file = "#{self.dirname}.rb"
+ us = "#{self.dirname}.rb"
paths = [
- File.join(Config::datadir, 'filters', file),
- @bot.path('filters', file)
+ File.join(Config::datadir, 'filters', us),
+ @bot.path('filters', us)
]
when Array
paths = options[:path]
diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb
index 25df3c5b..03671cfe 100644
--- a/lib/rbot/core/utils/httputil.rb
+++ b/lib/rbot/core/utils/httputil.rb
@@ -531,8 +531,6 @@ class HttpUtil
:method => :GET
}.merge(options)
- resp = nil
-
req_class = case opts[:method].to_s.downcase.intern
when :head, :"net::http::head"
opts[:max_redir] = -1
diff --git a/lib/rbot/core/utils/wordlist.rb b/lib/rbot/core/utils/wordlist.rb
index 4e624f9b..81d7d775 100755
--- a/lib/rbot/core/utils/wordlist.rb
+++ b/lib/rbot/core/utils/wordlist.rb
@@ -14,10 +14,10 @@ class Wordlist
@@wordlist_base ||= Utils.bot.path 'wordlists'
end
- def self.get(path, options={})
+ def self.get(where, options={})
opts = { :spaces => false }.merge(options)
- wordlist_path = File.join(wordlist_base, path)
+ wordlist_path = File.join(wordlist_base, where)
raise "wordlist not found: #{wordlist_path}" unless File.exist?(wordlist_path)
# Location is a directory -> combine all lists beneath it