From 6929ff06643a11354e8a3b01b6d296ef3b2b1704 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 16 Sep 2019 15:29:09 +0100 Subject: add strip_otr.py closes #148 --- modules/strip_otr.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 modules/strip_otr.py (limited to 'modules') diff --git a/modules/strip_otr.py b/modules/strip_otr.py new file mode 100644 index 00000000..bdb273a5 --- /dev/null +++ b/modules/strip_otr.py @@ -0,0 +1,15 @@ +from src import EventManager, ModuleManager, utils + +# Strip magic whitespace string from the end of messages. +# OTR uses this string to advertise, over plaintext, that the sending user +# supports OTR. + +MAGIC = " \t \t\t\t\t \t \t \t \t\t \t \t" + +class Module(ModuleManager.BaseModule): + @utils.hook("raw.received.privmsg") + @utils.kwarg("priority", EventManager.PRIORITY_HIGH) + def on_message(self, event): + message = event["line"].args.get(1) + if message.endswith(MAGIC): + event["line"].args[1] = message.rsplit(MAGIC, 1)[0] -- cgit v1.3.1-10-gc9f91