From 9ddd39daa2a8130564440bb423401d516ceb8870 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 2 Apr 2023 20:56:51 +0200 Subject: [PATCH] start and stop commands --- matrix_pygmalion_bot/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/matrix_pygmalion_bot/core.py b/matrix_pygmalion_bot/core.py index 62b5692..b7d916a 100644 --- a/matrix_pygmalion_bot/core.py +++ b/matrix_pygmalion_bot/core.py @@ -67,6 +67,9 @@ class Callbacks(object): ) await self.client.room_read_markers(room.room_id, event.event_id, event.event_id) + # Ignore messages when disabled + if "disabled" in self.bot.room_config[room.room_id] and self.bot.room_config[room.room_id]["disabled"] == True and not event.body.startswith('!start'): + return # Ignore messages from ourselves if chat_message.is_own_message: return @@ -103,6 +106,12 @@ class Callbacks(object): await self.bot.write_conf2(self.bot.name) await self.bot.send_message(self.client, room.room_id, self.bot.greeting) return + elif event.body.startswith('!start'): + self.bot.room_config[room.room_id]["disabled"] = False + return + elif event.body.startswith('!stop'): + self.bot.room_config[room.room_id]["disabled"] = True + return elif event.body.startswith('!!!'): if self.bot.chat_history.room(room.display_name).getLen() < 3: return