-
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.
Merge pull request #1 from alliraine/achapman/major_update_1
Achapman/major update 1
- Loading branch information
Showing
10 changed files
with
1,106 additions
and
43 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,5 @@ | ||
from .beep import BeepCommand | ||
from .qotd import QotdCommand | ||
from .aster import AsterCommand | ||
|
||
__all__ = ["BeepCommand", "QotdCommand"] | ||
__all__ = ["BeepCommand", "QotdCommand", "AsterCommand"] |
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,26 @@ | ||
from signalbot import Command, Context | ||
import openai | ||
import os | ||
|
||
class AsterCommand(Command): | ||
def describe(self) -> str: | ||
return "OpenAI Trigger" | ||
|
||
async def handle(self, c: Context): | ||
command = c.message.text | ||
print(c.message.mentions) | ||
if len(c.message.mentions) > 0: | ||
if "2219a1a4-828b-4af1-9804-ca839236d40f" in c.message.mentions[0]["uuid"]: | ||
await c.start_typing() | ||
await c.react('🤖') | ||
openai.api_key = os.getenv("OPEN_AI") | ||
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 a queer lesbian polycule which consists of Alli, Jen, Ellie, and Sae."}, | ||
{"role": "user", "content": command} | ||
] | ||
) | ||
await c.send(response.choices[0].message.content) | ||
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,32 +1,29 @@ | ||
from selenium.webdriver.chrome.options import Options | ||
from signalbot import Command, Context | ||
from bs4 import BeautifulSoup | ||
import requests | ||
from selenium import webdriver | ||
from signalbot import Command, Context, triggered | ||
|
||
|
||
def get_qotd(): | ||
options = Options() | ||
options.headless = True | ||
driver = webdriver.Chrome(options=options) | ||
driver.get('https://randomwordgenerator.com/question.php') | ||
html = driver.page_source | ||
soup = BeautifulSoup(html, 'html.parser') | ||
s = soup.find('ol', id='result') | ||
driver.quit() | ||
return s.find('span', class_='support-sentence').text | ||
file = open("data/random_questions.csv", "r") | ||
questions = file.read() | ||
question_list = questions.split('\n') | ||
|
||
question = question_list[0] | ||
|
||
with open('data/random_questions.csv', 'w') as fp: | ||
fp.write('\n'.join(question_list[1:])) | ||
|
||
return question | ||
|
||
|
||
class QotdCommand(Command): | ||
def describe(self) -> str: | ||
return "🏓 Beep Command: Listen for a beep" | ||
|
||
@triggered("qotd") | ||
async def handle(self, c: Context): | ||
command = c.message.text | ||
|
||
if command == "qotd": | ||
print("command qotd triggered") | ||
await c.react('🤖') | ||
qotd = get_qotd() | ||
await c.send(f"❓QOTD: {qotd}") | ||
return | ||
await c.start_typing() | ||
print("command qotd triggered") | ||
await c.react('🤖') | ||
qotd = get_qotd() | ||
await c.reply(f"❓QOTD: {qotd}") | ||
await c.stop_typing() | ||
return |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
Oops, something went wrong.