add strip_otr.py

closes #148
This commit is contained in:
jesopo 2019-09-16 15:29:09 +01:00
parent fa33a927b1
commit 6929ff0664

15
modules/strip_otr.py Normal file
View file

@ -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]