Request PUBLIC/PRIVATE Robocop Addon
 

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 PUBLIC/PRIVATE Robocop Addon

Started by aL1en, 20 February, 2005, 00:03:13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aL1en

Greetz to u all...

I'd realize, normally hub runs private, and sometimes its okey to open it public..

Does someone can help developing/writing a piece of script 'standalone' with 2 simple commands:

+private (hub goes private for regged only)
+public (hub goes free 4 all)

Additional Info's:
Running PtokaX0.330.b15.25.dbg
And RoboCop v9.0b

Thanks in Advance!

Peace.

bastya_elvtars

#1
Haven't tested (cos i could not), please feedbacks here


-- regonly by bastya_elvtars
-- requested by aL1en

-- sorry 4 possible bugs, cannot test it and forgot lua a bit :)
-- disconnects unreg users if hub is set private
-- well, here is an array that contains allowed ppl. this is the safest.
-- command prefixes: + ! # ? (as usual)
-- enjoy

-- // settings

userswhocansetregonly={ -- ppl who are allowed to use it

"bastya_elvtars", "me", "you", 

}

-- the bot1s name:

Bot="RegChecker"

--- // end of settings, do not edit below


regO={}

regonly=0 -- for safety only

dofile("regonly.ini") -- loads settings

function Main() -- loads on script start
	for b=1,getn(userswhocansetregonly) do
		regO[userswhocansetregonly[b]]=1 -- makes a metatable to use l8r
	end
end


function NewUserConnected(user) -- user connects
	if regonly==1 then
		if user.iProfile==-1 then
			user:SendData(Bot,"This hub is for registered users only.")
			user:Disconnect()
		end
	end
end

function DataArrival(user,data)
	if strsub(data,1,1)=="<" then
		data=strsub(data,1,strlen(data)-1)
		local _,_,cmd=strfind(data,"%b<>%s+[%+%!%#%?](%S+)")
		if cmd=="private" then
			if regO[user.sName] then
				if regonly~=1 then
					regonly=1
					save()
					user:SendData(Bot,"Hub is now private.")
				else
					user:SendData(Bot,"Hub is already private.")
				end
			else
				user:SendData(Bot,"You are not allowed to use this command.")
			end
		elseif cmd=="public" then
			if regO[user.sName] then
				if regonly~=0 then
					regonly=0
					save()
					user:SendData(Bot,"Hub is now public.")
				else
					user:SendData(Bot,"Hub is already public.")
				end
			else
				user:SendData(Bot,"You are not allowed to use this command.")
			end
		end
	end
end

function save()
	writeto("regonly.ini")
	write("regonly="..regonly)
	writeto()
end
Everything could have been anything else and it would have just as much meaning.

aL1en

#2
okey,

thanks for your interest and time to do it..

got a msg on ptokax script editor box when start the script..

stack traceback:
   1:  function `Main' at line 26 [file `C:\hub\scripts\pvt.lua']

and this msg when type +public command on dc++:

stack traceback:
   1:  function `DataArrival' at line 57 [file `C:\hub\scripts\pvt.lua']

and this one msg when type +private..

stack traceback:
   1:  function `DataArrival' at line 45 [file `C:\hub\scripts\pvt.lua']


thanks again for ur time!

PS.Edit: If u can, no need to disconnect users when hub goes private, only close and allow join registered ones..

bastya_elvtars

heh, i forgot 2 declare botname... lol - edited the above script
Everything could have been anything else and it would have just as much meaning.

aL1en

nice nice..

seems to be working now..


can u modify instead of OP use the command to only MASTER? ;)

bastya_elvtars

QuoteOriginally posted by aL1en
nice nice..

seems to be working now..


can u modify instead of OP use the command to only MASTER? ;)

You enter the exact usernames that are allowed to use it regardless of the profile.
Everything could have been anything else and it would have just as much meaning.

aL1en

true true

lack of attention mine in there...

userswhocansetregonly={ -- ppl who are allowed to use it

"bastya_elvtars", "me", "you",

aL1en

one more thing..

when i start the hub.. i start it private.. and when i use command +public it say:  Hub is already public.

can u do the opposite in the script? to keep it private when started..

bastya_elvtars

erm i will add a +state command.

BTW there must be a regonly.ini file in the scripts folder - post its contents please. as @ the script's first startup the hub will start public, and if you type +private it becomes private until you type +public. (even if hub restarts)
Everything could have been anything else and it would have just as much meaning.

aL1en

QuoteBTW there must be a regonly.ini file in the scripts folder - post its contents please.


yeppa.. it auto-created the .ini file.. and its set inside: regonly=0

Quoteas @ the script's first startup the hub will start public, and if you type +private it becomes private until you type +public. (even if hub restarts)

thats the point.. i always start the hub private, and just sometimes i needed to make it public remotely via command line, if the hub start always public and when scripts restart it goes public then it will be a prob for me :\

bastya_elvtars

No, it will start the way you left it. See the .ini file after typing +private. If it won't change, you found a bug. :D
Everything could have been anything else and it would have just as much meaning.

aL1en

#11
QuoteOriginally posted by bastya_elvtars
No, it will start the way you left it. See the .ini file after typing +private. If it won't change, you found a bug. :D

yea.. the .ini changes when i use the 2 commands..

but...

non-reg people cant join when its set to PUBLIC.. remembering i have set on PtokaX the option on 'Advanced Option' tab the 'Registered users only' checkbox marked...

can u do something about??


Would be wonderful if ptaczek or optimus could include this kinda command in next hub release or robocop release ;)

bastya_elvtars

QuoteOriginally posted by aL1en
non-reg people cant join when its set to PUBLIC.. remembering i have set on PtokaX the option on 'Advanced Option' tab the 'Registered users only' checkbox marked...

Do they get the same message as with +private enabled?
Everything could have been anything else and it would have just as much meaning.

aL1en

#13
yeppa.. they get same message.. as if command were not actully being changing anything.. remembering im testing with non-reg users of course.

bastya_elvtars

I do not find the bug. I thought everything was OK.
Everything could have been anything else and it would have just as much meaning.

aL1en

hmmm u see no error in the coding?

cause i got many different users trying test  from different countries and all get PtokaX default msg of private hub even after i used the +public command..


wacko  :\

aL1en

and when i reg them normally using +regreg or any other profile they can enter.. but non registered users cant enter at all..

bastya_elvtars

when u set public... does the ini file change? if yes, how?
Everything could have been anything else and it would have just as much meaning.

aL1en

when i type +public.. INI file goes regonly=0

when i type +private.. INI goes regonly=1


but users not registered cant access/enter hub when in public mode..

bastya_elvtars

I can find no error. Have you really disabled reg only in PtokaX?
Everything could have been anything else and it would have just as much meaning.

aL1en

lol no.. i have not disabled the Reg Only option on PtokaX.. thats what im telling ya in some 2 or 3 posts over there :P


let me test now..

aL1en

:P~~~~~~~


now things flow easy..

haha.. so easy to fix :)

SMF spam blocked by CleanTalk