From 940ea7f4c924536d913e1a1c4ec6bacf51bcdc2f Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Fri, 20 Aug 2021 14:01:27 +0530 Subject: add ACCOUNT --- plugin.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index 0b8d698..fcfc89b 100644 --- a/plugin.py +++ b/plugin.py @@ -122,12 +122,26 @@ class SnoParser(callbacks.Plugin): quitregex = "^-QUIT- (.+) exited the network$" couple = re.match(quitregex, text) nick = couple.group(1) + DictFromSnotice = {'notice': 'quit', 'nick': nick} repl = f"\x02\x1FNOTICE: quit nick: {nick} has exited the network" self._sendSnotice(irc, msg, repl) - # -ACCOUNT- Client [] registered account [] from IP - # -ACCOUNT- Operator [] registered account [] with SAREGISTER - # if 'ACCOUNT' in text and 'logged into account' in text: - # accregex = "^-ACCOUNT- " + if 'ACCOUNT' in text and 'registered account' in text: + accregex = "^-ACCOUNT- Client \[(.*)\] registered account \[(.*)\] from IP (.*)$" + couple = re.match(accregex, text) + hostmask = couple.group(1) + account = couple.group(2) + ip = couple.group(3) + DictFromSnotice = {'notice': 'accreg', 'hostmask': hostmask, 'account': account, 'ip': ip} + repl = f"\x02\x1FNOTICE: accreg -> [{account}] was registered by hostmask [{hostmask}] from IP {ip}" + 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) + oper = couple.group(1) + account = couple.group(2) + DictFromSnotice = {'notice': 'sareg', 'oper': oper, 'account': account} + repl = f"\x02\x1FNOTICE: sareg -> [{account}] was registered by operator [{oper}]" + self._sendSnotice(irc, msg, repl) -- cgit v1.2.3 From 5039d0b51be13b2d2e8ed1c2e797eb4f6d281114 Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Fri, 20 Aug 2021 17:14:44 +0530 Subject: switch to rst, add setvhost, use config vars --- plugin.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index fcfc89b..8c3717e 100644 --- a/plugin.py +++ b/plugin.py @@ -133,6 +133,10 @@ class SnoParser(callbacks.Plugin): ip = couple.group(3) DictFromSnotice = {'notice': 'accreg', 'hostmask': hostmask, 'account': account, 'ip': ip} repl = f"\x02\x1FNOTICE: accreg -> [{account}] was registered by hostmask [{hostmask}] from IP {ip}" + + # 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$" @@ -141,13 +145,34 @@ 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) + + # Post Registration + def _setvhost(self, irc, msg, account): + arg = ['SET'] + arg.append(account) + vhost = self.registryValue('AutoVhost') + arg.append(f'{vhost}{account}') + irc.sendMsg(msg=ircmsgs.IrcMsg(command='HS', + args=arg)) + + + # Send formatted SNO to channel def _sendSnotice(self, irc, msg, repl): - irc.queueMsg(msg=ircmsgs.IrcMsg(command='PRIVMSG', - args=('#snotices', repl))) + try: + channel = self.registryValue('targetChannel') + if channel[0] == '#': + irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE', + args=(channel, repl))) + # what sort of exception does one raise + except: + pass + Class = SnoParser -- cgit v1.2.3