How does this script work?
 

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

How does this script work?

Started by Alexandros, 16 December, 2003, 09:19:36

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Alexandros

I don't know much about lua...only want to know how this works....it sends a message to the "online" user...to test the conecction? if the TCP conecction is pointing to nothing then the socket closes when it receibes this message?

-- --
--
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 == "<unknown>" 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

plop

yep, if you get the msg "your nick has been taken" it trys 2 send a msg 2 that nick wich is in the hub.
this is mostly enough 2 make ptokax drop the ghost.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk