NickNameTaken
 

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

NickNameTaken

Started by NotRabidWombat, 31 May, 2004, 07:53:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NotRabidWombat

After a year of neglect, I finally took some time to fix this script up to make it work *very* well. Did some basic testing and it seems to work just as expected.
--------------------------------------------------
--						--
-- This bot is designed to fix the 		--
-- "*** Your nick is taken" bug when a user is	--
-- disconnected from the hub.			--
-- 						--
-- By RabidWombat				--
--------------------------------------------------

Bot = {};

Bot.Name = "NickTakenBot";
Bot.Version = "v0.7";
Bot.Author = "RabidWombat";

-- Time to wait for a client to reply
Bot.ReplyTimeOut = 10; -- in seconds

-- Time to wait to check the client again
-- This protects against a flood
Bot.NextTryTimeOut = 60; -- in seconds

-- Nick used to test a client for activity
Bot.TestingNick = "NoNameTester";
-- no user may login with this nick
-- This nick name must NOT ever exist in the hub

Bot.HelloString = format("$Hello %s|", Bot.TestingNick);
Bot.RevConnectToMeString = format("$RevConnectToMe %s ", Bot.TestingNick);
Bot.QuitString  = format("$Quit %s|", Bot.TestingNick);
Bot.SearchString = format(" %s|$", Bot.TestingNick);

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

Bot.ClientsBeingTested = {};
Bot.FloodProtect = {};

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

function OnTimer()
	for UserName, TimeToLive in Bot.ClientsBeingTested do
		-- Has a time out occured?
		if TimeToLive < 0 then
			-- Drop the user
			DisconnectByName(UserName);
			-- Remove from testing
			Bot.ClientsBeingTested[UserName] = nil;
		else
			-- Decrement the count
			Bot.ClientsBeingTested[UserName] = TimeToLive - 1;
		end
	end

	for UserName, NextTryTimeOut in Bot.FloodProtect do
		if NextTryTimeOut < 0 then
			Bot.FloodProtect[UserName] = nil;
		else
			Bot.FloodProtect[UserName] = NextTryTimeOut - 1;
		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(Bot.ClientsBeingTested[name]) then
				-- Client is already being tested
				return;	 -- do not do anything
			else
				SendToNick(name, Bot.HelloString);		-- Check for ghost
				SendToNick(name, Bot.RevConnectToMeString .. name .. "|");
				curUser:SendData("*** "..Bot.NickMessage);	-- Do hubs job
				curUser:SendData("*** "..Bot.Title);		-- Inform new user
				curUser:SendData("*** "..Bot.Message);

				Bot.ClientsBeingTested[name] = Bot.ReplyTimeOut;

				-- 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

	if Bot.ClientsBeingTested[curUser.sName] then
		-- Client is alive
		-- Remove from testing
		Bot.ClientsBeingTested[curUser.sName] = nil;

		-- Assign next try timeout
		Bot.FloodProtect[curUser.sName] = Bot.NextTryTimeOut;

		-- Tell the client the testing nick disconnected
		curUser:SendData(Bot.QuitString);

		if ( strfind(sData, Bot.SearchString) ) then
			-- The hub doesn't need to do anything with this command
			return 1;
		end
	end
end

-- Remove a user from testing if they exist
-- IN: User Object
-- OUT: Nothing
function RemoveFromTesting(curUser)
	if(Bot.ClientsBeingTested[curUser.sName]) then
		Bot.TriesArray[curUser.sName] = nil;
	end
end

NewUserConnected = RemoveFromTesting;
OpConnected = RemoveFromTesting;
UserDisconnected = RemoveFromTesting;
OpDisconnected = RemoveFromTesting;
I use:
S > C : $Hello TestingNick
S > C : $RevConnectToMe TestingNick TargetNick
I expect :
C > S : $ConnectToMe ....
or
C > S : $RevConnectToMe ...

This was the best thing I could find that was the equivalent to a ping.

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

chill

thats really a good one IMAO :).

NotRabidWombat

What is IMAO? Is it a combination of LMAO and IMHO? ;-)

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

chill

no it should be

In My Arrogant Opinion

if google's results searched for "acronym IMAO"
are correct ;)

NotRabidWombat

Hah! Google, correct? Never!

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

NotRabidWombat

Any validation or bug reports?

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

blackwings

QuoteOriginally posted by NotRabidWombat
Any validation or bug reports?

-NotRabidWombat

I have ptokax 0.3.3.0 build 15.25 and get these errors =

