From 2b1dc33e47a2c13684b23230910de9403871a392 Mon Sep 17 00:00:00 2001 From: Elijah Lazkani Date: Sun, 10 Sep 2017 23:53:28 -0400 Subject: [PATCH] Adding a MSG and ACTION commands --- README.md | 2 +- boots/boots.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3839e93..be4b052 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ It will only answer to the `keyword` provided to the `Eightball` object. # Admin -The `Admin` module provides the ability to add bot administrators who can request some destructive actions that might put the bot itself being abused like `join`, `part` and `quit`. +The `Admin` module provides the ability to add bot administrators who can request some destructive actions that might put the bot itself being abused like `msg`, `action`, `join`, `part` and `quit`. ## Commands diff --git a/boots/boots.py b/boots/boots.py index d119c62..9ad927c 100644 --- a/boots/boots.py +++ b/boots/boots.py @@ -29,6 +29,18 @@ async def plugins(bot: robot.Bot): def part(target, message, **kwargs): bot.send("PART", channel=message) + @admin_cmd.on_command("msg") + def msg(target, message, **kwargs): + kwargs['target'] = message.split(' ')[0] + kwargs['message'] = " ".join(message.split(' ')[1:]) + bot.send("PRIVMSG", **kwargs) + + @admin_cmd.on_command("action") + def action(target, message, **kwargs): + kwargs['target'] = message.split(' ')[0] + kwargs['message'] = "\x01ACTION {}\x01".format(" ".join(message.split(' ')[1:])) + bot.send("PRIVMSG", **kwargs) + @admin_cmd.on_command("quit") async def quit(target, message, **kwargs): bot.send("QUIT", message=message) @@ -36,7 +48,6 @@ async def plugins(bot: robot.Bot): # Exit the event loop cleanly bot.loop.stop() - def main(): host = 'eu.undernet.org'