add insta-ban wordlist, use with caution
This commit is contained in:
@@ -88,6 +88,10 @@ censor_wordlist:
|
|||||||
- 'effword'
|
- 'effword'
|
||||||
- 'essword'
|
- 'essword'
|
||||||
|
|
||||||
|
# using one of these words results in redaction AND an instant ban. use with EXTREME caution. wordlist pattern matching can have
|
||||||
|
# unintended consequences! set to an empty list [] to avoid using.
|
||||||
|
censor_wordlist_instaban: []
|
||||||
|
|
||||||
# list of banlists that should be subscribed to, such as #community-moderation-effort-bl:neko.dev
|
# list of banlists that should be subscribed to, such as #community-moderation-effort-bl:neko.dev
|
||||||
# when users join any room managed by this bot, they are compared against these existing banlists
|
# when users join any room managed by this bot, they are compared against these existing banlists
|
||||||
# if found, they will immediately be banned.
|
# if found, they will immediately be banned.
|
||||||
|
|||||||
+28
-1
@@ -40,6 +40,7 @@ class Config(BaseProxyConfig):
|
|||||||
helper.copy("censor")
|
helper.copy("censor")
|
||||||
helper.copy("uncensor_pl")
|
helper.copy("uncensor_pl")
|
||||||
helper.copy("censor_wordlist")
|
helper.copy("censor_wordlist")
|
||||||
|
helper.copy("censor_wordlist_instaban")
|
||||||
helper.copy("censor_files")
|
helper.copy("censor_files")
|
||||||
helper.copy("banlists")
|
helper.copy("banlists")
|
||||||
helper.copy("proactive_banning")
|
helper.copy("proactive_banning")
|
||||||
@@ -138,6 +139,18 @@ class CommunityBot(Plugin):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Could not parse message for flagging: {e}")
|
self.log.error(f"Could not parse message for flagging: {e}")
|
||||||
|
|
||||||
|
def flag_instaban(self, msg):
|
||||||
|
for w in self.config['censor_wordlist_instaban']:
|
||||||
|
try:
|
||||||
|
if bool(re.search(w, msg.content.body, re.IGNORECASE)):
|
||||||
|
#self.log.debug(f"DEBUG message flagged for instaban")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
self.log.error(f"Could not parse message for flagging: {e}")
|
||||||
|
|
||||||
|
|
||||||
def censor_room(self, msg):
|
def censor_room(self, msg):
|
||||||
if isinstance(self.config['censor'], bool):
|
if isinstance(self.config['censor'], bool):
|
||||||
#self.log.debug(f"DEBUG message will be redacted because censoring is enabled")
|
#self.log.debug(f"DEBUG message will be redacted because censoring is enabled")
|
||||||
@@ -297,7 +310,7 @@ class CommunityBot(Plugin):
|
|||||||
async def update_message_timestamp(self, evt: MessageEvent) -> None:
|
async def update_message_timestamp(self, evt: MessageEvent) -> None:
|
||||||
power_levels = await self.client.get_state_event(evt.room_id, EventType.ROOM_POWER_LEVELS)
|
power_levels = await self.client.get_state_event(evt.room_id, EventType.ROOM_POWER_LEVELS)
|
||||||
user_level = power_levels.get_user_level(evt.sender)
|
user_level = power_levels.get_user_level(evt.sender)
|
||||||
self.log.debug(f"DEBUGDEBUG user {evt.sender} has power level {user_level}")
|
#self.log.debug(f"DEBUGDEBUG user {evt.sender} has power level {user_level}")
|
||||||
if self.flag_message(evt):
|
if self.flag_message(evt):
|
||||||
# do we need to redact?
|
# do we need to redact?
|
||||||
if evt.sender not in self.config['admins'] and \
|
if evt.sender not in self.config['admins'] and \
|
||||||
@@ -309,6 +322,20 @@ class CommunityBot(Plugin):
|
|||||||
await self.client.redact(evt.room_id, evt.event_id, reason="message flagged")
|
await self.client.redact(evt.room_id, evt.event_id, reason="message flagged")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Flagged message could not be redacted: {e}")
|
self.log.error(f"Flagged message could not be redacted: {e}")
|
||||||
|
if evt.content.msgtype in {MessageType.TEXT, MessageType.NOTICE, MessageType.EMOTE}:
|
||||||
|
if self.flag_instaban(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:
|
||||||
|
await self.client.redact(evt.room_id, evt.event_id, reason="message flagged")
|
||||||
|
except Exception as e:
|
||||||
|
self.log.error(f"Flagged message could not be redacted: {e}")
|
||||||
|
|
||||||
|
await self.ban_this_user(evt.sender)
|
||||||
|
|
||||||
if not self.config["track_messages"] or not self.config["track_users"]:
|
if not self.config["track_messages"] or not self.config["track_users"]:
|
||||||
pass
|
pass
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: org.jobmachine.communitybot
|
id: org.jobmachine.communitybot
|
||||||
version: 0.1.12
|
version: 0.1.13
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- community
|
- community
|
||||||
|
|||||||
Reference in New Issue
Block a user