Nick Already Taken
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Nick Already Taken

Started by [ES]latinmusic, 11 October, 2003, 18:49:53

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

[ES]latinmusic

-- --
-- This bot is designed to fix the --
-- "*** Your nick is taken" bug when a user is --
-- disconnected from the hub. --
-- --
-- For more details go to: --
-- http://students.dwc.edu/cbarber/nickbug.html --
-- --
-- By RabidWombat --
--------------------------------------------------

BotName = "NickTakenBot";
BotVersion = "v0.6";
BotAuthor = "RabidWombat";

NickMessage = "Your nick is already taken, please change to something else!"
Title = BotName.." "..BotVersion.." by: "..BotAuthor;
Message = "If you were disconnected from the hub, please wait a minute and you should be able to reconnect.";

TriesArray = {};
TimeToWait = 20; -- in seconds
MaxTries = 3;

function Main()
frmHub:RegBot(BotName);
frmHub:EnableFullData(1);
frmHub:EnableSearchData(0);
SetTimer(1000);
StartTimer();
end

function OnTimer()
-- This is designed so old entries will be removed from the table

for UserName,TryTable in TriesArray do

if(TryTable[0] == nil or TryTable[1] == nil) then
TriesArray[UserName] = nil; -- set entry to be removed
return;
end

TryTable[1] = TryTable[1] - 1; -- decrement time count

if(TryTable[1] <= 0) then -- less than just in case
TryTable[1] = TimeToWait; -- reset time count for next decrement
TryTable[0] = TryTable[0] - 1; -- decrement try count

if(TryTable[0] <= 0) then -- less than just in case
TriesArray[UserName] = nil; -- set entry to be removed
end
end
end
end

function DataArrival(curUser, sData)
if curUser.sName == "" and strsub(sData, 1, 13) == "$ValidateNick" then
local s, e, name = strfind(sData, "$ValidateNick (%S+)");
name = strsub(name, 1, strlen(name) - 1);

if(GetItemByName(name)) then
if(TriesArray[name] and TriesArray[name][0]) then
TriesArray[name][0] = TriesArray[name][0] + 1; -- increment tries
if(TriesArray[name][0] > MaxTries) then
TriesArray[name][1] = TimeToWait; -- reset time count
return; -- do not send message
end
else
TriesArray[name] = {1, TimeToWait};
end

SendToNick(name, "testing this connection|"); -- Check for ghost
curUser:SendData("*** "..NickMessage); -- Do hubs job
curUser:SendData("*** "..Title); -- Inform new user
curUser:SendData("*** "..Message);

-- Disconnect user before $ValidateDenide is sent
-- Some clients do not reconnect automatically correctly when this message is sent
curUser:Disconnect();

return 1;
end
end
end

function OnNewUserConnected(curUser) -- Remove entry if user connects
if(TriesArray[curUser.sName]) then
TriesArray[curUser.sName] = nil;
end
end

function OnNewOpConnected(curUser) -- Remove entry if op connects
if(TriesArray[curUser.sName]) then
TriesArray[curUser.sName] = nil;
end
end
-- --

c h i l l a

#1
another solution, the idea also from

http://students.dwc.edu/cbarber/nickbug.html

-- Nick Already taken fix V.1

function DataArrival(curUser,data)
	if (strsub(data,1,13) == "$ValidateNick") then
		local _,_,curNick = strfind(data,"$ValidateNick%s+(%S+)|")
		if curNick and GetItemByName(curNick) then
			GetItemByName(curNick):SendData(" NickCorrelation, somebody is trying to connect with your Nick.")
			curUser:SendData(" Either your Nick "..format('%q',curNick).." is already taken or try to reconnect in a few seconds.")
			curUser:Disconnect()
		elseif not curNick then
			curUser:Disconnect()
		end
	end
end

Alexei

Solution nr 3!

Just get a newest version of a main-bot and a hub-soft...
 :D  :P

SMF spam blocked by CleanTalk