-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from .beep import BeepCommand | ||
from .qotd import QotdCommand | ||
from .trivia import TriviaCommand | ||
from .aster import AsterCommand | ||
|
||
__all__ = ["BeepCommand", "QotdCommand"] | ||
__all__ = ["BeepCommand", "QotdCommand", "TriviaCommand"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from signalbot import Command, Context | ||
import openai | ||
import os | ||
openai.organization = "org-39lwdYbHwZNWOWJ9k9IrCctR" | ||
openai.api_key = os.getenv("OPENAI_API_KEY") | ||
|
||
class AsterCommand(Command): | ||
def describe(self) -> str: | ||
return "OpenAI Trigger" | ||
|
||
async def handle(self, c: Context): | ||
command = c.message.text | ||
if "aster" in command.lower(): | ||
await c.start_typing() | ||
await c.react('🤖') | ||
response = openai.ChatCompletion.create( | ||
model="gpt-3.5-turbo", | ||
messages=[ | ||
{"role": "system", "content": "You are a chat bot called Asterbot. You are here to assisted The Constellation which consists of Alli, Jen, Ellie, and Sae. They are a queer polycule"}, | ||
{"role": "user", "content": command} | ||
] | ||
) | ||
await c.reply(response.choices[0].message) | ||
await c.stop_typing() | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from signalbot import Command, Context | ||
from trivia import trivia | ||
|
||
curr = None | ||
|
||
class Trivia: | ||
def __init__(self, category, type, difficulty, question, correct_answer): | ||
self.category = category | ||
self.type = type | ||
self.difficulty = difficulty | ||
self.question = question | ||
self. correct_answer = correct_answer | ||
|
||
|
||
class TriviaCommand(Command): | ||
def describe(self) -> str: | ||
return "🏓 Beep Command: Listen for a beep" | ||
|
||
async def handle(self, c: Context): | ||
command = c.message.text | ||
global curr | ||
|
||
if command == "trivia": | ||
await c.start_typing() | ||
print("command trivia triggered") | ||
await c.react('🤖') | ||
question = await trivia.question(amount=1, category=0, difficulty='easy', quizType='multiple') | ||
q = question[0] | ||
curr = Trivia(q.get("category"), q.get("type"), q.get("difficulty"), q.get("question"), q.get("correct_answer")) | ||
res = f"🧠Today's trivia is in the {curr.category} category! \n❓Question: {curr.question}" | ||
await c.reply(f"{res}") | ||
await c.stop_typing() | ||
return | ||
|
||
if command == "trivia answer": | ||
await c.start_typing() | ||
print("command trivia triggered") | ||
await c.react('🤖') | ||
await c.reply(f"The answer is: {curr.correct_answer}") | ||
await c.stop_typing() | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
signalbot~=0.6.0 | ||
|
||
requests~=2.30.0 | ||
selenium~=4.9.1 | ||
beautifulsoup4~=4.12.2 | ||
schedule~=1.2.0 | ||
signalbot | ||
chromedriver_autoinstaller | ||
requests | ||
selenium | ||
beautifulsoup4 | ||
schedule | ||
trivia.py | ||
openai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import os | ||
|
||
from actions.qotd import get_qotd | ||
|
||
|
||
def send_qotd(bot): | ||
print("triggered send_qotd") | ||
bot.send(f"❓QOTD: {get_qotd()}") | ||
bot.send(os.environ["GROUP_ID"], f"❓QOTD: {get_qotd()}") |