# (in quiz/) or web pages.
#
def fetch_data( m )
- # Read the winning messages file
+ # Read the winning messages file
@win_messages = Array.new
- if File.exists? "#{@bot.botclass}/quiz/win_messages"
- IO.foreach("#{@bot.botclass}/quiz/win_messages") { |line| @win_messages << line.chomp }
+ winfile = datafile 'win_messages'
+ if File.exists? winfile
+ IO.foreach(winfile) { |line| @win_messages << line.chomp }
else
warning( "win_messages file not found!" )
# Fill the array with a least one message or code accessing it would fail
m.reply "Failed to download questions from #{p}, ignoring sources"
end
else
- path = "#{@bot.botclass}/quiz/#{p}"
+ path = datafile p
debug "Fetching from #{path}"
# Local data
begin
- datafile = File.new( path, File::RDONLY )
- data << "\n\n" << datafile.read
+ file = File.new( path, File::RDONLY )
+ data << "\n\n" << file.read
rescue
m.reply "Failed to read from local database file #{p}, skipping."
end
end
end
- # If less than all other players' scores, append to table
+ # If less than all other players' scores, append to table
unless inserted
i += 1 unless q.rank_table.empty?
q.rank_table << [nick, stats]
message = m.message.downcase.strip
- nick = m.sourcenick.to_s
+ nick = m.sourcenick.to_s
# Support multiple alternate answers and cores
answer = q.answers.find { |ans| ans.valid?(message) }