registration script
 

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

registration script

Started by Awenger, 26 March, 2006, 20:29:08

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Awenger

I am tryin write new users data to RegisteredUsers.xml file but PtokaX don't see added users :(  Can anyone write script that add new users based on data added to RegisteredUsers.xml or external txt file  (check updates in file once per minite) ?

bastya_elvtars

If one adds them to a textfile like:
Nick/Pass/Profile
then it's possible to read on a certain interval. I may make this script.
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

By the way this script is cool for using web-based registration to the hub.
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

f:seek("*a") can do the trick.
Everything could have been anything else and it would have just as much meaning.

Awenger

Thanks for script.

Quote from: Mutor on 27 March, 2006, 01:32:46
Rather than using a straight timer, it may be better to add the users, purge the file and then watch for change in file size on timer.

It will be cool ! Or add timer that read file once per minite and delete or purge it

bastya_elvtars

I am working on the script that does this, but it does not work yet.
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

Ok, this part is clear. The bug is somewhere else.
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

#7
I don't know if this works good or not... but anyway, here ya go, another flavor:

--[[

Quick example of regging users from external list.
-Checks if nick is already regged
-Reports results to opnick


Expected file format: (Nickname Password Profile-Number)
Tester1 secret 0
Tester2 swordfish 1
Tester3 unknown 2
Tester4 password 3

Result:
<RegScript>
Failed [Master] Tester1 exists and was not added
Added [Operator] Tester2 with the Password: swordfish
Failed [VIP] Tester3 exists and was not added
Added [Reg] Tester4 with the Password: password

Change the line below (in Main) to reflect your file and your nick
AddReg("addreg.txt","Mutor")

Touched by bastya_elvtars:
	- Removes the file upon parsing.
	- Checks the last size, and if unchanged, it won't go any further.
	- Sends PM to a list of nicks.
	- Uses the hub bot's name.
]]

-- NOTE: BETA! Use for testing only!

filename="reg_pending.txt"

interval=30 -- in minutes

Bot=frmHub:GetHubBotName() -- pulling the main hub bit name, should be good in 95% of the cases

opnicks={"[TGA-OP]bastya_elvtars","Mutor"}

---------------------------------------------

OnTimer = function()
	local f,e = io.open(filename,"r")
	if f then
		local cur=f:seek()
		local size=f:seek("end")
		if size~=0 and size~=_LAST then
			f:seek("set", cur)
			_LAST=size
			AddReg(f)
		else
-- 			for _,opnick in ipairs(opnicks) do
-- 				SendToNick(opnick,"<"..Bot.."> No new registration was necessary.")
-- 			end
		end
	else
-- 		for _,opnick in ipairs(opnicks) do
-- 			SendToNick(opnick,"<"..Bot.."> "..e)
-- 		end
	end
end

AddReg = function(file)
	local reply = ""
	local l=0
	for line in file:lines() do
		l=l+1
		local _,_,usr,pwd,prof = string.find(line,"(%S+)%s+(%S+)%s+(%d+)")
		if usr then
			prof=tonumber(prof)
			if not frmHub:isNickRegged(usr) then
				AddRegUser(usr,pwd,prof)
				reply = reply.."Added ["..GetProfileName(prof).."] "..usr..
				" with the Password: "..pwd.."\r\n"
			else
				reply = reply.."Failed to add ["..GetProfileName(prof)..
				"] "..usr.."  - perhaps the account already exists.\r\n"
			end
		else
			reply = reply.."Bad data found in line "..l.." of "..filename.."!"
		end
	end
	file:close()
	os.remove(filename)
	for _,opnick in ipairs(opnicks) do
		SendPmToNick(opnick, Bot, "\r\n"..reply)
	end
end

Main=function()
	SetTimer(interval*60*1000)
	StartTimer()
end
Everything could have been anything else and it would have just as much meaning.

Awenger

#8
To Mutor:
Your script works fine, thanks for help.  I will use it :) 

To Bastya_elvtars:
Script seems working , but bot flood mainchat with messages like - names of regged users, reg_pending.txt: No such file or directory, No new registration was necessary. Even if i dont enter any nicks in line  opnicks={" "} bot post in mainchat nicks of new regged users.

P.S.
IMHO  sends PM or in mainchat reg info don't need because it's very annoying if many registration occurs .  But someone maybe find this very usefull.

I will test more both scripts tomorrow

bastya_elvtars

#9
Thanks for trying out, looks like I forgot to remove some debug code. Edited the above.
Everything could have been anything else and it would have just as much meaning.

Awenger

Thanks , script working very well

SMF spam blocked by CleanTalk