Skip to content

Commit

Permalink
remember last message per room
Browse files Browse the repository at this point in the history
  • Loading branch information
rom4nik committed Mar 20, 2022
1 parent 2e9ce70 commit 154f73a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions alternatingcaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@


class AlternatingCaps(Plugin):
last_message = None
last_messages = {}

@event.on(EventType.ROOM_MESSAGE)
async def message_handler(self, evt: MessageEvent) -> None:
self.last_message = evt.content.body
self.last_messages[evt.room_id] = evt.content.body

@command.new()
async def altcaps(self, evt: MessageEvent) -> None:
if self.last_message:
await evt.respond("".join([c.upper() if i % 2 else c.lower() for i, c in enumerate(self.last_message)]))
if evt.room_id in self.last_messages:
await evt.respond("".join([c.upper() if i % 2 else c.lower() for i, c in enumerate(self.last_messages[evt.room_id])]))
2 changes: 1 addition & 1 deletion maubot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: pl.rom4nik.maubot.alternatingcaps

# A PEP 440 compliant version string.
version: 0.1.0
version: 0.1.1

# The SPDX license identifier for the plugin. https://spdx.org/licenses/
# Optional, assumes all rights reserved if omitted.
Expand Down

0 comments on commit 154f73a

Please sign in to comment.