tmp Selfreg to Hub B
 

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

tmp Selfreg to Hub B

Started by sylvi, 26 November, 2004, 11:01:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sylvi

I need a simple selfreg script for a seccond Hub. Hub A and hub B are on the same server. All users with status reguser and higher in hub A should be able to invite himself by command !invite in hub B, so in hub B the user should have status reguser. If the user will leave hub B he should be deleted in the RegisteredUsers.dat and will only be able to came back in the hub through invite himself in

sylvi

#1
Please help,  i think there is a mistake in my script. One user in Hub A invite himself to Hub B, the file regestrierteUser.dat  from Hub B will open and will complete overwrite, Why? But the user is not added at the moment, first when i restart the hub B he is added, what can i do that it work like addregser?

sBot = "X-Planet-Invite"
regfile = "C:\\x-planet\\RegisteredUsers.dat" 
function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!inviteme") then
			local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (pass == nil) then
				user:SendPM(sBot, "Syntax Error, !inviteme , you must write a password.")
			else
				--- AddRegUser(user.sName, pass, 3)
				invitename = user.sName.."|"..pass.."|3"
				writeto(regfile)
				write(invitename.."\n")
				writeto()
				SendToOps(sBot, "The user "..user.sName.." has invite himself to X-Planet.")
				user:SendPM(sBot, "You have been successufly invite to X-Planet with the pass: "..pass)
				user:SendPM(sBot, "Please connect X-planet.dyndns.ws:8268 and type your password.")
			end
			return 
		end
	end
end

nErBoS

#2
Hi,

Use this script in your HUB A...

--## HUB INVITER BOT (PART 1)
--## Requested by sylvi 
--## Made by nErBoS
--## Commands:
--##	+invite 	- Will invite yourself to another HUB with a password

sBot = "HI1-Bot"

fPathRegUsers2 = "C:\\WorkFolder\\temp\\Ptokax2\\"	-- Path of ptokax the second hub

function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(user, data)
	if (user.iProfile ~= 1 and (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot)) then
		data = strsub(data,1,strlen(data)-1)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "+invite") then
			local s,e,sPass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sPass == nil) then
				user:SendPM(sBot, "Syntax Error, +invite , you must write a pass.")
			elseif (strfind(sPass, "[%c|\n\r]")) then
				user:SendPM(sBot, "Invalid Password. Try Again.")
			elseif (strfind(user.sName, "[%c|\n\r]")) then 
				user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
			elseif (CheckReg(user.sName) ~= nil) then
				user:SendPM(sBot, "You nick is already regged in the other HUB.")
			else
				AddReg(user.sName,sPass,user.iProfile)
				user:SendPM(sBot, "You have been regged in the other HUB with the password: "..sPass)
			end
			return 1
		end
	end
end

function CheckReg(sName)
	execute("copy "..fPathRegUsers2.."RegisteredUsers.dat")
	if (readfrom("RegisteredUsers.dat") ~= nil) then
		readfrom("RegisteredUsers.dat")
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				readfrom()
				return nil
			else
				local s,e,sNick = strfind(sLine, "(.+)|")
				if (sNick ~= nil and sNick == sName) then
					readfrom()
					return 1
				end
			end
		end
	end
end

function AddReg(sNick, sPass, iLevel)
	if (readfrom(fPathRegUsers2.."scripts\\NewUsers.dat") == nil) then
		writeto(fPathRegUsers2.."scripts\\NewUsers.dat")
 		write(sNick.."##"..sPass.."##"..iLevel.."\r\n")
		writeto()
	else
		appendto(fPathRegUsers2.."scripts\\NewUsers.dat")
 		write(sNick.."##"..sPass.."##"..iLevel.."\r\n")
		writeto()
	end
end

And use this one in your HUB B...

--## HUB INVITER BOT (PART 2)
--## Requested by sylvi 
--## Made by nErBoS

sBot = "HI1-Bot"

function Main()
	frmHub:RegBot(sBot)
end

function UserDisconnected(user)
	DelRegUser(user.sName)
end

function DataArrival(user, data)
	if (strsub(data,1,13) == "$ValidateNick") then
		CheckForNewUser()
	end
end

function CheckForNewUser()
	if (readfrom("NewUsers.dat") ~= nil) then
		readfrom("NewUsers.dat")
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				readfrom()
				writeto("NewUsers.dat")
				write("")
				writeto()
				break
			else
				local s,e,sNick,sPass,iLevel = strfind(sLine, "(.+)##(.+)##(%d+)")
				if (sNick ~= nil and sPass ~= nil and iLevel ~= nil) then
					AddRegUser(sNick,sPass,iLevel)
				end
			end
		end
	end 
end

Best regards, nErBoS
--## nErBoS Spot ##--

sylvi

Hi nErBoS,

thx for the work.

great script but i think there are some mistakes, it don?t work.

sylvi

Hi nErBoS,

Script Hub B

Quoteif (reafrom("NewUsers.dat") ~= nil) then

if (readfrom("NewUsers.dat") ~= nil) then


I think the mistake is in the position where the newuser.dat file should read out and add the users to hub.

The users don?t be added

sylvi

