3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

classes: allow callers to override the make_channel_ban() ban style

This commit is contained in:
James Lu 2018-10-20 12:34:11 -07:00
parent eb231a2aad
commit 94a345423e

View File

@ -1396,7 +1396,7 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
if regexp.fullmatch(target) and ((not channel) or channel in userobj.channels): if regexp.fullmatch(target) and ((not channel) or channel in userobj.channels):
yield uid yield uid
def make_channel_ban(self, uid, ban_type='ban'): def make_channel_ban(self, uid, ban_type='ban', ban_style=None):
"""Creates a hostmask-based ban for the given user. """Creates a hostmask-based ban for the given user.
Ban exceptions, invite exceptions quiets, and extbans are also supported by setting ban_type Ban exceptions, invite exceptions quiets, and extbans are also supported by setting ban_type
@ -1407,8 +1407,8 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
# XXX: support slicing hosts so things like *!ident@*.isp.net are possible. This is actually # XXX: support slicing hosts so things like *!ident@*.isp.net are possible. This is actually
# more annoying to do than it appears because of vHosts using /, IPv6 addresses # more annoying to do than it appears because of vHosts using /, IPv6 addresses
# (cloaked and uncloaked), etc. # (cloaked and uncloaked), etc.
ban_style = self.serverdata.get('ban_style') or conf.conf['pylink'].get('ban_style') or \ ban_style = ban_style or self.serverdata.get('ban_style') or \
'*!*@$host' conf.conf['pylink'].get('ban_style') or '*!*@$host'
template = string.Template(ban_style) template = string.Template(ban_style)
banhost = template.safe_substitute(self.users[uid].get_fields()) banhost = template.safe_substitute(self.users[uid].get_fields())