i didnt test this lol
parent
579de56d44
commit
226478abae
|
@ -1,10 +1,17 @@
|
|||
# mysterious_cube
|
||||
# The Mysterious Cube
|
||||
|
||||
An IRC bot.
|
||||
|
||||
APIs used:
|
||||
* https://opentdb.com/
|
||||
* https://llama.mcopp.com/
|
||||
* https://documenter.getpostman.com/view/664302/S1ENwy59
|
||||
* https://www.geonames.org/export/web-services.html
|
||||
* https://customsearch.googleapis.com/customsearch/v1
|
||||
|
||||
## !birds
|
||||
|
||||
it posts tweet tweets
|
||||
|
||||
## !trivia
|
||||
|
||||
|
|
18
main.py
18
main.py
|
@ -178,7 +178,7 @@ def post_birds(channel, username, arguments):
|
|||
return f"No data found for {arguments}"
|
||||
return birds
|
||||
|
||||
def get_question(ai_enabled=False):
|
||||
def get_question():
|
||||
global trivia_questions
|
||||
global trivia_unselected
|
||||
if trivia_questions:
|
||||
|
@ -186,7 +186,7 @@ def get_question(ai_enabled=False):
|
|||
trivia_unselected = trivia_questions.copy()
|
||||
question = choice(trivia_unselected)
|
||||
trivia_unselected.remove(question)
|
||||
question.append(ai_enabled)
|
||||
write_state()
|
||||
# print(len(unselected))
|
||||
return question
|
||||
else:
|
||||
|
@ -204,7 +204,7 @@ def post_question(channel, username, arguments):
|
|||
|
||||
def post_ai_question(channel, username, arguments):
|
||||
global ai_state
|
||||
question = get_question(ai_enabled=True)
|
||||
question = get_question()
|
||||
if question:
|
||||
ai_state[channel] = question
|
||||
write_state()
|
||||
|
@ -216,7 +216,7 @@ def ai_answer(choice, channel, name):
|
|||
global ai_state
|
||||
if channel not in ai_state.keys():
|
||||
return None
|
||||
question_text , answer, ai_enabled = ai_state[channel]
|
||||
question_text , answer = ai_state[channel]
|
||||
user_correct = False
|
||||
try:
|
||||
llm_response = llama_response(question_text)
|
||||
|
@ -229,11 +229,13 @@ def ai_answer(choice, channel, name):
|
|||
if llm_answer:
|
||||
llm_answer = llm_answer.group(1)
|
||||
if llm_answer.lower() == answer:
|
||||
line = "The AI was (at least kind of) right! "
|
||||
user_correct = choice == "right"
|
||||
w = "right" if user_correct else "wrong"
|
||||
line = f"Your guess was {w}! The AI was (at least kind of) right. "
|
||||
else:
|
||||
line = "The AI was wrong! "
|
||||
user_correct = choice == "wrong"
|
||||
w = "right" if user_correct else "wrong"
|
||||
line = f"Your guess was {w}! The AI was wrong. "
|
||||
else:
|
||||
return [
|
||||
f"Cannot automatically determine if AI is right or wrong.",
|
||||
|
@ -268,11 +270,11 @@ def answer(choice, channel, name):
|
|||
global trivia_state
|
||||
if channel not in trivia_state.keys():
|
||||
return None
|
||||
_, answer, ai_enabled = trivia_state[channel]
|
||||
_, answer = trivia_state[channel]
|
||||
del trivia_state[channel]
|
||||
write_state()
|
||||
line = f"The answer is {answer}!"
|
||||
if not ai_enabled and name:
|
||||
if name:
|
||||
if name not in trivia_scores.keys():
|
||||
trivia_scores[name] = 0
|
||||
if choice == answer:
|
||||
|
|
Loading…
Reference in New Issue