1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/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(InspIRCd* Instance) : ModeHandler(Instance, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
23 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
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
50 ModuleNoNickChange(InspIRCd* Me) : Module(Me)
53 nn = new NoNicks(ServerInstance);
54 ServerInstance->Modes->AddMode(nn);
55 Implementation eventlist[] = { I_OnUserPreNick, I_On005Numeric };
56 ServerInstance->Modules->Attach(eventlist, this, 2);
59 virtual ~ModuleNoNickChange()
61 ServerInstance->Modes->DelMode(nn);
65 virtual Version GetVersion()
67 return Version(1,2,0,1,VF_COMMON|VF_VENDOR,API_VERSION);
71 virtual void On005Numeric(std::string &output)
73 ServerInstance->AddExtBanChar('N');
76 virtual int OnUserPreNick(User* user, const std::string &newnick)
81 if (isdigit(newnick[0])) /* don't even think about touching a switch to uid! */
84 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
86 Channel* curr = i->first;
88 if (CHANOPS_EXEMPT(ServerInstance, 'N') && curr->GetStatus(user) == STATUS_OP)
91 if (curr->IsModeSet('N') || curr->IsExtBanned(user, 'N'))
93 user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)", user->nick.c_str(), curr->name.c_str());
102 MODULE_INIT(ModuleNoNickChange)