Hi nErBoS,

can you help me with this Skript from Hub B.

nErBoS

#6
Hi,

Is the file "NewUsers.dat" been created in the script folder of HUB B ?? Is the script given any error ?? I have made a little fix in the second script, try out.

Best regards, nErBoS
--## nErBoS Spot ##--

charlie

Hi nerbos,

i also try this script, because i think it is a great idee...
i think there are mistakes...

first in script for hub A
Quotefunction AddReg(sNick, sPass, iLevel)
   if (reafrom(fPathRegUsers2.."scripts\\NewUsers.dat") == nil) then


shoud this not mean: readfrom

and same is in script for hub B.

I change it an script in hub A creat the newusers.dat file.
But the script in Hub B can?t read out of them, and so nothing happend : Syntax Error: bad argument #1 to `strfind' (string expected, got nil)

nErBoS

Hi,

Made a edit on the scripts above correcting the "readfrom" syntax (sharp eye :D ) and the error, try it now please.

Best regards, nErBoS
--## nErBoS Spot ##--

sylvi

Hi nErBoS

I have the Script A and B editiert.

Script Hub A

--## HUB INVITER BOT (PART 1)
--## Requested by sylvi 
--## Made by nErBoS
--## Commands:
--##	+invite 	- Will invite yourself to another HUB with a password

sBot = "Invite-Hub-A"

fPathRegUsers2 = "C:\\x-planet\\"	-- Path of ptokax the second hub

function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(user, data)
	if (user.iProfile ~= 1 and (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot)) then
		data = strsub(data,1,strlen(data)-1)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "+invite") then
			local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (pass == nil) then
				user:SendPM(sBot, "Syntax Error, +invite , you must write a pass.")
			elseif (strfind(pass, "[%c|\n\r]")) then
				user:SendPM(sBot, "Invalid Password. Try Again.")
			elseif (strfind(user.sName, "[%c|\n\r]")) then 
				user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
			elseif (CheckReg(user.sName) ~= nil) then
				user:SendPM(sBot, "You nick is already regged in the other HUB.")
			else
				AddReg(user.sName,pass,user.iProfile)
				user:SendPM(sBot, "You have been regged in the other HUB with the password: "..pass)
			end
			return 1
		end
	end
end

function CheckReg(sName)
	execute("copy "..fPathRegUsers2.."RegisteredUsers.dat")
	if (readfrom("RegisteredUsers.dat") ~= nil) then
		readfrom("RegisteredUsers.dat")
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				readfrom()
				return nil
			else
				local s,e,sNick = strfind(sLine, "(.+)|")
				if (sNick ~= nil and sNick == sName) then
					readfrom()
					return 1
				end
			end
		end
	end
end

function AddReg(sNick, pass, iLevel)
	if (readfrom(fPathRegUsers2.."scripts\\NewUsers.dat") == nil) then
		writeto(fPathRegUsers2.."scripts\\NewUsers.dat")
 		write(sNick.."##"..pass.."##"..iLevel.."\r\n")
		writeto()
	else
		appendto(fPathRegUsers2.."scripts\\NewUsers.dat")
 		write(sNick.."##"..pass.."##"..iLevel.."\r\n")
		writeto()
	end
end

Script from Hub B it now

--## HUB INVITER BOT (PART 2)
--## Requested by sylvi 
--## Made by nErBoS

sBot = "Invite-Hub-B"

function Main()
	frmHub:RegBot(sBot)
end

function UserDisconnected(user)
	DelRegUser(user.sName)
end

function DataArrival(user, data)
	if (strsub(data,1,8) == "$Version") then
		CheckForNewUser()
	end
end

function CheckForNewUser()
	if (readfrom("NewUsers.dat") ~= nil) then
		readfrom("NewUsers.dat")
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				readfrom()
				writeto("NewUsers.dat")
				write("")
				writeto()
				break
			else
				local s,e,sNick,sPass,iLevel = strfind(data, "(.+)##(.+)##(%d+)")
				if (sNick ~= nil and sPass ~= nil and iLevel ~= nil) then
					AddRegUser(sNick,sPass,iLevel)
				end
			end
		end
	end 
end

The Scrip from Hub B dont work.

QuoteIs the file "NewUsers.dat" been created in the script folder of HUB B ??


yes, Scripts/Newuser.dat with user##password##Level

QuoteIs the script given any error ??


no error

But the script B can?t read and add from the NewUser.dat

nErBoS please help me,

nErBoS

Hi,

Try to use the script of HUB B that i have edited, like i said in the last post.

Best regards, nErBoS
--## nErBoS Spot ##--

sylvi

Hi nErBoS,

sorry, the Script from Hub B dont addet user.

I have Ptokax PtokaX DC Hub 0.3.3.0 build 15.25 [debug] on Hub A and B

nErBoS

Hi,

I need to catch some free time to test it, when i have i will check it.

Best regards, nErBoS
--## nErBoS Spot ##--

nErBoS

Hi,

I have correct both scripts above in my post and i have tested.

Best regards, nErBoS
--## nErBoS Spot ##--

sylvi

Big thx nErBos :P  :P  :P

SMF spam blocked by CleanTalk