From bee8625fbe375f55053d3709b72a2972fbf6ba84 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 3 Jul 2014 12:21:00 +0200 Subject: Move calling the OnUserPreNick() hook and the restrictbannedusers check from core to cmd_nick (core_user) --- src/coremods/core_user/cmd_nick.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/coremods') diff --git a/src/coremods/core_user/cmd_nick.cpp b/src/coremods/core_user/cmd_nick.cpp index 1b25616dd..a28c40451 100644 --- a/src/coremods/core_user/cmd_nick.cpp +++ b/src/coremods/core_user/cmd_nick.cpp @@ -61,6 +61,28 @@ CmdResult CommandNick::HandleLocal(const std::vector& parameters, L return CMD_FAILURE; } + ModResult MOD_RESULT; + FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (user, newnick)); + + // If a module denied the change, abort now + if (MOD_RESULT == MOD_RES_DENY) + return CMD_FAILURE; + + // Disallow the nick change if is on and there is a ban matching this user in + // one of the channels they are on + if (ServerInstance->Config->RestrictBannedUsers) + { + for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i) + { + Channel* chan = (*i)->chan; + if (chan->GetPrefixValue(user) < VOICE_VALUE && chan->IsBanned(user)) + { + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str()); + return CMD_FAILURE; + } + } + } + if (!user->ChangeNick(newnick, false)) return CMD_FAILURE; -- cgit v1.3.1-10-gc9f91