Request to register
 

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

Request to register

Started by Dj_OcTaGoN, 02 December, 2004, 10:08:05

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dj_OcTaGoN

Howdy!

Just thought about a script where users could be able to request to get registered in a hub, and the request saves into a tmp file or something, waiting for a OP/Master to either accept it or deny it, which results in the request gets erased from tmp file after answer from OP/Master. If the request is granted, the user would get a message when logging in or in real-time that his request has been accepted or denied.
Like


Request command for users:
!reqreg  

Commands for OP/Master:
!seereq (See all requests)
!accept 
!deny 


cheers// Dj_OcTaGoN


nErBoS

Hi,

Here you go...

--## REQUESTED REGISTER BOT
--## Requested by Dj_OcTaGoN
--## Made by nErBoS
--## Commands:
--##	+reqreg 	-- Makes a request to register your nick
--##
--##	ONLY FOR OPs:
--##	+seereq		-- Show all the requests to register
--##	+accept 	-- Accepts the request of regiter to an user
--##	+denied 	-- Denies the request of register to an user

sBot = "RR-Bot"

arrRR = {}
fRR = "reqreg.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
			-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fRR)
end

function OnExit()
	SaveToFile(fRR,arrRR,"arrRR")
end

function NewUserConnected(user)
	if (arrRR[user.sName] ~= nil) then
		if (arrRR[user.sName]["DENIED"] ~= nil) then
			user:SendData(sBot, "Your request for register has been denied.")
			arrRR[user.sName] = nil
			if (uLaterPtokax == 1) then
				OnExit()
			end
		elseif (arrRR[user.sName]["ACCEPT"] ~= nil) then
			user:SendData(sBot, "Your request for register has been accepted.")
			arrRR[user.sName] = nil
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	end
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)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "+reqreg") then
			local s,e,sPass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sPass == nil) then
				user:SendPM(sBot, "Syntax Error, +reqreg , 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 (user.iProfile ~= -1) then
				user:SendPM(sBot, "You are already register in our HUB.")
			elseif (arrRR[user.sName] ~= nil) then
				user:SendPM(sBot, "Your request for register hasn't yet been checked.")
			else
				arrRR[user.sName] = {["PASS"] = sPass, ["TIME"] = GetTime()}
				user:SendPM(sBot, "Your request for register has been saved. Don't forget your password: "..sPass)
				if (uLaterPtokax == 1) then
					OnExit()
				end
			end
			return 1
		elseif (user.bOperator and cmd == "+seereq") then
			local sTmp,sNick,arrTable = "Request of register in the HUB:\r\n\r\n"
			for sNick, arrTable in arrRR do
				if (arrTable["DENIED"] == nil and arrRR["ACCEPT"] == nil) then
					sTmp = sTmp.."USER: "..sNick.." TIME OF REQUEST: "..arrTable["TIME"].."\r\n"
				end
			end
			user:SendPM(sBot, sTmp)
			return 1
		elseif (user.bOperator and cmd == "+accept") then
			local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sNick == nil) then
				user:SendPM(sBot, "Syntax Error, +accept , you must write a nick.")
			elseif (arrRR[sNick] == nil) then
				user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
			elseif (GetItemByName(sNick) == nil) then
				AddRegUser(sNick,arrRR[sNick]["PASS"],3)
				arrRR[sNick] = {["ACCEPT"] = 1}
				user:SendPM(sBot, "The user "..sNick.." was been registered.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			else
				sNick = GetItemByName(sNick)
				AddRegUser(sNick,arrRR[sNick]["PASS"],3)
				arrRR[sNick] = {["ACCEPT"] = 1}
				user:SendPM(sBot, "The user "..sNick.." was been registered.")
				sNick:SendPM(sBot, "Your request for register was been accept. Please reconnect with your password.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			end
			return 1
		end
	end
end

function GetTime()
	return date("%d").."/"..date("%m").."/20"..date("%y").." "..date("%H")..":"..date("%M")..":"..date("%S")
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

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

FrAcTi0n

is there a way that tis bot checks if nick of requested user has [REG] in front of it and if not, write him something like, u must have [REG] in fornt of your nick?
thx

FrAcTi0n

and also 2 more things... if someone request for registeration, send pm to ops that someone wanted to register, and also make another dat file, that will keep all the request... do no delete reguest after accepting or denying.]
thx

FrAcTi0n

#4
btw +accept or +seereq gets thiz error and not workin..

Syntax error: attempt to index a nil value
stack traceback:
   1:  function `DataArrival' at line 197 [file `...p\PtokaX-0.326.TestDrive4.99\scripts\regreq.lua']

btw accept nefunguje...

FrAcTi0n

also +denied is doin nothing.) but that scipt would be verry usefull if workin.) so hope someone will solve theese problems.)

