1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
23 /* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
29 void handle_nicklock(char **parameters, int pcnt, userrec *user)
31 userrec* source = Srv->FindNick(std::string(parameters[0]));
34 if (source->GetExt("nick_locked"))
36 WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
39 if (Srv->IsNick(std::string(parameters[1])))
41 if (!strcasecmp(user->server,Srv->GetServerName().c_str()))
43 // give them a lock flag
44 Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
45 Srv->ChangeUserNick(source,std::string(parameters[1]));
46 // only attempt to set their lockflag after we know the change succeeded
47 userrec* s2 = Srv->FindNick(std::string(parameters[1]));
49 s2->Extend("nick_locked",dummy);
53 WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
59 void handle_nickunlock(char **parameters, int pcnt, userrec *user)
61 userrec* source = Srv->FindNick(std::string(parameters[0]));
64 source->Shrink("nick_locked");
65 WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
66 Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
71 class ModuleNickLock : public Module
77 Srv->AddCommand("NICKLOCK",handle_nicklock,'o',2,"m_nicklock.so");
78 Srv->AddCommand("NICKUNLOCK",handle_nickunlock,'o',1,"m_nicklock.so");
81 virtual ~ModuleNickLock()
85 virtual Version GetVersion()
87 return Version(1,0,0,1,VF_VENDOR);
90 virtual int OnUserPreNick(userrec* user, std::string newnick)
92 if (user->GetExt("nick_locked"))
94 WriteServ(user->fd,"447 %s :You cannot change your nickname (your nick is locked)",user->nick);
100 virtual void OnUserQuit(userrec* user)
102 user->Shrink("nick_locked");
107 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
109 class ModuleNickLockFactory : public ModuleFactory
112 ModuleNickLockFactory()
116 ~ModuleNickLockFactory()
120 virtual Module * CreateModule()
122 return new ModuleNickLock;
128 extern "C" void * init_module( void )
130 return new ModuleNickLockFactory;