Browse Source

start and stop commands

master
Hendrik Langer 2 years ago
parent
commit
9ddd39daa2
  1. 9
      matrix_pygmalion_bot/core.py

9
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) 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 # Ignore messages from ourselves
if chat_message.is_own_message: if chat_message.is_own_message:
return return
@ -103,6 +106,12 @@ class Callbacks(object):
await self.bot.write_conf2(self.bot.name) await self.bot.write_conf2(self.bot.name)
await self.bot.send_message(self.client, room.room_id, self.bot.greeting) await self.bot.send_message(self.client, room.room_id, self.bot.greeting)
return 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('!!!'): elif event.body.startswith('!!!'):
if self.bot.chat_history.room(room.display_name).getLen() < 3: if self.bot.chat_history.room(room.display_name).getLen() < 3:
return return

Loading…
Cancel
Save