nErBoS

#6
Hi,

Here you go...

--## REQUESTED REGISTER BOT 1.0
--## Requested by Dj_OcTaGoN
--## Made by nErBoS
--## Some BUGs corrected
--## Added a [REG] nick checker
--## OPs warning of new request
--## Save the denieds and accpets
--## Added the command +delete
--## Commands:
--##	+reqreg 	-- Makes a request to register your nick
--##
--##	ONLY FOR OPs:
--##	+seereq		-- Show all the requests to register
--##	+accept 	-- Accepts the request of regiter to an user
--##	+denied 	-- Denies the request of register to an user
--##
--##	ONLY FOR MASTERS
--##	+delete 	-- Deletes the entry of a request

sBot = "RR-Bot"

arrRR = {}
fRR = "reqreg.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
			-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fRR)
end

function OnExit()
	SaveToFile(fRR,arrRR,"arrRR")
end

function NewUserConnected(user)
	if (arrRR[user.sName] ~= nil) then
		if (type(arrRR[user.sName]["DENIED"]) == "table") then
			user:SendData(sBot, "Your request for register has been denied.")
			arrRR[user.sName]["DENIED"]["WARN"] = nil
			arrRR[user.sName]["DENIED"] = arrRR[user.sName]["DENIED"]["OP"]
			if (uLaterPtokax == 1) then
				OnExit()
			end
		elseif (type(arrRR[user.sName]["ACCEPT"]) == "table") then
			user:SendData(sBot, "Your request for register has been accepted.")
			arrRR[user.sName]["ACCEPT"]["WARN"] = nil
			arrRR[user.sName]["ACCEPT"] = arrRR[user.sName]["ACCEPT"]["OP"]
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	end
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)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "+reqreg") then
			local s,e,sPass = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sPass == nil) then
				user:SendPM(sBot, "Syntax Error, +reqreg , 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 (user.iProfile ~= -1) then
				user:SendPM(sBot, "You are already register in our HUB.")
			elseif (strsub(user.sName,1,5) ~= "[REG]") then
				user:SendPM(sBot, "To make the request you need to have the prefix [REG] on your nick.")
			elseif (arrRR[user.sName] ~= nil) then
				user:SendPM(sBot, "You have already made a request.")
			else
				arrRR[user.sName] = {["PASS"] = sPass, ["TIME"] = GetTime()}
				user:SendPM(sBot, "Your request for register has been saved. Don't forget your password: "..sPass)
				SendPmToOps(sBot, "The user "..user.sName.." has requested to be register.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			end
			return 1
		elseif (user.bOperator and cmd == "+seereq") then
			local sTmp,sTmp2,sTmp3,sNick,arrTable = "Request of register in the HUB:\r\n\r\n","Users accepted:\r\n\r\n","Users denied:\r\n\r\n"
			for sNick, arrTable in arrRR do
				if (arrTable["DENIED"] ~= nil) then
					if (arrTable["DENIED"]["OP"] == nil) then
						sTmp3 = sTmp3.."USER: "..sNick.." DENIED BY: "..arrTable["DENIED"].."\r\n"
					else
						sTmp3 = sTmp3.."USER: "..sNick.." DENIED BY: "..arrTable["DENIED"]["OP"].."\r\n"
					end
				elseif (arrTable["ACCEPT"] ~= nil) then
					if (arrTable["ACCEPT"]["OP"] == nil) then
						sTmp2 = sTmp2.."USER: "..sNick.." ACCEPTED BY: "..arrTable["ACCEPT"].."\r\n"
					else
						sTmp2 = sTmp2.."USER: "..sNick.." ACCEPTED BY: "..arrTable["ACCEPT"]["OP"].."\r\n"
					end
				else
					sTmp = sTmp.."USER: "..sNick.." TIME OF REQUEST: "..arrTable["TIME"].."\r\n"
				end
			end
			user:SendPM(sBot, sTmp.."\r\n"..sTmp2.."\r\n"..sTmp3)
			return 1
		elseif (user.bOperator and cmd == "+accept") then
			local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sNick == nil) then
				user:SendPM(sBot, "Syntax Error, +accept , you must write a nick.")
			elseif (arrRR[sNick] == nil) then
				user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
			elseif (GetItemByName(sNick) == nil) then
				AddRegUser(sNick,arrRR[sNick]["PASS"],3)
				arrRR[sNick] = {["ACCEPT"] = {["WARN"] = 1, ["OP"] = user.sName}}
				user:SendPM(sBot, "The user "..sNick.." was been registered.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			else
				sNick = GetItemByName(sNick)
				AddRegUser(sNick.sName,arrRR[sNick.sName]["PASS"],3)
				arrRR[sNick.sName] = {["ACCEPT"] = {["WARN"] = 1, ["OP"] = user.sName}}
				user:SendPM(sBot, "The user "..sNick.sName.." was been registered.")
				sNick:SendPM(sBot, "Your request for register was been accept. Please reconnect with your password.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			end
			return 1
		elseif (user.bOperator and cmd == "+denied") then
			local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sNick == nil) then
				user:SendPM(sBot, "Syntax Error, +denied , you must write a nick.")
			elseif (arrRR[sNick] == nil) then
				user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
			elseif (GetItemByName(sNick) == nil) then
				arrRR[sNick] = {["DENIED"] = {["WARN"] = 1, ["OP"] = user.sName}}
				user:SendPM(sBot, "The user "..sNick.." was been denied the register.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			else
				sNick = GetItemByName(sNick)
				arrRR[sNick.sName] = {["DENIED"] = {["WARN"] = 1, ["OP"] = user.sName}}
				user:SendPM(sBot, "The user "..sNick.sName.." was been denied the register.")
				sNick:SendPM(sBot, "Your request for register was been denied.")
				if (uLaterPtokax == 1) then
					OnExit()
				end
			end
			return 1
		elseif (user.iProfile == 0 and cmd == "+delete") then
			local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (sNick == nil) then
				user:SendPM(sBot, "Syntax Error, +delete , you must write a nick.")
			elseif (arrRR[sNick] == nil) then
				user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
			else
				arrRR[sNick] = nil
				user:SendPM(sBot, "The entry of the request of the nick "..sNick.." has been deleted.")
			end
			return 1			
		end
	end
end

function GetTime()
	return date("%d").."/"..date("%m").."/20"..date("%y").." "..date("%H")..":"..date("%M")..":"..date("%S")
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

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

FrAcTi0n

thx but still gettong errors

-4 +denied

Syntax error: attempt to index a nil value
stack traceback:
   1:  function `DataArrival' at line 295 [file `...p\PtokaX-0.326.TestDrive4.99\scripts\reqreg.lua']


-4 +accept

Syntax error: attempt to index a nil value
stack traceback:
   1:  function `DataArrival' at line 247 [file `...p\PtokaX-0.326.TestDrive4.99\scripts\reqreg.lua']

+delete works fine.)
thx.)

FrAcTi0n

also if i can help u with something, tell me and i will try it.)

