From 7a7bbe9b012806fa374272c43f8c146aaad2ca8a Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Thu, 2 Sep 2021 18:02:58 +0530 Subject: [PATCH] Nonetype for string config --- config.py | 2 +- plugin.py | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/config.py b/config.py index 5a9ebbd..f801b87 100644 --- a/config.py +++ b/config.py @@ -53,7 +53,7 @@ SnoParser = conf.registerPlugin('SnoParser') # registry.Boolean(False, _("""Help for someConfigVariableName."""))) conf.registerGlobalValue(SnoParser, 'targetChannel', - registry.String(None, ("""Sends reformatted snolines to the """))) + registry.String("", ("""Sends reformatted snolines to the """))) conf.registerGlobalValue(SnoParser, 'AutoVhost', registry.String('libcasa/user/', ("""Configure the vhost eg. libcasa/user/$account"""))) diff --git a/plugin.py b/plugin.py index d10c8e0..b4f6bdc 100644 --- a/plugin.py +++ b/plugin.py @@ -253,8 +253,9 @@ class SnoParser(callbacks.Plugin): (target, text) = msg.args if target == irc.nick: - # server notices CONNECT, KILL, XLINE, NICK, ACCOUNT + # server notices text = ircutils.stripFormatting(text) + # CONNECT if 'CONNECT' in text: connregex = "^-CONNECT- Client connected \[(.+)\] \[u\:~(.+)\] \[h\:(.+)\] \[ip\:(.+)\] \[r\:(.+)\]$" couple = re.match(connregex, text) @@ -272,9 +273,7 @@ class SnoParser(callbacks.Plugin): whois = self.whois_run(sourceip=ip) DictFromSnotice = {'notice': 'connect', 'nickname': nickname, 'username': username, 'host': host, 'ip': ip, 'realname': realname, 'ipCount': ip_seen, 'nickCount': nick_seen} - #repl = f"\x02\x1FNOTICE: {DictFromSnotice['notice']} \x0F\x11\x0303==>>\x0F \x02Nick:\x0F {DictFromSnotice['nickname']} \x02Username:\x0F {DictFromSnotice['username']} \x02Hostname:\x0F {DictFromSnotice['host']} \x02IP:\x0F {DictFromSnotice['ip']} \x02Realname:\x0F {DictFromSnotice['realname']} \x02IPcount:\x0F {DictFromSnotice['ipCount']} \x02NickCount:\x0F {DictFromSnotice['nickCount']}" repl = f"\x02\x1F{DictFromSnotice['notice']} \x0F\x11\x0303==>>\x0F \x02Nick:\x0F {DictFromSnotice['nickname']} \x02Username:\x0F {DictFromSnotice['username']} \x02Hostname:\x0F {DictFromSnotice['host']} \x02IP:\x0F {DictFromSnotice['ip']} {whois} \x02Realname:\x0F {DictFromSnotice['realname']} \x02IPcount:\x0F {DictFromSnotice['ipCount']} \x02NickCount:\x0F {DictFromSnotice['nickCount']}" - self._sendSnotice(irc, msg, repl) if 'XLINE' in text and 'temporary' in text: xlineregex = "^-XLINE- (.+) \[(.+)\] added temporary \((.+)\) (K-Line|D-Line) for (.+)$" @@ -344,8 +343,8 @@ class SnoParser(callbacks.Plugin): # Trigger HS SET self._setvhost(irc, msg, account) - self._sendSnotice(irc, msg, repl) + if 'ACCOUNT' in text and 'registered account' in text and 'SAREGISTER' in text: accregex = "^-ACCOUNT- Operator \[(.*)\] registered account \[(.*)\] with SAREGISTER$" couple = re.match(accregex, text) @@ -353,7 +352,6 @@ class SnoParser(callbacks.Plugin): account = couple.group(2) DictFromSnotice = {'notice': 'sareg', 'oper': oper, 'account': account} repl = f"\x02\x1FNOTICE: sareg -> [{account}] was registered by operator [{oper}]" - self._setvhost(irc, msg, account) self._sendSnotice(irc, msg, repl) @@ -362,16 +360,11 @@ class SnoParser(callbacks.Plugin): couple = re.match(operregex, text) hostmask = couple.group(1) oper = couple.group(2) - - print(couple) - DictFromSnotice = {'notice': 'opered', 'hostmask': hostmask, 'oper': oper} repl = f"\x02\x1FNOTICE:\x0F [{hostmask}] opered up as [{oper}]." - self._sendSnotice(irc, msg, repl) if 'OPER' in text and 'Client deopered' in text: - operregex = "^-OPER- Client deopered \[(.*)\]" couple = re.match(operregex, text) account = couple.group(1) -- 2.35.3