From 454539185e9516350ff86c74d7cad8fca3be8090 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 21 Dec 2017 00:04:55 -0800 Subject: [PATCH] Move knock handling to ts6_common This adds support for (reasonless) KNOCK on TS6. --- protocols/inspircd.py | 7 ------- protocols/ts6_common.py | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index dd0d43e..b51349d 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -672,13 +672,6 @@ class InspIRCdProtocol(TS6BaseProtocol): # SVSTOPIC is used by InspIRCd module m_topiclock - its arguments are the same as FTOPIC handle_svstopic = handle_ftopic - def handle_knock(self, numeric, command, args): - """Handles channel KNOCKs.""" - # <- :70MAAAAAA ENCAP * KNOCK #blah :abcdefg - channel = args[0] - text = args[1] - return {'channel': channel, 'text': text} - def handle_opertype(self, target, command, args): """Handles incoming OPERTYPE, which is used to denote an oper up. diff --git a/protocols/ts6_common.py b/protocols/ts6_common.py index f6215f8..bd1bc43 100644 --- a/protocols/ts6_common.py +++ b/protocols/ts6_common.py @@ -56,7 +56,6 @@ class TS6SIDGenerator(): self.output[idx] = self.allowedchars[idx][0] next(self.iters[idx]) - def increment(self, pos=2): """ Increments the SID generator to the next available SID. @@ -198,6 +197,20 @@ class TS6BaseProtocol(IRCS2SProtocol): ### HANDLERS + def handle_knock(self, numeric, command, args): + """Handles channel KNOCKs.""" + # InspIRCd: + # <- :70MAAAAAA ENCAP * KNOCK #blah :abcdefg + # Charybdis: + # <- :42XAAAAAC KNOCK #endlessvoid + # UnrealIRCd propagates knocks as a channel notice to all ops, so this handler is not used there. + channel = args[0] + try: + text = args[1] + except IndexError: + text = '' + return {'channel': channel, 'text': text} + def handle_nick(self, numeric, command, args): """Handles incoming NICK changes.""" # <- :70MAAAAAA NICK GL-devel 1434744242