nErBoS

Hi,

You are using TD4.99, don't use, because its not a official release and has serious bugs, use TD4. About the errors, the lines that is showing in the error doesn't exist, have you made any mod in the script ??

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

FrAcTi0n

ok, thx, will try it when i get home.)

FrAcTi0n

ok using td4
can request, can seereq,
can deny, but when used, the user is registered... but it write to user that it was denied
cannot accept
     Syntax Error: attempt to index a nil value

when trying to deny after trying accept
     Syntax Error: attempt to index a nil value

delete workin....


see it here....

[19:10:03] The user [REG]tester999 has requested to be register.
[19:10:20] <[OP]FrAcTi0N> +seereq
[19:10:20] Request of register in the HUB:

USER: [REG]tester999 TIME OF REQUEST: 09/12/2004 19:10:03

Users accepted:


Users denied:


[19:10:37] <[OP]FrAcTi0N> +accept [REG]tester999
[19:13:06] <[OP]FrAcTi0N> +denied [REG]tester999
[19:13:15] <[OP]FrAcTi0N> +seereq
[19:13:15] Request of register in the HUB:

USER: [REG]tester999 TIME OF REQUEST: 09/12/2004 19:10:03

Users accepted:


Users denied:


[19:15:13] <[OP]FrAcTi0N> +delete [REG]tester999
[19:15:13] The entry of the request of the nick [REG]tester999 has been deleted.

