Skip to content

Commit

Permalink
Merge pull request #293 from StampyAI/intfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt authored Jun 18, 2023
2 parents 1129a10 + 67cd951 commit 295106e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 33 deletions.
7 changes: 4 additions & 3 deletions modules/Factoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from modules.module import Module, Response
from utilities.serviceutils import ServiceMessage
from utilities.discordutils import DiscordUser
from utilities.utilities import get_user_handle, randbool, is_bot_dev
from utilities.utilities import get_user_handle, randbool, is_bot_dev, Utilities


class Factoids(Module):
Expand Down Expand Up @@ -217,17 +217,18 @@ def __str__(self):
@property
def test_cases(self):
return [

self.create_integration_test(
test_message="remember chriscanal is the person who wrote this test",
expected_response='Ok stampy, remembering that "chriscanal" is "the person who wrote this test"',
expected_response=f'Ok {Utilities.get_instance().discord_user.name}, remembering that "chriscanal" is "the person who wrote this test"',
),
self.create_integration_test(
test_message="list chriscanal",
expected_regex="values for factoid+",
),
self.create_integration_test(
test_message="forget that",
expected_response='Ok stampy, forgetting that "chriscanal" is "the person who wrote this test"',
expected_response=f'Ok {Utilities.get_instance().discord_user.name}, forgetting that "chriscanal" is "the person who wrote this test"',
),
]

Expand Down
12 changes: 4 additions & 8 deletions modules/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def process_message(self, message: ServiceMessage) -> Response:
self.log.info(self.class_name, warning="cannot use paid service") # DEBUG
return Response()

if Utilities.get_instance().test_mode:
return Response()

return Response(
confidence=3, callback=self.chatgpt_chat, args=[message], kwargs={}
)
Expand Down Expand Up @@ -159,11 +162,4 @@ async def chatgpt_chat(self, message: ServiceMessage) -> Response:
def __str__(self):
return "ChatGPT Module"

@property
def test_cases(self) -> list[IntegrationTest]:
return [
self.create_integration_test(
test_message="ChatGPT api is only hit in production because it is expensive?",
expected_response=CONFUSED_RESPONSE,
) # TODO write actual test for this
]
# TODO: integration tests that make sense
12 changes: 4 additions & 8 deletions modules/gpt3module.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def process_message(self, message: ServiceMessage) -> Response:
if not self.is_at_me(message):
return Response()

if Utilities.get_instance().test_mode:
return Response()

return Response(
confidence=2, callback=self.gpt3_chat, args=[message], kwargs={}
)
Expand Down Expand Up @@ -263,11 +266,4 @@ async def gpt3_question(self, message: ServiceMessage) -> Response:
def __str__(self):
return "GPT-3 Module"

@property
def test_cases(self) -> list[IntegrationTest]:
return [
self.create_integration_test(
test_message="GPT3 api is only hit in production because it is expensive?",
expected_response=CONFUSED_RESPONSE,
) # TODO write actual test for this
]
# TODO: integration tests that make sense
9 changes: 0 additions & 9 deletions modules/sentience.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,3 @@ def process_message(self, message):

def __str__(self):
return "Sentience"

@property
def test_cases(self):
return [
self.create_integration_test(
test_message="If I asked you what 2+2 was and you answered incorrectly what would you have said?",
expected_response=CONFUSED_RESPONSE,
)
]
7 changes: 2 additions & 5 deletions modules/stampcollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from structlog import get_logger

from api.coda import CodaAPI
from utilities import is_in_testing_mode, utilities, Utilities
from utilities import is_in_testing_mode, utilities, Utilities, is_bot_dev
from modules.module import Module, Response
from config import stamp_scores_csv_file_path, coda_api_token
from servicemodules.serviceConstants import Services
Expand Down Expand Up @@ -337,10 +337,7 @@ def process_message(self, message):

elif text == "reloadallstamps":
if message.service == Services.DISCORD:
asked_by_admin = discord.utils.get(
message.author.roles, id=bot_admin_role_id
)
if asked_by_admin:
if is_bot_dev(message.author):
return Response(
confidence=10, callback=self.reloadallstamps, args=[message]
)
Expand Down

0 comments on commit 295106e

Please sign in to comment.