Initial commit of botqui (ruby)
This commit is contained in:
parent
bf08959178
commit
55b712b4ad
7 changed files with 134755 additions and 0 deletions
36
trivia_master.rb
Normal file
36
trivia_master.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
class TriviaMaster
|
||||
def initialize()
|
||||
@questions = []
|
||||
|
||||
File.open("triv_questions_new.txt").each_line{|line|
|
||||
@questions.push(line)
|
||||
}
|
||||
end
|
||||
|
||||
def get_question()
|
||||
q = @questions.sample
|
||||
questionBits = q.split('*')
|
||||
# m.reply questionBits.inspect
|
||||
|
||||
qData = {}
|
||||
qData['question'] = questionBits[0].strip
|
||||
qData['answer'] = questionBits[1].strip
|
||||
|
||||
# mask this somehow. answer "I did it" would become "* *** **"
|
||||
mask = ""
|
||||
questionBits[1].strip().each_char{|c|
|
||||
# this is so ugly.
|
||||
if c == '-' or c == '\'' or c == ':' or c == "," or c == "." or c == "!" or c == "?" or c == "%" or c == "&" then
|
||||
mask = mask + c
|
||||
elsif c == ' ' then
|
||||
mask = mask + ' '
|
||||
else
|
||||
mask = mask + '*'
|
||||
end
|
||||
}
|
||||
|
||||
qData['answer_mask'] = mask
|
||||
|
||||
return qData
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue