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 * ---------------------------------------------------
24 #include "helperfuncs.h"
27 /* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
31 void handle_nicklock(char **parameters, int pcnt, userrec *user)
33 userrec* source = Srv->FindNick(std::string(parameters[0]));
39 if (source->GetExt("nick_locked"))
41 WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
44 if (Srv->IsNick(std::string(parameters[1])))
46 server = user->server;
47 me = Srv->GetServerName().c_str();
51 // give them a lock flag
52 Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
53 Srv->ChangeUserNick(source,std::string(parameters[1]));
54 // only attempt to set their lockflag after we know the change succeeded
55 source = Srv->FindNick(std::string(parameters[1]));
57 source->Extend("nick_locked", "ON");
61 WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
67 void handle_nickunlock(char **parameters, int pcnt, userrec *user)
69 userrec* source = Srv->FindNick(std::string(parameters[0]));
72 source->Shrink("nick_locked");
73 WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
74 Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
79 class ModuleNickLock : public Module
82 ModuleNickLock(Server* Me)
86 Srv->AddCommand("NICKLOCK",handle_nicklock,'o',2,"m_nicklock.so");
87 Srv->AddCommand("NICKUNLOCK",handle_nickunlock,'o',1,"m_nicklock.so");
90 virtual ~ModuleNickLock()
94 virtual Version GetVersion()
96 return Version(1,0,0,1,VF_VENDOR);
99 virtual int OnUserPreNick(userrec* user, std::string newnick)
101 if (user->GetExt("nick_locked"))
103 WriteServ(user->fd,"447 %s :You cannot change your nickname (your nick is locked)",user->nick);
109 virtual void OnUserQuit(userrec* user, std::string reason)
111 user->Shrink("nick_locked");
116 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
118 class ModuleNickLockFactory : public ModuleFactory
121 ModuleNickLockFactory()
125 ~ModuleNickLockFactory()
129 virtual Module * CreateModule(Server* Me)
131 return new ModuleNickLock(Me);
137 extern "C" void * init_module( void )
139 return new ModuleNickLockFactory;