Removing the old triv app. All hail trev.

This commit is contained in:
Monqui 2025-07-16 01:39:18 +00:00
parent 55b712b4ad
commit 1594fcfb47
5 changed files with 0 additions and 134100 deletions

View file

@ -10,8 +10,6 @@ require 'net/http'
require 'json'
require 'htmlentities'
load "trivia_master.rb"
def fix_nick(n)
return n[0] + "\uFEFF" + n[1,n.length]
end
@ -59,9 +57,6 @@ bot = Cinch::Bot.new do
last_saids = {}
trivData = {}
isTriv = false
trev_running = false
trev_answers_running = false
trev_guesses = {}
@ -328,89 +323,6 @@ bot = Cinch::Bot.new do
end
end
on :channel, /^!triv$/ do |m|
if isTriv == false then
tm = TriviaMaster.new()
trivData = tm.get_question()
# m.reply questionBits.inspect
isTriv = true
end
m.reply trivData['question'] + " " + trivData['answer_mask']
end
on :channel, /^!trivstop$/ do |m|
isTriv = false
m.reply "Stopping trivia."
end
on :channel, /^!trivhint$/ do |m|
new_mask = trivData['answer_mask']
starPositions = []
for i in 0 .. new_mask.length-1
if new_mask[i] == '*' then starPositions.push(i) end
end
if starPositions.length == 0 and isTriv == true then
isTriv = false
m.reply "HOLY TITS botqui WON"
if !data['trivias'].key?('botqui') then
data['trivias']['botqui'] = 0
end
data['trivias'][nick] = data['trivias'][nick] + 1
File.open("data.bd", 'w') { |file| file.write(JSON.generate(data)) }
m.reply "botqui currently has " + data['trivias']['botqui'].to_s + " wins."
else
revealPos = starPositions.sample
new_mask[revealPos] = trivData['answer'][revealPos]
trivData['answer_mask'] = new_mask
m.reply trivData['answer_mask']
end
end
on :channel, /^(.*)$/ do |m, val|
if isTriv then
val = val.downcase
if val.downcase == trivData['answer'].downcase then
m.reply "YOU WON HOLY SHIT - the answer was " + trivData['answer']
isTriv = false
nick = m.user.nick
if !data['trivias'].key?(nick) then
data['trivias'][nick] = 0
end
data['trivias'][nick] = data['trivias'][nick] + 1
File.open("data.bd", 'w') { |file| file.write(JSON.generate(data)) }
m.reply nick + " currently has " + data['trivias'][nick].to_s + " wins."
else
tmp_answer = trivData['answer'].downcase
new_mask = trivData['answer_mask']
found = false
for i in 0 .. [val.length, trivData['answer'].length].min
if val[i] == tmp_answer[i] and trivData['answer_mask'][i] == '*' then
found = true
new_mask[i] = trivData['answer'][i]
end
end
trivData['answer_mask'] = new_mask
if found then
m.reply new_mask + " (!trivstop to stop)"
end
end
end
end
on :channel, /^!imgur (.*)$/ do |m, tag|
m.reply "http://i.imgur.com/" + tag
end

0
test
View file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,36 +0,0 @@
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