diff --git a/bot.py b/bot.py index d640d1e..44a395d 100644 --- a/bot.py +++ b/bot.py @@ -22,6 +22,7 @@ else: print("Logging in…") credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password']) +admin = config['bot']['admin'] bot = botLibrary.Bot(credentials) PREFIX = "!q" print("Logged in.") @@ -41,6 +42,7 @@ async def help_message(room, message): {PREFIX} get - fetch a image from the defined instance {PREFIX} source - send a link to the source code {PREFIX} version - show the bot version + {PREFIX} die - kills the bot (only admins can do this!) """) else: message = (f""" @@ -51,6 +53,7 @@ async def help_message(room, message): {PREFIX} get - fetch a image from the defined instance {PREFIX} source - send a link to the source code {PREFIX} version - show the bot version + {PREFIX} die - kills the bot (only admins can do this!) --- @@ -142,4 +145,28 @@ async def help_message(room, message): await bot.api.send_text_message(room.room_id, message) +@bot.listener.on_message_event +async def help_message(room, message): + match = botLibrary.MessageMatch(room, message, bot, PREFIX) + if not (match.is_not_from_this_bot() and match.prefix() and match.is_from_userid(admin) + and match.command("die")): + return + + message = ("Ok") + + await bot.api.send_text_message(room.room_id, message) + exit(0) + +# We should find a better way to do this. +@bot.listener.on_message_event +async def help_message(room, message): + match = botLibrary.MessageMatch(room, message, bot, PREFIX) + if not (match.is_not_from_this_bot() and match.prefix() and not match.is_from_userid(admin) + and match.command("die")): + return + + message = ("You don't have permissions for that.") + + await bot.api.send_text_message(room.room_id, message) + bot.run() diff --git a/config.sample.json b/config.sample.json index 1f00381..3aa009d 100644 --- a/config.sample.json +++ b/config.sample.json @@ -9,6 +9,7 @@ "server": "https://quotes.example.com" }, "bot": { - "debugMode": true + "debugMode": true, + "admin": "@alice:example.com" } }