redact videos when censoring, and include uncensor powerlevel config

This commit is contained in:
William Kray
2024-10-10 13:57:24 -07:00
parent bc5fb7048c
commit ed59f1dd91
3 changed files with 12 additions and 2 deletions
+5
View File
@@ -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
+6 -1
View File
@@ -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:
+1 -1
View File
@@ -1,6 +1,6 @@
maubot: 0.1.0
id: org.jobmachine.communitybot
version: 0.1.11
version: 0.1.12
license: MIT
modules:
- community