1
0
Fork 0

add !q die, admin

This commit is contained in:
Nyx 2025-02-01 17:11:21 -06:00
parent 96ba32b610
commit 66ff8f1474
2 changed files with 29 additions and 1 deletions

27
bot.py
View file

@ -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()

View file

@ -9,6 +9,7 @@
"server": "https://quotes.example.com"
},
"bot": {
"debugMode": true
"debugMode": true,
"admin": "@alice:example.com"
}
}