1 # Mattermost Bot module.
2 # Copyright (c) 2016-2022 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 # published under MIT-License
8 from AbstractWSHandler import *
9 class WSModRemovePostTextEnforcer(AbstractWSHandler):
10 NAME = "mod-remove-post-text-enforcer"
13 def on_WS_EVENT(self, data):
14 post = json.loads(data["data"]["post"])
15 if "has_reactions" not in post:
16 post["has_reactions"] = False
17 #post = self.bot.api.get_post(post["id"])
19 if "somebot_removed_post_text" in post["props"] and post["message"] != "":
20 self.bot.api.update_post(post["id"], message=None, is_pinned=post["is_pinned"], has_reactions=post["has_reactions"], props=post["props"])
21 self.bot.debug_chan("``WSModRemovePostTextEnforcer: Post edit-attempt reverted. Post-id: ``**``"+post["id"]+"``**`` Text was:``\n\n----\n\n"+post["message"])
25 self.bot.command_stats_inc("ws::"+evtype+"::"+self.NAME, amount=-1)