PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: aL1en on 20 February, 2005, 00:03:13

Title: Request PUBLIC/PRIVATE Robocop Addon
Post by: aL1en on 20 February, 2005, 00:03:13
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.
Title:
Post by: bastya_elvtars on 20 February, 2005, 00:34:10
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
Title:
Post by: aL1en on 20 February, 2005, 12:45:28
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..
Title:
Post by: bastya_elvtars on 20 February, 2005, 12:48:22
heh, i forgot 2 declare botname... lol - edited the above script
Title:
Post by: aL1en on 20 February, 2005, 13:02:14
nice nice..

seems to be working now..


can u modify instead of OP use the command to only MASTER? ;)
Title:
Post by: bastya_elvtars on 20 February, 2005, 13:06:46
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.
Title:
Post by: aL1en on 20 February, 2005, 13:36:05
true true

lack of attention mine in there...

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

"bastya_elvtars", "me", "you",
Title:
Post by: aL1en on 20 February, 2005, 13:39:07
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..
Title:
Post by: bastya_elvtars on 20 February, 2005, 13:42:55
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)
Title:
Post by: aL1en on 20 February, 2005, 14:00:14
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 :\
Title:
Post by: bastya_elvtars on 20 February, 2005, 14:35:35
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
Title:
Post by: aL1en on 22 February, 2005, 20:09:10
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 ;)
Title:
Post by: bastya_elvtars on 22 February, 2005, 20:43:02
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?
Title:
Post by: aL1en on 23 February, 2005, 09:34:50
yeppa.. they get same message.. as if command were not actully being changing anything.. remembering im testing with non-reg users of course.
Title:
Post by: bastya_elvtars on 23 February, 2005, 13:25:13
I do not find the bug. I thought everything was OK.
Title:
Post by: aL1en on 23 February, 2005, 17:28:45
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  :\
Title:
Post by: aL1en on 23 February, 2005, 17:33:40
and when i reg them normally using +regreg or any other profile they can enter.. but non registered users cant enter at all..
Title:
Post by: bastya_elvtars on 23 February, 2005, 17:41:07
when u set public... does the ini file change? if yes, how?
Title:
Post by: aL1en on 23 February, 2005, 21:32:29
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..
Title:
Post by: bastya_elvtars on 23 February, 2005, 21:39:51
I can find no error. Have you really disabled reg only in PtokaX?
Title:
Post by: aL1en on 25 February, 2005, 16:44:52
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..
Title:
Post by: aL1en on 25 February, 2005, 16:53:43
:P~~~~~~~


now things flow easy..

haha.. so easy to fix :)