aboutsummaryrefslogtreecommitdiff
path: root/modules/ctcp.py
diff options
context:
space:
mode:
authorGravatar jesopo2016-03-29 12:56:58 +0100
committerGravatar jesopo2016-03-29 12:56:58 +0100
commitf943d63098a50746f4e470e403a991a4d9713030 (patch)
treedeeb98058917d0155227211d72576f0cbab28d3f /modules/ctcp.py
parentInitial commit (diff)
first commit.
Diffstat (limited to 'modules/ctcp.py')
-rw-r--r--modules/ctcp.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/ctcp.py b/modules/ctcp.py
new file mode 100644
index 00000000..f646cedf
--- /dev/null
+++ b/modules/ctcp.py
@@ -0,0 +1,26 @@
+
+
+class Module(object):
+ def __init__(self, bot):
+ bot.events.on("received").on("message").on("private").hook(
+ self.private_message)
+ self.bot = bot
+
+ def private_message(self, event):
+ if event["message"][0] == "\x01" and event["message"][-1] == "\x01":
+ ctcp_command = event["message_split"][0][1:].upper()
+ if ctcp_command.endswith("\x01"):
+ ctcp_command = ctcp_command[:-1]
+ ctcp_args = " ".join(event["message_split"][1:])[:-1]
+ ctcp_args_split = ctcp_args.split(" ")
+
+ ctcp_response = None
+ if ctcp_command == "VERSION":
+ ctcp_response = self.bot.config.get("ctcp-version",
+ "BitBot")
+ elif ctcp_command == "PING":
+ ctcp_response = " ".join(ctcp_args_split)
+
+ if ctcp_response:
+ event["user"].send_ctcp_response(ctcp_command,
+ ctcp_response)