Syntax error: attempt to index field `TriesArray' (a nil value)
stack traceback:
   1:  function `OpDisconnected' at line 121 [file `C:\ptokax\scripts\NickTakenBot07.lua']]
   2:  function `DisconnectByName' [C]
   3:  function `OnTimer' at line 53 [file `C:\ptokax\scripts\NickTakenBot07.lua']

Syntax error: bad argument #1 to `strlen' (string expected, got nil)
stack traceback:
   1:  function `strlen' [C]
   2:  function `DataArrival' at line 74 [file `C:\ptokax\scripts\NickTakenBot07.lua']

Syntax error: attempt to index field `TriesArray' (a nil value)
stack traceback:
   1:  function `OpDisconnected' at line 121 [file `C:\ptokax\scripts\NickTakenBot07.lua']


NotRabidWombat

#7
Yup, you're right. I actually posted the wrong version. Guess not many people use this anymore. *EDIT* and added a fix for the nil problem */EDIT*
--------------------------------------------------
--						--
-- This bot is designed to fix the 		--
-- "*** Your nick is taken" bug when a user is	--
-- disconnected from the hub.			--
-- 						--
-- By RabidWombat				--
--------------------------------------------------

Bot = {};

Bot.Name = "NickTakenBot";
Bot.Version = "v0.8";
Bot.Author = "RabidWombat";

-- Time to wait for a client to reply
Bot.ReplyTimeOut = 10; -- in seconds

-- Time to wait to check the client again
-- This protects against a flood
Bot.NextTryTimeOut = 60; -- in seconds

-- Nick used to test a client for activity
Bot.TestingNick = "NoNameTester";
-- no user may login with this nick
-- This nick name must NOT ever exist in the hub

Bot.HelloString = format("$Hello %s|", Bot.TestingNick);
Bot.RevConnectToMeString = format("$RevConnectToMe %s ", Bot.TestingNick);
Bot.QuitString  = format("$Quit %s|", Bot.TestingNick);
Bot.SearchString = format(" %s|$", Bot.TestingNick);

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

Bot.ClientsBeingTested = {};
Bot.FloodProtect = {};

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

function OnTimer()
	for UserName, TimeToLive in Bot.ClientsBeingTested do
		-- Has a time out occured?
		if TimeToLive < 0 then
			-- Drop the user
			DisconnectByName(UserName);
			-- Remove from testing
			Bot.ClientsBeingTested[UserName] = nil;
		else
			-- Decrement the count
			Bot.ClientsBeingTested[UserName] = TimeToLive - 1;
		end
	end

	for UserName, NextTryTimeOut in Bot.FloodProtect do
		if NextTryTimeOut < 0 then
			Bot.FloodProtect[UserName] = nil;
		else
			Bot.FloodProtect[UserName] = NextTryTimeOut - 1;
		end
	end
end

function DataArrival(curUser, sData)
	if curUser.sName == "" then
		local s, e, name = strfind(sData, "$ValidateNick%s+(%S+)");
		if not name then return; end

		name = strsub(name, 1, strlen(name) - 1);

		if(GetItemByName(name)) then
			if(Bot.ClientsBeingTested[name]) then
				-- Client is already being tested
				return;	 -- do not do anything
			else
				SendToNick(name, Bot.HelloString);		-- Check for ghost
				SendToNick(name, Bot.RevConnectToMeString .. name .. "|");
				curUser:SendData("*** "..Bot.NickMessage);	-- Do hubs job
				curUser:SendData("*** "..Bot.Title);		-- Inform new user
				curUser:SendData("*** "..Bot.Message);

				Bot.ClientsBeingTested[name] = Bot.ReplyTimeOut;

				-- 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

	if Bot.ClientsBeingTested[curUser.sName] then
		-- Client is alive
		-- Remove from testing
		Bot.ClientsBeingTested[curUser.sName] = nil;

		-- Assign next try timeout
		Bot.FloodProtect[curUser.sName] = Bot.NextTryTimeOut;

		-- Tell the client the testing nick disconnected
		curUser:SendData(Bot.QuitString);

		if ( strfind(sData, Bot.SearchString) ) then
			-- The hub doesn't need to do anything with this command
			return 1;
		end
	end
end

-- Remove a user from testing if they exist
-- IN: User Object
-- OUT: Nothing
function RemoveFromTesting(curUser)
	if(Bot.ClientsBeingTested[curUser.sName]) then
		Bot.ClientsBeingTested[curUser.sName] = nil;
	end
end

NewUserConnected = RemoveFromTesting;
OpConnected = RemoveFromTesting;
UserDisconnected = RemoveFromTesting;
OpDisconnected = RemoveFromTesting;

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

SMF spam blocked by CleanTalk