Skip to content

Commit

Permalink
minor fixes of types and user names
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Bagiński committed Jun 23, 2023
1 parent 87ce9cc commit 5a2513f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
3 changes: 1 addition & 2 deletions modules/Factoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
# dict of room ids to factoid: (text, value, verb) tuples
self.prev_factoid = {}

def process_message(self, message: ServiceMessage):
def process_message(self, message: ServiceMessage) -> Response:
self.who = message.author.name
self.utils.people.add(self.who)
result = ""
Expand Down Expand Up @@ -217,7 +217,6 @@ 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=f'Ok {Utilities.get_instance().discord_user.name}, remembering that "chriscanal" is "the person who wrote this test"',
Expand Down
12 changes: 7 additions & 5 deletions modules/Random.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import re
import random
from modules.module import Module, Response
from utilities.serviceutils import ServiceMessage

from utilities.utilities import Utilities

utils = Utilities.get_instance()


class Random(Module):
def process_message(self, message):
def process_message(self, message: ServiceMessage) -> Response:
atme = self.is_at_me(message)
text = atme or message.clean_content
who = message.author.name
who = message.author.display_name

# dice rolling
if re.search("^roll [0-9]+d[0-9]+$", text):
Expand Down Expand Up @@ -44,7 +45,7 @@ def process_message(self, message):
)

# "Stampy, choose coke or pepsi or both"
elif text.startswith("choose ") and " or " in text:
if text.startswith("choose ") and " or " in text:
# repetition guard
if atme and utils.message_repeated(message, text):
self.log.info(
Expand All @@ -59,12 +60,13 @@ def process_message(self, message):
for option in re.split(" or |,", cstring)
if option.strip()
]
options_str = ", ".join(options)
return Response(
confidence=9,
text=random.choice(options),
why="%s asked me to choose between the options [%s]"
% (who, ", ".join(options)),
why=f"{who} asked me to choose between the options [{options_str}]",
)
return Response()

def __str__(self):
return "Random"
10 changes: 2 additions & 8 deletions modules/Silly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
import datetime
import string

from typing import Dict
from modules.module import Module, Response, ServiceMessage
from utilities.utilities import Utilities, randbool

utils = Utilities.get_instance()


class Silly(Module):
def __init__(self):
super().__init__()

def process_message(self, message):
def process_message(self, message: ServiceMessage) -> Response:
atme = self.is_at_me(message)
text = atme or message.clean_content
who = message.author.name
print(atme)
print(text)
who = message.author.display_name

if atme and utils.message_repeated(message, text):
self.log.info(
Expand Down
2 changes: 1 addition & 1 deletion modules/testModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def process_message(self, message: ServiceMessage):
return Response(
confidence=10,
text="Testing is only allowed in the private channel",
why=f"{message.author.name} wanted to test me outside of the private channel which is prohibited!",
why=f"{message.author.display_name} wanted to test me outside of the private channel which is prohibited!",
)

if not is_bot_dev(message.author):
Expand Down

0 comments on commit 5a2513f

Please sign in to comment.