--// anti_clone.lua -- Kick 2 users with the same nick 
--// but it leaves the first nick in the hub 
--// made by plop 
--// thx 2 GrenadeSingh for helping me with debugging. 

-- the command it should send (!kick) 
sCommand = "!kick" 

-- the reason it should send. 
sReason = "you are being kicked because of cloning!" 

tIP = {} 

dcpp:setListener( "pm", "anti_clone", 
   function ( hub, user, text ) 
         if user:getIp() ~= "" then 
            if tIP[user:getIp()] then 
               if user:getNick() ~= tIP[user:getIp()] then 
                  hub:sendChat( sCommand.." "..user:getNick().." "..sReason ) 
                  return 1 
               end 
            else 
               tIP[user:getIp()] = user:getNick() 
            end 
         end 
   end 
) 
dcpp:setListener( "chat", "anti_clone", 
   function ( hub, user, text ) 
         if user:getIp() ~= "" then 
            if tIP[user:getIp()] then 
               if user:getNick() ~= tIP[user:getIp()] then 
                  hub:sendChat( sCommand.." "..user:getNick().." "..sReason ) 
                  return 1 
               end 
            else 
               tIP[user:getIp()] = user:getNick() 
            end 
         end 
   end 
) 

dcpp:setListener( "userQuit", "anti_clone", 
   function( hub, user ) 
      user = hub:getUser(user) 
      if user:getIp() ~= "" and user:getNick() == tIP[user:getIp()] then 
         hub:injectChat (user:getNick().." "..user:getIp().." gone") 
         tIP[user:getIp()] = nil 
      end 
   end 
) 

DC():PrintDebug( "  ** Loaded anti_clone.lua **")