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 * ---------------------------------------------------
22 #include "helperfuncs.h"
25 /* $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]));
36 if (source->GetExt("nick_locked"))
38 WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
41 if (Srv->IsNick(std::string(parameters[1])))
43 irc::string server = user->server;
44 irc::string me = Srv->GetServerName().c_str();
47 // give them a lock flag
48 Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
49 Srv->ChangeUserNick(source,std::string(parameters[1]));
50 // only attempt to set their lockflag after we know the change succeeded
51 userrec* s2 = Srv->FindNick(std::string(parameters[1]));
53 s2->Extend("nick_locked",dummy);
57 WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
63 void handle_nickunlock(char **parameters, int pcnt, userrec *user)
65 userrec* source = Srv->FindNick(std::string(parameters[0]));
68 source->Shrink("nick_locked");
69 WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
70 Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
75 class ModuleNickLock : public Module
81 Srv->AddCommand("NICKLOCK",handle_nicklock,'o',2,"m_nicklock.so");
82 Srv->AddCommand("NICKUNLOCK",handle_nickunlock,'o',1,"m_nicklock.so");
85 virtual ~ModuleNickLock()
89 virtual Version GetVersion()
91 return Version(1,0,0,1,VF_VENDOR);
94 virtual int OnUserPreNick(userrec* user, std::string newnick)
96 if (user->GetExt("nick_locked"))
98 WriteServ(user->fd,"447 %s :You cannot change your nickname (your nick is locked)",user->nick);
104 virtual void OnUserQuit(userrec* user)
106 user->Shrink("nick_locked");
111 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
113 class ModuleNickLockFactory : public ModuleFactory
116 ModuleNickLockFactory()
120 ~ModuleNickLockFactory()
124 virtual Module * CreateModule()
126 return new ModuleNickLock;
132 extern "C" void * init_module( void )
134 return new ModuleNickLockFactory;