diff --git a/matrix_reminder_bot/bot_commands.py b/matrix_reminder_bot/bot_commands.py index 877ec87..4c78759 100644 --- a/matrix_reminder_bot/bot_commands.py +++ b/matrix_reminder_bot/bot_commands.py @@ -338,8 +338,25 @@ async def _remind_me(self): """Set a reminder that will remind only the user who created it""" await self._remind(target=self.event.sender) + async def _insufficient_room_ping_pl(self): + room_ping_pl = self.room.power_levels.defaults.notifications.get("room") + sender_pl = self.room.power_levels.users.get(self.event.sender, 0) + bot_pl = self.room.power_levels.users.get(self.client.user_id, 0) + if sender_pl < room_ping_pl: + insufficient = f"You ({sender_pl}) do" + elif bot_pl < room_ping_pl: + insufficient = f"The bot ({bot_pl}) does" + + if insufficient is not None: + text = f"Insufficient rights: {insufficient} not have the required power level to ping the whole room ({room_ping_pl})." + await send_text_to_room(self.client, self.room.room_id, text) + return True + @command_syntax("[every ;] ; ") async def _remind_room(self): + if await self._insufficient_room_ping_pl(): + return + """Set a reminder that will mention the room that the reminder was created in""" await self._remind()