-
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
7 changed files
with
1,034 additions
and
45 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,6 +1,5 @@ | ||
from .beep import BeepCommand | ||
from .qotd import QotdCommand | ||
from .trivia import TriviaCommand | ||
from .aster import AsterCommand | ||
|
||
__all__ = ["BeepCommand", "QotdCommand", "TriviaCommand"] | ||
__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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
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 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +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": | ||
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 | ||
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 |
Oops, something went wrong.