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.
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
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..
heh, i forgot 2 declare botname... lol - edited the above script
nice nice..
seems to be working now..
can u modify instead of OP use the command to only MASTER? ;)
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.
true true
lack of attention mine in there...
userswhocansetregonly={ -- ppl who are allowed to use it
"bastya_elvtars", "me", "you",
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..
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)
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 :\
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
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 ;)
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?
yeppa.. they get same message.. as if command were not actully being changing anything.. remembering im testing with non-reg users of course.
I do not find the bug. I thought everything was OK.
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 :\
and when i reg them normally using +regreg or any other profile they can enter.. but non registered users cant enter at all..
when u set public... does the ini file change? if yes, how?
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..
I can find no error. Have you really disabled reg only in PtokaX?
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..
:P~~~~~~~
now things flow easy..
haha.. so easy to fix :)