]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nicklock.cpp
fix little typo in syntax hint, type => action
[user/henk/code/inspircd.git] / src / modules / m_nicklock.cpp
index 7f64cba597f4fa6db36dc6bee9252c511dd8bb86..40965ffe007aa0824eac30fd634827d0415c06db 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -43,12 +43,12 @@ class CommandNicklock : public Command
                // check if user is locked
                if (target->GetExt("nick_locked", dummy))
                {
-                       user->WriteNumeric(946, "%s %s :This user's nickname is already locked.",user->nick,target->nick);
+                       user->WriteNumeric(946, "%s %s :This user's nickname is already locked.",user->nick.c_str(),target->nick.c_str());
                        return CMD_FAILURE;
                }
 
                // check nick is valid
-               if (!ServerInstance->IsNick(parameters[1].c_str()))
+               if (IS_LOCAL(user) && !ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax))
                {
                        return CMD_FAILURE;
                }
@@ -58,8 +58,12 @@ class CommandNicklock : public Command
 
                if (!target->ForceNickChange(parameters[1].c_str()))
                {
-                       // ugh, nickchange failed for some reason -- possibly existing nick? XXX change to UID here
-                       ServerInstance->Users->QuitUser(target, "Nickname collision");
+                       // ugh, nickchange failed for some reason -- possibly existing nick?
+                       if (!target->ForceNickChange(target->uuid.c_str()))
+                       {
+                               // Well shit, we cant even change them to their UID (this should not happen!)
+                               ServerInstance->Users->QuitUser(target, "Nickname collision");
+                       }
                }
 
                // give them a lock flag
@@ -87,7 +91,7 @@ class CommandNickunlock : public Command
                if (target)
                {
                        target->Shrink("nick_locked");
-                       user->WriteNumeric(945, "%s %s :Nickname now unlocked.",user->nick,target->nick);
+                       user->WriteNumeric(945, "%s %s :Nickname now unlocked.",user->nick.c_str(),target->nick.c_str());
                        ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used NICKUNLOCK on "+parameters[0]);
                        return CMD_SUCCESS;
                }
@@ -106,7 +110,7 @@ class ModuleNickLock : public Module
        ModuleNickLock(InspIRCd* Me)
                : Module(Me)
        {
-               
+
                cmd1 = new CommandNicklock(ServerInstance);
                cmd2 = new CommandNickunlock(ServerInstance);
                ServerInstance->AddCommand(cmd1);
@@ -114,14 +118,14 @@ class ModuleNickLock : public Module
                Implementation eventlist[] = { I_OnUserPreNick, I_OnUserQuit, I_OnCleanup };
                ServerInstance->Modules->Attach(eventlist, this, 3);
        }
-       
+
        virtual ~ModuleNickLock()
        {
        }
-       
+
        virtual Version GetVersion()
        {
-               return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
        }
 
 
@@ -132,7 +136,7 @@ class ModuleNickLock : public Module
 
                if (user->GetExt("nick_locked", n))
                {
-                       user->WriteNumeric(447, "%s :You cannot change your nickname (your nick is locked)",user->nick);
+                       user->WriteNumeric(447, "%s :You cannot change your nickname (your nick is locked)",user->nick.c_str());
                        return 1;
                }
                return 0;