Compare commits
No commits in common. "e2a713e2994c6d8c83c4223e8b5f4e1adba9c3fd" and "9810f1ca99e6d8283bc33cae218b02e4cd795cba" have entirely different histories.
e2a713e299
...
9810f1ca99
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
env/
|
env/
|
||||||
.vscode
|
|
27
README.rst
27
README.rst
@ -1,27 +0,0 @@
|
|||||||
SnoParser
|
|
||||||
=========
|
|
||||||
|
|
||||||
Parses the Server Notices from ErgoIRCd.
|
|
||||||
|
|
||||||
|
|
||||||
Assumptions
|
|
||||||
-----------
|
|
||||||
|
|
||||||
- ``force-nick-equals-account=True``
|
|
||||||
- The Bot needs to be oper and have all the snomasks.
|
|
||||||
|
|
||||||
Current Coverage
|
|
||||||
----------------
|
|
||||||
|
|
||||||
1. CONNECT
|
|
||||||
2. XLINE
|
|
||||||
3. NICK
|
|
||||||
4. KILL
|
|
||||||
5. ACCOUNT (reg only)
|
|
||||||
|
|
||||||
Configurations
|
|
||||||
--------------
|
|
||||||
|
|
||||||
1. Formatting for 'AutoVhost' post Registration (TODO: Disable)
|
|
||||||
2. Configure the '#channel' to send the SNO lines (disabled by default) (TODO: Add Exceptions)
|
|
||||||
3. Use ZWSP to toggle nickhighlights when in channel.
|
|
@ -52,13 +52,5 @@ SnoParser = conf.registerPlugin('SnoParser')
|
|||||||
# conf.registerGlobalValue(SnoParser, 'someConfigVariableName',
|
# conf.registerGlobalValue(SnoParser, 'someConfigVariableName',
|
||||||
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
||||||
|
|
||||||
conf.registerGlobalValue(SnoParser, 'targetChannel',
|
|
||||||
registry.String(None, ("""Sends reformatted snolines to the <channel>""")))
|
|
||||||
|
|
||||||
conf.registerGlobalValue(SnoParser, 'AutoVhost',
|
|
||||||
registry.String('libcasa/user/', ("""Configure the vhost eg. libcasa/user/$account""")))
|
|
||||||
|
|
||||||
conf.registerGlobalValue(SnoParser, 'preventHighlight',
|
|
||||||
registry.Boolean(True, ("""Toggles in channel highlights with ZWSP""")))
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
51
plugin.py
51
plugin.py
@ -122,57 +122,18 @@ class SnoParser(callbacks.Plugin):
|
|||||||
quitregex = "^-QUIT- (.+) exited the network$"
|
quitregex = "^-QUIT- (.+) exited the network$"
|
||||||
couple = re.match(quitregex, text)
|
couple = re.match(quitregex, text)
|
||||||
nick = couple.group(1)
|
nick = couple.group(1)
|
||||||
DictFromSnotice = {'notice': 'quit', 'nick': nick}
|
|
||||||
repl = f"\x02\x1FNOTICE: quit nick: {nick} has exited the network"
|
repl = f"\x02\x1FNOTICE: quit nick: {nick} has exited the network"
|
||||||
self._sendSnotice(irc, msg, repl)
|
self._sendSnotice(irc, msg, repl)
|
||||||
if 'ACCOUNT' in text and 'registered account' in text:
|
# -ACCOUNT- Client [<redacted-hostmask>] registered account [<redacted>] from IP <redacted>
|
||||||
accregex = "^-ACCOUNT- Client \[(.*)\] registered account \[(.*)\] from IP (.*)$"
|
# -ACCOUNT- Operator [<redacted>] registered account [<redacted>] with SAREGISTER
|
||||||
couple = re.match(accregex, text)
|
# if 'ACCOUNT' in text and 'logged into account' in text:
|
||||||
hostmask = couple.group(1)
|
# accregex = "^-ACCOUNT- "
|
||||||
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):
|
def _sendSnotice(self, irc, msg, repl):
|
||||||
try:
|
irc.queueMsg(msg=ircmsgs.IrcMsg(command='PRIVMSG',
|
||||||
channel = self.registryValue('targetChannel')
|
args=('#snotices', repl)))
|
||||||
if channel[0] == '#':
|
|
||||||
irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE',
|
|
||||||
args=(channel, repl)))
|
|
||||||
# what sort of exception does one raise
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
Class = SnoParser
|
Class = SnoParser
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user