mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
parent
85e786904c
commit
c410de2fad
19
classes.py
19
classes.py
@ -172,6 +172,13 @@ class Irc():
|
||||
while True:
|
||||
self.aborted.clear()
|
||||
self.initVars()
|
||||
|
||||
try:
|
||||
self.proto.validateServerConf()
|
||||
except AssertionError as e:
|
||||
log.exception("(%s) Configuration error: %s", self.name, e)
|
||||
return
|
||||
|
||||
ip = self.serverdata["ip"]
|
||||
port = self.serverdata["port"]
|
||||
checks_ok = True
|
||||
@ -1144,6 +1151,18 @@ class Protocol():
|
||||
# Lock for updateTS to make sure only one thread can change the channel TS at one time.
|
||||
self.ts_lock = threading.Lock()
|
||||
|
||||
# Lists required conf keys for the server block.
|
||||
self.conf_keys = {'ip', 'port', 'hostname', 'sid', 'sidrange', 'protocol', 'sendpass',
|
||||
'recvpass'}
|
||||
|
||||
def validateServerConf(self):
|
||||
"""Validates that the server block given contains the required keys."""
|
||||
for k in self.conf_keys:
|
||||
assert k in self.irc.serverdata, "Missing option %r in server block for network %s." % (k, self.irc.name)
|
||||
|
||||
port = self.irc.serverdata['port']
|
||||
assert type(port) == int and 0 < port < 65535, "Invalid port %r for network %s" % (port, self.irc.name)
|
||||
|
||||
def parseArgs(self, args):
|
||||
"""Parses a string of RFC1459-style arguments split into a list, where ":" may
|
||||
be used for multi-word arguments that last until the end of a line.
|
||||
|
4
conf.py
4
conf.py
@ -50,10 +50,6 @@ def validateConf(conf):
|
||||
for section in ('bot', 'servers', 'login', 'logging'):
|
||||
assert conf.get(section), "Missing %r section in config." % section
|
||||
|
||||
for netname, serverblock in conf['servers'].items():
|
||||
for section in ('ip', 'port', 'hostname', 'sid', 'sidrange', 'protocol'):
|
||||
assert serverblock.get(section), "Missing %r in server block for %r." % (section, netname)
|
||||
|
||||
assert type(conf['login'].get('password')) == type(conf['login'].get('user')) == str and \
|
||||
conf['login']['password'] != "changeme", "You have not set the login details correctly!"
|
||||
|
||||
|
@ -10,6 +10,9 @@ class ClientbotWrapperProtocol(Protocol):
|
||||
def __init__(self, irc):
|
||||
super().__init__(irc)
|
||||
|
||||
# Remove conf key checks for those not needed for Clientbot.
|
||||
self.conf_keys -= {'recvpass', 'sendpass'}
|
||||
|
||||
# This is just a fallback. Actual casemapping is fetched by handle_005()
|
||||
self.casemapping = 'ascii'
|
||||
|
||||
|
@ -39,7 +39,6 @@ class IRCS2SProtocol(Protocol):
|
||||
|
||||
return {'target': killed, 'text': killmsg, 'userdata': data}
|
||||
|
||||
|
||||
def handle_squit(self, numeric, command, args):
|
||||
"""Handles incoming SQUITs."""
|
||||
return self._squit(numeric, command, args)
|
||||
|
Loading…
Reference in New Issue
Block a user