Skip to content

Commit

Permalink
Merge pull request #141 from anoadragon453/HarHarLinks/ignore-the-past
Browse files Browse the repository at this point in the history
ignore messages sent before the bot joined
  • Loading branch information
HarHarLinks authored Feb 6, 2024
2 parents cebbca4 + 6a1151b commit c062f19
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions matrix_reminder_bot/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ async def message(self, room: MatrixRoom, event: RoomMessageText):
if event.sender == self.client.user:
return

# Ignore messages from the past
join_time = 0
state = await self.client.room_get_state(room.room_id)
for membership in state.events:
if (
membership.get("type") == "m.room.member"
and membership.get("state_key") == self.client.user_id
):
join_time = membership.get("origin_server_ts", 0)
if join_time > event.server_timestamp:
return

# Ignore messages from disallowed users
if not is_allowed_user(event.sender):
logger.debug(
Expand Down

0 comments on commit c062f19

Please sign in to comment.