diff --git a/base-config.yaml b/base-config.yaml index 825980c..6ebe0f1 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -74,6 +74,11 @@ join_notification_message: | # this bot, bot admins and bot moderators are immune to censorship. censor: false +# if censoring content, what minimum Power Level is required to not be censored? +# this allows easy permission of trusted users in a room to post images or files on demand. +# rooms usually default to 0 power level for normal users. +uncensor_pl: 1 + # whether to redact file and image uploads. this will apply to all rooms defined # in the censor variable (either boolean or a list of room IDs). censor_files: true diff --git a/community/bot.py b/community/bot.py index 7fa130d..4ee5e55 100644 --- a/community/bot.py +++ b/community/bot.py @@ -38,6 +38,7 @@ class Config(BaseProxyConfig): helper.copy_dict("greeting_rooms") helper.copy_dict("greetings") helper.copy("censor") + helper.copy("uncensor_pl") helper.copy("censor_wordlist") helper.copy("censor_files") helper.copy("banlists") @@ -124,7 +125,7 @@ class CommunityBot(Plugin): return report def flag_message(self, msg): - if msg.content.msgtype in [MessageType.FILE, MessageType.IMAGE]: + if msg.content.msgtype in [MessageType.FILE, MessageType.IMAGE, MessageType.VIDEO]: return self.config['censor_files'] for w in self.config['censor_wordlist']: @@ -294,10 +295,14 @@ class CommunityBot(Plugin): @event.on(EventType.ROOM_MESSAGE) async def update_message_timestamp(self, evt: MessageEvent) -> None: + power_levels = await self.client.get_state_event(evt.room_id, EventType.ROOM_POWER_LEVELS) + user_level = power_levels.get_user_level(evt.sender) + self.log.debug(f"DEBUGDEBUG user {evt.sender} has power level {user_level}") if self.flag_message(evt): # do we need to redact? if evt.sender not in self.config['admins'] and \ evt.sender not in self.config['moderators'] and \ + user_level < self.config['uncensor_pl'] and \ evt.sender != self.client.mxid and \ self.censor_room(evt): try: diff --git a/maubot.yaml b/maubot.yaml index 4ea4422..942dc04 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: org.jobmachine.communitybot -version: 0.1.11 +version: 0.1.12 license: MIT modules: - community