summaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authorGeorg2021-08-31 16:29:17 +0200
committerGeorg2021-08-31 16:29:17 +0200
commit46596e0b33a9a5dc086028f8e0e023a4b599bc95 (patch)
tree7ec89feabbe540cc5e4b261b4d163fbcbf92f262 /plugin.py
parent14e7d4e74e77ee92b55e5c117d7e17477b83ef8a (diff)
downloadsnoparser-46596e0b33a9a5dc086028f8e0e023a4b599bc95.tar.gz
snoparser-46596e0b33a9a5dc086028f8e0e023a4b599bc95.tar.bz2
snoparser-46596e0b33a9a5dc086028f8e0e023a4b599bc95.zip
ipquery IP validation + repaired config integers
Signed-off-by: Georg <georg@lysergic.dev>
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/plugin.py b/plugin.py
index cf2e05c..d10c8e0 100644
--- a/plugin.py
+++ b/plugin.py
@@ -168,7 +168,7 @@ class SnoParser(callbacks.Plugin):
print(data)
data = json.dumps(data)
state = self.whois_set_cache(key=sourceip, value=data)
-
+
if state is True:
return json.loads(data)
else:
@@ -243,11 +243,10 @@ class SnoParser(callbacks.Plugin):
ttl = self.redis_client_whois.ttl(ipaddress)
count = self.redis_client_ips.get(ipaddress)
decoded_count = count.decode('utf-8')
-
print('SnoParser manual query: ', data, ' ', ttl)
irc.reply(f'{decoded_data} - Count: {decoded_count} - Remaining: {ttl}s')
-
- ipquery = wrap(ipquery, ['anything'])
+
+ ipquery = wrap(ipquery, ['ip'])
def doNotice(self, irc, msg):
@@ -342,7 +341,7 @@ 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)
@@ -354,17 +353,20 @@ 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)
if 'OPER' in text and 'Client opered up' in text:
-
- operregex = "^-OPER- Client opered up \[(.*)\]"
+ operregex = "^-OPER- Client opered up \[(.*)\, \ (.*)\]$"
couple = re.match(operregex, text)
- account = couple.group(1)
- DictFromSnotice = {'notice': 'oper'}
- repl = f"\x02\x1FNOTICE:\x0F [{account}] opered up."
+ 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)
@@ -373,14 +375,14 @@ class SnoParser(callbacks.Plugin):
operregex = "^-OPER- Client deopered \[(.*)\]"
couple = re.match(operregex, text)
account = couple.group(1)
- DictFromSnotice = {'notice': 'oper'}
+ DictFromSnotice = {'notice': 'deopered', 'name': account}
repl = f"\x02\x1FNOTICE:\x0F [{account}] opered down."
self._sendSnotice(irc, msg, repl)
# Post Registration
-
+
def _setvhost(self, irc, msg, account):
arg = ['SET']
arg.append(account)
@@ -390,18 +392,18 @@ class SnoParser(callbacks.Plugin):
args=arg))
- # Send formatted SNO to channel
+ # Send formatted SNO to channel
def _sendSnotice(self, irc, msg, repl):
try:
channel = self.registryValue('targetChannel')
if channel[0] == '#':
irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE',
- args=(channel, repl)))
+ args=(channel, repl)))
# what sort of exception does one raise
except:
pass
-
+
Class = SnoParser