Skip to content

Commit

Permalink
doc: Add docstrings to the messagecommands
Browse files Browse the repository at this point in the history
  • Loading branch information
sebimarkgraf committed Jun 18, 2024
1 parent 11c02e5 commit b8083ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/whatsapp_transcribe/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,47 @@

@dataclass()
class Message:
"""
Represents a message sent to the service
"""

body: str
from_number: str


class MessageCommand(Protocol):
"""
Base Class defining the methods to define on all Commands.
We are using a command pattern and therefore implement one command in one
Command Protocol instance.
To create a new command correctly implement the MessageCommand Protocl
"""

def handle_message(self, message: Message) -> str:
pass


class EchoCommand(MessageCommand):
"""
EchoCommand returns the message sent to the service prefixed with "Echo: "
Assumes that the message is prefixed with "echo" and the message to echo
is the rest of the message.
"""

def handle_message(self, message: Message):
return f"Echo: {message.body.split(' ', 1)[1]}"


class HelpCommand(MessageCommand):
"""
HelpCommand returns a help message for the user.
The help message contains information about the available commands.
"""

def handle_message(self, message: Message):
return dedent("""\
Send a voice message to transcribe and summarize.
Expand Down
1 change: 1 addition & 0 deletions src/whatsapp_transcribe/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def summarize(self, text: str) -> str:
Tries to create a short and concise summary.
Args:
----
text: The text to summarize
Returns:
Expand Down

0 comments on commit b8083ab

Please sign in to comment.