diff options
| author | Pratyush Desai | 2021-08-20 13:58:25 +0200 |
|---|---|---|
| committer | Pratyush Desai | 2021-08-20 13:58:25 +0200 |
| commit | e2a713e2994c6d8c83c4223e8b5f4e1adba9c3fd (patch) | |
| tree | 845645c22d4a00b3e7d4a33c3fd71abbf3b5320a /plugin.py | |
| parent | 9810f1ca99e6d8283bc33cae218b02e4cd795cba (diff) | |
| parent | 5039d0b51be13b2d2e8ed1c2e797eb4f6d281114 (diff) | |
| download | snoparser-e2a713e2994c6d8c83c4223e8b5f4e1adba9c3fd.tar.gz snoparser-e2a713e2994c6d8c83c4223e8b5f4e1adba9c3fd.tar.bz2 snoparser-e2a713e2994c6d8c83c4223e8b5f4e1adba9c3fd.zip | |
Merge pull request 'merging devel into master' (#7) from devel into master
Reviewed-on: https://git.com.de/LimnoriaPlugins/SnoParser/pulls/7
Diffstat (limited to 'plugin.py')
| -rw-r--r-- | plugin.py | 51 |
1 files changed, 45 insertions, 6 deletions
@@ -122,18 +122,57 @@ 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 [<redacted-hostmask>] registered account [<redacted>] from IP <redacted> - # -ACCOUNT- Operator [<redacted>] registered account [<redacted>] 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}" + + # 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) + 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._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 |
