1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for channel mode +N & extban +b N: which prevents nick changes on channel */
18 class NoNicks : public ModeHandler
21 NoNicks(Module* Creator) : ModeHandler(Creator, "nonick", 'N', PARAM_NONE, MODETYPE_CHANNEL) { }
23 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
27 if (!channel->IsModeSet('N'))
29 channel->SetMode('N',true);
30 return MODEACTION_ALLOW;
35 if (channel->IsModeSet('N'))
37 channel->SetMode('N',false);
38 return MODEACTION_ALLOW;
42 return MODEACTION_DENY;
46 class ModuleNoNickChange : public Module
51 ModuleNoNickChange() : nn(this)
54 ServerInstance->Modes->AddMode(&nn);
55 Implementation eventlist[] = { I_OnUserPreNick, I_On005Numeric, I_OnRehash };
56 ServerInstance->Modules->Attach(eventlist, this, 3);
59 virtual ~ModuleNoNickChange()
63 virtual Version GetVersion()
65 return Version("Provides support for channel mode +N & extban +b N: which prevents nick changes on channel", VF_VENDOR);
69 virtual void On005Numeric(std::string &output)
71 ServerInstance->AddExtBanChar('N');
74 virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
77 return MOD_RES_PASSTHRU;
79 // Allow forced nick changes.
80 if (ServerInstance->NICKForced.get(user))
81 return MOD_RES_PASSTHRU;
83 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
87 ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick");
89 if (res == MOD_RES_ALLOW)
92 if (override && IS_OPER(user))
95 if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet('N')))
97 user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)",
98 user->nick.c_str(), curr->name.c_str());
103 return MOD_RES_PASSTHRU;
106 virtual void OnRehash(User* user)
109 override = Conf.ReadFlag("nonicks", "operoverride", "no", 0);
113 MODULE_INIT(ModuleNoNickChange)