[19:16:55] <[OP]FrAcTi0N> +seereq
[19:16:55] Request of register in the HUB:


Users accepted:


Users denied:

nErBoS

Hi,

When i have time i will test it.

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

Dj_OcTaGoN

Ok, thx for taking time. This is a very usefull script so apreciate all help  :))

cheers // Dj_OcTaGoN


nErBoS

Hi,

I have edit the script above, try out now.

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

FrAcTi0n

will test it soon.) do u mean that u edited the first posted or the second one?

nErBoS

Hi,

I have edited the last one (second).

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

FrAcTi0n

thx, seems working.)
nice job.)

FrAcTi0n

#18
getting thiz error
after +accept - oka works fine
+seereq - Syntax Error: attempt to index field `ACCEPT' (a string value)

but +reqreg still works
and +accept too.)
didnot try +denied yet bcs do not want to rewrite all guides to register until it is not workin 100%
but still good work, getting better and better.)
have to restart script then....

FrAcTi0n

oka, so installed another dc++ version and it seems that works fine.. maybe some problem of rmdc++
just the only thing is that  when i restart the script all accepted and denied users are not saved, so when u type +seereq there is no one accepted or denied...

and also one more request to it...

when u deny someone is it possible to add reason why was it denied, that will show that it was denied?
such as +denied nick share some .....

thx

nErBoS

Hi,

About not saving you have to have this configuration according to the Ptokax you are using...

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
			-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0

--## END ##--

About adding a reason to the denied i will do it as soon as i can.

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

FrAcTi0n

#21
oka if i do that, i can reg someone but after that +seereq is not workin.... file reqreg.dat was made, with request and accepted request....
but when try to use +seereq getting thiz error
Syntax Error: attempt to index field `ACCEPT' (a string value)

if i restart the script it is still the same, until i delete reqreg.dat....
thiz file:

arrRR = {
   ["[REG]Toxic"] = {
      ["TIME"] = "17/12/2004 22:52:50",
      ["PASS"] = "*****",
   },
   ["[REG]subdrum47"] = {
      ["ACCEPT"] = "[OP]FrAcTi0N",
   },
}

nErBoS

Hi,

Ok i will see that as soon as i can.

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

NeoUltimicia

Here is what happened with the Data.
When I changed it, it went OK after that.
I don't know what make itwrite that "wrong" format.
could you please find out the reason.


===== Original =================================

	
[
"user1"] = {
	
	
[
"ACCEPT"] = "userOP",
	
},

======= 
Made changes to work ===================

	
[
"user1"] = {
	
	
[
"ACCEPT"] = {
	
	
	
[
"OP"] = "userOP",
	
	
	
[
"WARN"] = 1,
	
	
},
	
},

================================================

NeoUltimicia

I tried to figure out the problem.. and I think I got a clue....

After I accept the registed user and the user re-login, he get a notification because the data is as follows:

Quote["user1"] = {
        ["ACCEPT"] = {
            ["OP"] = "userOP",
            ["WARN"] = 1,
        },
    },

but.. then again.. this data is re constructed after he get the confirmation and then becomes:

Quote["user1"] = {
        ["ACCEPT"] = "userOP",
    },

so... it's  either a problem with the READing +seereq
OR the re-constucting.

could anyone please find out the problem?

SMF spam blocked by CleanTalk