Show a list of unregistered users to an OP
 

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

Show a list of unregistered users to an OP

Started by NoiZe, 03 March, 2004, 23:28:41

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

NoiZe

I hope someone can help me, searched my ass off but didn't find any good stand-alone script for this problem.

I run a public hub with regged users. I want to see a list of currently unregistered nicks in a PM or mainchat. Only OP's or admin's can see or trigger this.

That way it's easy to see which users still must be checked for a good share or something..  8)

Thank you!
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

nErBoS

Hi,

I don't believe if that is possible.

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

kepp

Hey, hope this helps.

sBot = "show[Unregs]"

LOGGusr = {}

function Main()
	frmHub:RegBot(sBot)
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		if LOGGusr[user.sName] == nil then
			LOGGusr[user.sName] = 1
		end
	end
end

function UserDisconnected(user)
	if user.iProfile == -1 then
		LOGGusr[user.sName] = nil
	end
end

function DataArrival(user, data)
	if strsub(data,1,1)=="<" then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if user.bOperator then
			if (cmd=="+showregs") then
				for i,v in LOGGusr do
					user:SendPM(sBot,i) return 1
				end
			end
		end
	end
end
Guarding    

NoiZe

#3
It seems to work! Very, very nice kepp! :))
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

NoiZe

Hmmn... it showed 1 user that's not regged.. after that it showed another user that was not regged.
 
But then there came more unregged users in to the hub after that user but they were not shown by the script.

I do not get it.  ?(
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

kepp

Did you restartscripts?
Guarding    

kepp

as soon as you restartscripts everyone must reconnect... else, it won't show up... Only those users who's entering the hub after scriptrestart will be shown
Guarding    

NoiZe

#7
Yeah I did, but it still the same problem.

It only show's the last unregged user that joined. I need a list of all current users that are present. I think that's the problem.

And ofcourse only those who have joined after starting the script. So they have to be online at that moment.

Do you understand what I want?
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

kepp

It will show all users after a while if you leave the scriptrestart button alone ;)

The problem is, there is no other way to get then name of all unregistered users that are curently active...

Enjoy
Guarding    

NoiZe

Of course I will leave it alone  :D

Still it's not working as it should be.

Example:
[00:48] *** Joins: Tatone
[00:48] *** Joins: [Telia]Cameltoe
[00:49] *** Joins: [Cable]Canopus

All three are unregged.

But the script only show's:

[00:49] Tatone

Hmmn..  ?(
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

kepp

sBot = "show[Unregs]"

LOGGusr = {}

function Main()
	frmHub:RegBot(sBot)
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		if LOGGusr[user.sName] == nil then
			LOGGusr[user.sName] = 1
		end
	end
end

function UserDisconnected(user)
	if user.iProfile == -1 then
		LOGGusr[user.sName] = nil
	end
end

function DataArrival(user, data)
	if strsub(data,1,1)=="<" then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if user.bOperator then
			if (cmd=="+showregs") then
				for i,v in LOGGusr do
					user:SendPM(sBot,i)
				end
			end
		end
	end
end

Here you go... tested and works for me :)
Guarding    

NoiZe

Thanks, had to look very carefully for that change  :]

I will look, test, sleep and look again :D

Thanks again!
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

kepp

No problem, lol!!
Guarding    

NoiZe

Seems to work just fine now!  :))

could be a #1 at the Lua Script Award's 2004! :tongue:
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

NightLitch

Reminder:

When restarting script the LOGGusr table will be emty...


/NL
//NL

NoiZe

Yes indeed. You can better restart the entire hub then instead, because all users will reconnect then and everything will work fine again.
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

NightLitch

Here is a modified version that write's to a file:

--[ LogBot ]--
-- Originally by: Kepp
-- Modified by: NightLitch

sBot = "show[Unregs]"

LogFile = "UserLog.txt"

LOGGusr = {}

function Main()
	frmHub:RegBot(sBot)
	if frmHub:GetUsersCount() == 0 then
		local f = openfile(LogFile, "w")
		if f == nil or f=="" then
			write(f, " ")
			closefile(f)
		else
			write(f, " ")
			closefile(f)
		end
	else
		LoadFromFile (LogFile)
	end
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		if LOGGusr[user.sName] == nil then
			LOGGusr[user.sName] = 1
			SaveToFile(LOGGusr , "LOGGusr", LogFile)
		end
	end
end

function UserDisconnected(user)
	if user.iProfile == -1 then
		LOGGusr[user.sName] = nil
		SaveToFile(LOGGusr , "LOGGusr", LogFile)
	end
end

function DataArrival(user, data)
	if strsub(data,1,1)=="<" then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if user.bOperator then
			if (cmd=="+showregs") then
				for i,v in LOGGusr do
					user:SendPM(sBot,i)
				end
			end
		end
	end
end

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

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

	sTab = sTab or "";

	write(hFile, 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
			Serialize(value, sKey, hFile, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile, sTab.."\t"..sKey.." = "..sValue);
		end

		write(hFile, ",\n");
	end

	write(hFile, sTab.."}");
end

function SaveToFile(table , tablename, file)
	local hFile = openfile(file, "w");
	Serialize(table, tablename, hFile);
	closefile(hFile);
end

function LoadFromFile (file)
	assert(readfrom(file),file.." is not found.Generating new "..file..". All is fine. Don't panic.")
	dostring(read("*all"))
	readfrom()
end

/NL
//NL

kepp

ok, would you like to explain a bit further, what the serializatio of the tables do? What's the point... seems every script use it lately
Guarding    

NightLitch

QuoteOriginally posted by kepp
ok, would you like to explain a bit further, what the serializatio of the tables do? What's the point... seems every script use it lately

Well that is just a main serialize I got from Wombat, a slight change but not noticeable.

That will order the table and then write to file.

that is the best serialize I have tried, especially if you use outer & inner table:

outer = { inner = {values},  }

And don't want "many" functions. I don't know who made it from the start maybe Wombat, as I mention I got it from him.

/NL
//NL

NoiZe

Seems to work ok, thnx!

Btw.. a better command is +showunregs  ;)

And now off to bed again.. :D
--=[ Owner of the Electro hub: electro.no-ip.biz ]=--

SMF spam blocked by CleanTalk