From 484294c9d72b234dd56f3d2bcaaefe5cc5d4a68a Mon Sep 17 00:00:00 2001 From: poxifide Date: Fri, 13 Mar 2020 10:08:17 -0400 Subject: [PATCH] bitbotctl raw command. See description. # How to trigger bitbotctl commands If the command requires extra arguments, you must put quotes around the command and arguments, like so: `./bitbotctl command "raw JOIN "` Otherwise, just do: `./bitbotctl command ` --- src/core_modules/bitbotctl-raw.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/core_modules/bitbotctl-raw.py diff --git a/src/core_modules/bitbotctl-raw.py b/src/core_modules/bitbotctl-raw.py new file mode 100644 index 00000000..587a83b4 --- /dev/null +++ b/src/core_modules/bitbotctl-raw.py @@ -0,0 +1,30 @@ +#--depends-on commands + +from src import IRCLine, ModuleManager, utils + +class Module(ModuleManager.BaseModule): + def _id_from_alias(self, alias): + return self.bot.database.servers.get_by_alias(alias) + def _server_from_alias(self, alias): + id, server = self._both_from_alias(alias) + return server + def _both_from_alias(self, alias): + id = self._id_from_alias(alias) + if id == None: + raise utils.EventError("Unknown server alias") + return id, self.bot.get_server_by_id(id) + + @utils.hook("control.raw") + def rawctl(self, event): + rawargs = str(event["data"]).split(" ", 1) + server = self._server_from_alias(rawargs[0]) + if IRCLine.is_human(rawargs[1]): + line = IRCLine.parse_human(rawargs[1]) + else: + line = IRCLine.parse_line(rawargs[1]) + line = server.send(line) + + if not line == None: + return "Sent: " + line.parsed_line.format() + else: + return "Line was filtered"