aboutsummaryrefslogtreecommitdiff
path: root/modules/strip_otr.py
blob: bdb273a513e692268fcc378b5ab45ff7d4ce6c29 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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]