switch channel_op ban masks to use utils.parse.parse_token_replace

This commit is contained in:
jesopo 2019-12-21 21:41:09 +00:00
parent b2c5ad041c
commit 38235b1667

View file

@ -51,13 +51,12 @@ class Module(ModuleManager.BaseModule):
event["args_split"][1:]) event["args_split"][1:])
def _format_hostmask(self, user, s): def _format_hostmask(self, user, s):
mask_split = s.split("$$") vars = {}
for i, mask_part in enumerate(mask_split): vars["n"] = vars["nickname"] = user.nickname
mask_split[i] = (mask_part.replace("$n", user.nickname) vars["u"] = vars["username"] = user.username
.replace("$u", user.username) vars["h"] = vars["hostname"] = user.hostname
.replace("$h", user.hostname) vars["a"] = vars["account"] = user.account or ""
.replace("$a", user.account or "")) return utils.parse.format_token_replace(s, vars)
return "$".join(mask_split)
def _get_hostmask(self, channel, user): def _get_hostmask(self, channel, user):
if not user.account == None: if not user.account == None:
account_format = channel.get_setting("ban-format-account", None) account_format = channel.get_setting("ban-format-account", None)