From 226478abaea81609abe7f78bfddf1fb1895d07a7 Mon Sep 17 00:00:00 2001 From: nebula Date: Mon, 16 Dec 2024 15:49:43 -0600 Subject: [PATCH] i didnt test this lol --- README.md | 9 ++++++++- main.py | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 31c8b87..9e3d88f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.py b/main.py index ed0b02d..f512b9b 100644 --- a/main.py +++ b/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: