add !q die, admin
This commit is contained in:
parent
96ba32b610
commit
66ff8f1474
2 changed files with 29 additions and 1 deletions
27
bot.py
27
bot.py
|
@ -22,6 +22,7 @@ else:
|
||||||
|
|
||||||
print("Logging in…")
|
print("Logging in…")
|
||||||
credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password'])
|
credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password'])
|
||||||
|
admin = config['bot']['admin']
|
||||||
bot = botLibrary.Bot(credentials)
|
bot = botLibrary.Bot(credentials)
|
||||||
PREFIX = "!q"
|
PREFIX = "!q"
|
||||||
print("Logged in.")
|
print("Logged in.")
|
||||||
|
@ -41,6 +42,7 @@ async def help_message(room, message):
|
||||||
{PREFIX} get - fetch a image from the defined instance
|
{PREFIX} get - fetch a image from the defined instance
|
||||||
{PREFIX} source - send a link to the source code
|
{PREFIX} source - send a link to the source code
|
||||||
{PREFIX} version - show the bot version
|
{PREFIX} version - show the bot version
|
||||||
|
{PREFIX} die - kills the bot (only admins can do this!)
|
||||||
""")
|
""")
|
||||||
else:
|
else:
|
||||||
message = (f"""
|
message = (f"""
|
||||||
|
@ -51,6 +53,7 @@ async def help_message(room, message):
|
||||||
{PREFIX} get - fetch a image from the defined instance
|
{PREFIX} get - fetch a image from the defined instance
|
||||||
{PREFIX} source - send a link to the source code
|
{PREFIX} source - send a link to the source code
|
||||||
{PREFIX} version - show the bot version
|
{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)
|
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()
|
bot.run()
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"server": "https://quotes.example.com"
|
"server": "https://quotes.example.com"
|
||||||
},
|
},
|
||||||
"bot": {
|
"bot": {
|
||||||
"debugMode": true
|
"debugMode": true,
|
||||||
|
"admin": "@alice:example.com"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue