Selfreg script - Page 2
 

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

Selfreg script

Started by NemeziS, 17 September, 2004, 11:39:19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nErBoS

Hi,

1) Fixed....

--## Self Register 1.2
--## Requested by Cp6uja
--## Secure Pass and Nick (thanks to RabidWombat) 
--## Added a helper remenber of pass (requested by BoJlk)
--## Reg will obrigate which user to have [Reg] has a prefix (requested by BoJlk)
--## Made by nErBoS
--## Commands;
--##	!regme or !reg  - Register the user who uses the command

sBot = "Reg-Bot"

PtokaxPath = "C:\\Ptokax\\" -- Put here you ptokax folder path
fReg = "RegisteredUsers.dat"
arrReg = {}

function Main()
	frmHub:RegBot(sBot)
	frmHub:EnableFullData(1)
end

function NewUserConnected(user)
	if (arrReg[user.sName] ~= nil) then
		user:SendData(sBot, "Change your your nick to [Reg]"..user.sName)
		user:Disconnect()
	end
	if (user.iProfile == 3) then
		local name = strsub(user.sName,5,strlen(user.sName))
		arrReg[name] = nil
	end
end

function DataArrival(user, data)
	if (strsub(data,1,7) == "$MyPass") then
		execute("copy "..PtokaxPath..fReg)
		local s,e,pass = strfind(data, "%$MyPass%s+(.+)|") 
		local validation,len = CheckPass(user.sName,pass)
		if (validation == nil) then
			if (len ~= strlen(pass)) then
				user:SendData(sBot, "Your password is wrong. You must type a "..len.." length pass.")
				user:Disconnect()
			else
				user:SendData(sBot, "Wrong Password.")
				user:Disconnect()
			end
		end
	end
	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 == "!regme" or cmd =="!reg") then
			local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (pass == nil) then
				user:SendPM(sBot, "Syntax Error, !regme  or !reg , you must write a password.")
			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.")
			else
				AddRegUser("[Reg]"..user.sName, pass, 3)
				arrReg[user.sName] = 1
				SendToOps(sBot, "The user "..user.sName.." has regiter himself.")
				user:SendPM(sBot, "You have been successufly registered with the pass: "..pass)
				user:SendPM(sBot, "Change your your nick to [Reg]"..user.sName)
				user:SendPM(sBot, "Please reconnect and type your password.")
			end
			return 1
		end
	end
end

function CheckPass(nick, pass)
	readfrom(fReg)
	while 1 do
		local sLine = read()
		if (sLine == nil) then
			break
		else
			local s,e,usr,rpass = strfind(sLine, "(.+)|(.+)|%d+")
			if (usr == nick) then
				if (rpass ~= pass) then
					return nil,strlen(rpass)
				else
					return 0,0
				end
			end
		end
	end
	readfrom()
	return 0,0
end

2) Well i have tried what you said and worked fine by me.

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

BoJlk

#26
First as far as i tried
Now i can't delete the user

with the command
!deluser [reg]User001
*** You can't delete [reg]User001 he is not a registered user!


And the script doesn't checks the Lenght of the password given
I mean, i want the users will register with no less then xxx characters password...

nErBoS

#27
Hi,

About the Pass len here you have...

--## Self Register 1.3
--## Requested by Cp6uja
--## Secure Pass and Nick (thanks to RabidWombat) 
--## Added a helper remenber of pass (requested by BoJlk)
--## Reg will obrigate which user to have [Reg] has a prefix (requested by BoJlk)
--## Added a Min and Max Password length (requested by BoJlk)
--## Made by nErBoS
--## Commands;
--##	!regme or !reg  - Register the user who uses the command

sBot = "Reg-Bot"

PtokaxPath = "C:\\Ptokax\\" -- Put here you ptokax folder path
minPassLen = 3	-- Put here the min Len accepted to register (If you want to disable just put 0)
maxPassLen = 20	-- Put here the max Len accepted to register (If you want to disable just put 0)
fReg = "RegisteredUsers.dat"
arrReg = {}

function Main()
	frmHub:RegBot(sBot)
	frmHub:EnableFullData(1)
end

function NewUserConnected(user)
	if (arrReg[user.sName] ~= nil) then
		user:SendData(sBot, "Change your your nick to [Reg]"..user.sName)
		user:Disconnect()
	end
	if (user.iProfile == 3) then
		local name = strsub(user.sName,5,strlen(user.sName))
		arrReg[name] = nil
	end
end

function DataArrival(user, data)
	if (strsub(data,1,7) == "$MyPass") then
		execute("copy "..PtokaxPath..fReg)
		local s,e,pass = strfind(data, "%$MyPass%s+(.+)|") 
		local validation,len = CheckPass(user.sName,pass)
		if (validation == nil) then
			if (len ~= strlen(pass)) then
				user:SendData(sBot, "Your password is wrong. You must type a "..len.." length pass.")
				user:Disconnect()
			else
				user:SendData(sBot, "Wrong Password.")
				user:Disconnect()
			end
		end
	end
	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 == "!regme" or cmd =="!reg") then
			local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (pass == nil) then
				user:SendPM(sBot, "Syntax Error, !regme  or !reg , you must write a password.")
			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 (minPassLen ~= 0 and strlen(pass) < minPassLen) then
				user:SendPM(sBot, "Your password is to short. You must write a password with a min lenght of "..minPassLen.." chars.")
			elseif (maxPassLen ~= 0 and strlen(pass) > maxPassLen) then
				user:SendPM(sBot, "Your password is to big. You must write a password with a max lenght of "..maxPassLen.." chars.")
			else
				AddRegUser("[Reg]"..user.sName, pass, 3)
				arrReg[user.sName] = 1
				SendToOps(sBot, "The user "..user.sName.." has regiter himself.")
				user:SendPM(sBot, "You have been successufly registered with the pass: "..pass)
				user:SendPM(sBot, "Change your your nick to [Reg]"..user.sName)
				user:SendPM(sBot, "Please reconnect and type your password.")
			end
			return 1
		end
	end
end

function CheckPass(nick, pass)
	readfrom(fReg)
	while 1 do
		local sLine = read()
		if (sLine == nil) then
			break
		else
			local s,e,usr,rpass = strfind(sLine, "(.+)|(.+)|%d+")
			if (usr == nick) then
				if (rpass ~= pass) then
					return nil,strlen(rpass)
				else
					return 0,0
				end
			end
		end
	end
	readfrom()
	return 0,0
end

I belive Unregging users is case sensative, so trie out to input "!deluser [Reg]User001".

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

BoJlk

#28
I thought i might be CaseSensitive so i've tried it
and still got the same problem...

The only way i could delete the registered person is
by !upgrade to VIP,OP and the deleting the VIP,OP!
otherwise it made me ***disconnected.
without the [reg] prefix

about this scripts i'll try it later and keep you poseted...
Thanks a alot

nErBoS

Hi,

That error is pretty weird i have try to remove a user by the delreg command of ptokax and worked OK. Then i tried to remove the user from the ptokax software and worked OK.

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

BoJlk

it only worked by removing the user from ProtaX...

But not by the sommand...
!deluser - Remove a user from registeredUsers.dat (All profiles)

*** You can't delete [reg]User001 he is not a registered user!

nErBoS

Hi,

Beware the deluser command is case sensative like you said so the nick prefix is [Reg].

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

SMF spam blocked by CleanTalk