Howdy!
Just thought about a script where users could be able to request to get registered in a hub, and the request saves into a tmp file or something, waiting for a OP/Master to either accept it or deny it, which results in the request gets erased from tmp file after answer from OP/Master. If the request is granted, the user would get a message when logging in or in real-time that his request has been accepted or denied.
Like
Request command for users:
!reqreg
Commands for OP/Master:
!seereq (See all requests)
!accept
!deny
cheers// Dj_OcTaGoN
Hi,
Here you go...
--## REQUESTED REGISTER BOT
--## Requested by Dj_OcTaGoN
--## Made by nErBoS
--## Commands:
--## +reqreg -- Makes a request to register your nick
--##
--## ONLY FOR OPs:
--## +seereq -- Show all the requests to register
--## +accept -- Accepts the request of regiter to an user
--## +denied -- Denies the request of register to an user
sBot = "RR-Bot"
arrRR = {}
fRR = "reqreg.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0
--## END ##--
function Main()
frmHub:RegBot(sBot)
LoadFromFile(fRR)
end
function OnExit()
SaveToFile(fRR,arrRR,"arrRR")
end
function NewUserConnected(user)
if (arrRR[user.sName] ~= nil) then
if (arrRR[user.sName]["DENIED"] ~= nil) then
user:SendData(sBot, "Your request for register has been denied.")
arrRR[user.sName] = nil
if (uLaterPtokax == 1) then
OnExit()
end
elseif (arrRR[user.sName]["ACCEPT"] ~= nil) then
user:SendData(sBot, "Your request for register has been accepted.")
arrRR[user.sName] = nil
if (uLaterPtokax == 1) then
OnExit()
end
end
end
end
function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+reqreg") then
local s,e,sPass = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sPass == nil) then
user:SendPM(sBot, "Syntax Error, +reqreg , you must write a pass.")
elseif (strfind(sPass, "[%c|\n\r]")) then
user:SendPM(sBot, "Invalid Password. Try Again.")
elseif (strfind(user.sName, "[%c|\n\r]")) then
user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
elseif (user.iProfile ~= -1) then
user:SendPM(sBot, "You are already register in our HUB.")
elseif (arrRR[user.sName] ~= nil) then
user:SendPM(sBot, "Your request for register hasn't yet been checked.")
else
arrRR[user.sName] = {["PASS"] = sPass, ["TIME"] = GetTime()}
user:SendPM(sBot, "Your request for register has been saved. Don't forget your password: "..sPass)
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (user.bOperator and cmd == "+seereq") then
local sTmp,sNick,arrTable = "Request of register in the HUB:\r\n\r\n"
for sNick, arrTable in arrRR do
if (arrTable["DENIED"] == nil and arrRR["ACCEPT"] == nil) then
sTmp = sTmp.."USER: "..sNick.." TIME OF REQUEST: "..arrTable["TIME"].."\r\n"
end
end
user:SendPM(sBot, sTmp)
return 1
elseif (user.bOperator and cmd == "+accept") then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +accept , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
elseif (GetItemByName(sNick) == nil) then
AddRegUser(sNick,arrRR[sNick]["PASS"],3)
arrRR[sNick] = {["ACCEPT"] = 1}
user:SendPM(sBot, "The user "..sNick.." was been registered.")
if (uLaterPtokax == 1) then
OnExit()
end
else
sNick = GetItemByName(sNick)
AddRegUser(sNick,arrRR[sNick]["PASS"],3)
arrRR[sNick] = {["ACCEPT"] = 1}
user:SendPM(sBot, "The user "..sNick.." was been registered.")
sNick:SendPM(sBot, "Your request for register was been accept. Please reconnect with your password.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
end
end
end
function GetTime()
return date("%d").."/"..date("%m").."/20"..date("%y").." "..date("%H")..":"..date("%M")..":"..date("%S")
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..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
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end
function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
Best regards, nErBoS
is there a way that tis bot checks if nick of requested user has [REG] in front of it and if not, write him something like, u must have [REG] in fornt of your nick?
thx
and also 2 more things... if someone request for registeration, send pm to ops that someone wanted to register, and also make another dat file, that will keep all the request... do no delete reguest after accepting or denying.]
thx
btw +accept or +seereq gets thiz error and not workin..
Syntax error: attempt to index a nil value
stack traceback:
1: function `DataArrival' at line 197 [file `...p\PtokaX-0.326.TestDrive4.99\scripts\regreq.lua']
btw accept nefunguje...
also +denied is doin nothing.) but that scipt would be verry usefull if workin.) so hope someone will solve theese problems.)
Hi,
Here you go...
--## REQUESTED REGISTER BOT 1.0
--## Requested by Dj_OcTaGoN
--## Made by nErBoS
--## Some BUGs corrected
--## Added a [REG] nick checker
--## OPs warning of new request
--## Save the denieds and accpets
--## Added the command +delete
--## Commands:
--## +reqreg -- Makes a request to register your nick
--##
--## ONLY FOR OPs:
--## +seereq -- Show all the requests to register
--## +accept -- Accepts the request of regiter to an user
--## +denied -- Denies the request of register to an user
--##
--## ONLY FOR MASTERS
--## +delete -- Deletes the entry of a request
sBot = "RR-Bot"
arrRR = {}
fRR = "reqreg.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0
--## END ##--
function Main()
frmHub:RegBot(sBot)
LoadFromFile(fRR)
end
function OnExit()
SaveToFile(fRR,arrRR,"arrRR")
end
function NewUserConnected(user)
if (arrRR[user.sName] ~= nil) then
if (type(arrRR[user.sName]["DENIED"]) == "table") then
user:SendData(sBot, "Your request for register has been denied.")
arrRR[user.sName]["DENIED"]["WARN"] = nil
arrRR[user.sName]["DENIED"] = arrRR[user.sName]["DENIED"]["OP"]
if (uLaterPtokax == 1) then
OnExit()
end
elseif (type(arrRR[user.sName]["ACCEPT"]) == "table") then
user:SendData(sBot, "Your request for register has been accepted.")
arrRR[user.sName]["ACCEPT"]["WARN"] = nil
arrRR[user.sName]["ACCEPT"] = arrRR[user.sName]["ACCEPT"]["OP"]
if (uLaterPtokax == 1) then
OnExit()
end
end
end
end
function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+reqreg") then
local s,e,sPass = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sPass == nil) then
user:SendPM(sBot, "Syntax Error, +reqreg , you must write a pass.")
elseif (strfind(sPass, "[%c|\n\r]")) then
user:SendPM(sBot, "Invalid Password. Try Again.")
elseif (strfind(user.sName, "[%c|\n\r]")) then
user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
elseif (user.iProfile ~= -1) then
user:SendPM(sBot, "You are already register in our HUB.")
elseif (strsub(user.sName,1,5) ~= "[REG]") then
user:SendPM(sBot, "To make the request you need to have the prefix [REG] on your nick.")
elseif (arrRR[user.sName] ~= nil) then
user:SendPM(sBot, "You have already made a request.")
else
arrRR[user.sName] = {["PASS"] = sPass, ["TIME"] = GetTime()}
user:SendPM(sBot, "Your request for register has been saved. Don't forget your password: "..sPass)
SendPmToOps(sBot, "The user "..user.sName.." has requested to be register.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (user.bOperator and cmd == "+seereq") then
local sTmp,sTmp2,sTmp3,sNick,arrTable = "Request of register in the HUB:\r\n\r\n","Users accepted:\r\n\r\n","Users denied:\r\n\r\n"
for sNick, arrTable in arrRR do
if (arrTable["DENIED"] ~= nil) then
if (arrTable["DENIED"]["OP"] == nil) then
sTmp3 = sTmp3.."USER: "..sNick.." DENIED BY: "..arrTable["DENIED"].."\r\n"
else
sTmp3 = sTmp3.."USER: "..sNick.." DENIED BY: "..arrTable["DENIED"]["OP"].."\r\n"
end
elseif (arrTable["ACCEPT"] ~= nil) then
if (arrTable["ACCEPT"]["OP"] == nil) then
sTmp2 = sTmp2.."USER: "..sNick.." ACCEPTED BY: "..arrTable["ACCEPT"].."\r\n"
else
sTmp2 = sTmp2.."USER: "..sNick.." ACCEPTED BY: "..arrTable["ACCEPT"]["OP"].."\r\n"
end
else
sTmp = sTmp.."USER: "..sNick.." TIME OF REQUEST: "..arrTable["TIME"].."\r\n"
end
end
user:SendPM(sBot, sTmp.."\r\n"..sTmp2.."\r\n"..sTmp3)
return 1
elseif (user.bOperator and cmd == "+accept") then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +accept , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
elseif (GetItemByName(sNick) == nil) then
AddRegUser(sNick,arrRR[sNick]["PASS"],3)
arrRR[sNick] = {["ACCEPT"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.." was been registered.")
if (uLaterPtokax == 1) then
OnExit()
end
else
sNick = GetItemByName(sNick)
AddRegUser(sNick.sName,arrRR[sNick.sName]["PASS"],3)
arrRR[sNick.sName] = {["ACCEPT"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.sName.." was been registered.")
sNick:SendPM(sBot, "Your request for register was been accept. Please reconnect with your password.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (user.bOperator and cmd == "+denied") then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +denied , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
elseif (GetItemByName(sNick) == nil) then
arrRR[sNick] = {["DENIED"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.." was been denied the register.")
if (uLaterPtokax == 1) then
OnExit()
end
else
sNick = GetItemByName(sNick)
arrRR[sNick.sName] = {["DENIED"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.sName.." was been denied the register.")
sNick:SendPM(sBot, "Your request for register was been denied.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (user.iProfile == 0 and cmd == "+delete") then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +delete , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
else
arrRR[sNick] = nil
user:SendPM(sBot, "The entry of the request of the nick "..sNick.." has been deleted.")
end
return 1
end
end
end
function GetTime()
return date("%d").."/"..date("%m").."/20"..date("%y").." "..date("%H")..":"..date("%M")..":"..date("%S")
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..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
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end
function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
Best regards, nErBoS
thx but still gettong errors
-4 +denied
Syntax error: attempt to index a nil value
stack traceback:
1: function `DataArrival' at line 295 [file `...p\PtokaX-0.326.TestDrive4.99\scripts\reqreg.lua']
-4 +accept
Syntax error: attempt to index a nil value
stack traceback:
1: function `DataArrival' at line 247 [file `...p\PtokaX-0.326.TestDrive4.99\scripts\reqreg.lua']
+delete works fine.)
thx.)
also if i can help u with something, tell me and i will try it.)
Hi,
You are using TD4.99, don't use, because its not a official release and has serious bugs, use TD4. About the errors, the lines that is showing in the error doesn't exist, have you made any mod in the script ??
Best regards, nErBoS
ok, thx, will try it when i get home.)
ok using td4
can request, can seereq,
can deny, but when used, the user is registered... but it write to user that it was denied
cannot accept
Syntax Error: attempt to index a nil value
when trying to deny after trying accept
Syntax Error: attempt to index a nil value
delete workin....
see it here....
[19:10:03] The user [REG]tester999 has requested to be register.
[19:10:20] <[OP]FrAcTi0N> +seereq
[19:10:20] Request of register in the HUB:
USER: [REG]tester999 TIME OF REQUEST: 09/12/2004 19:10:03
Users accepted:
Users denied:
[19:10:37] <[OP]FrAcTi0N> +accept [REG]tester999
[19:13:06] <[OP]FrAcTi0N> +denied [REG]tester999
[19:13:15] <[OP]FrAcTi0N> +seereq
[19:13:15] Request of register in the HUB:
USER: [REG]tester999 TIME OF REQUEST: 09/12/2004 19:10:03
Users accepted:
Users denied:
[19:15:13] <[OP]FrAcTi0N> +delete [REG]tester999
[19:15:13] The entry of the request of the nick [REG]tester999 has been deleted.
[19:16:55] <[OP]FrAcTi0N> +seereq
[19:16:55] Request of register in the HUB:
Users accepted:
Users denied:
Hi,
When i have time i will test it.
Best regards, nErBoS
Ok, thx for taking time. This is a very usefull script so apreciate all help :))
cheers // Dj_OcTaGoN
Hi,
I have edit the script above, try out now.
Best regards, nErBoS
will test it soon.) do u mean that u edited the first posted or the second one?
Hi,
I have edited the last one (second).
Best regards, nErBoS
thx, seems working.)
nice job.)
getting thiz error
after +accept - oka works fine
+seereq - Syntax Error: attempt to index field `ACCEPT' (a string value)
but +reqreg still works
and +accept too.)
didnot try +denied yet bcs do not want to rewrite all guides to register until it is not workin 100%
but still good work, getting better and better.)
have to restart script then....
oka, so installed another dc++ version and it seems that works fine.. maybe some problem of rmdc++
just the only thing is that when i restart the script all accepted and denied users are not saved, so when u type +seereq there is no one accepted or denied...
and also one more request to it...
when u deny someone is it possible to add reason why was it denied, that will show that it was denied?
such as +denied nick share some .....
thx
Hi,
About not saving you have to have this configuration according to the Ptokax you are using...
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0
--## END ##--
About adding a reason to the denied i will do it as soon as i can.
Best regards, nErBoS
oka if i do that, i can reg someone but after that +seereq is not workin.... file reqreg.dat was made, with request and accepted request....
but when try to use +seereq getting thiz error
Syntax Error: attempt to index field `ACCEPT' (a string value)
if i restart the script it is still the same, until i delete reqreg.dat....
thiz file:
arrRR = {
["[REG]Toxic"] = {
["TIME"] = "17/12/2004 22:52:50",
["PASS"] = "*****",
},
["[REG]subdrum47"] = {
["ACCEPT"] = "[OP]FrAcTi0N",
},
}
Hi,
Ok i will see that as soon as i can.
Best regards, nErBoS
Here is what happened with the Data.
When I changed it, it went OK after that.
I don't know what make itwrite that "wrong" format.
could you please find out the reason.
===== Original =================================
["user1"] = {
["ACCEPT"] = "userOP",
},
======= Made changes to work ===================
["user1"] = {
["ACCEPT"] = {
["OP"] = "userOP",
["WARN"] = 1,
},
},
================================================
I tried to figure out the problem.. and I think I got a clue....
After I accept the registed user and the user re-login, he get a notification because the data is as follows:
Quote["user1"] = {
["ACCEPT"] = {
["OP"] = "userOP",
["WARN"] = 1,
},
},
but.. then again.. this data is re constructed after he get the confirmation and then becomes:
Quote["user1"] = {
["ACCEPT"] = "userOP",
},
so... it's either a problem with the READing +seereq
OR the re-constucting.
could anyone please find out the problem?
well, I changed this thing -- hope it fixed it..
This will write the data correctly after a NEW user get in:
I added the ["OP"] in:
arrRR[user.sName]["ACCEPT"] = arrRR[user.sName]["ACCEPT"]["OP"]
to look like:
arrRR[user.sName]["ACCEPT"]["OP"]= arrRR[user.sName]["ACCEPT"]["OP"]
I hope this was the problem. (I don't wanna see more errors out of this...)
in anycase, here is the full script (hopefully working)
I hope "nErBoS" & "Mator" won't mind with the "configrations" that I used from Mutor's script (Message Board 1.01)
--## REQUESTED REGISTER BOT 1.0
--## Requested by Dj_OcTaGoN
--## Made by nErBoS [bugfix by NeoUltimicia (NewUserConnected)]
--## Some BUGs corrected
--## Added a [REG] nick checker
--## OPs warning of new request
--## Save the denieds and accpets
--## Added the command +delete
--## Commands:
--## +reqreg -- Makes a request to register your nick
--##
--## ONLY FOR OPs:
--## +seereqreg -- Show all the requests to register
--## +accreqreg -- Accepts the request of regiter to an user
--## +denreqreg -- Denies the request of register to an user
--##
--## ONLY FOR MASTERS
--## +delreqreg -- Deletes the entry of a request
sBot = frmHub:GetHubBotName()
arrRR = {}
fRR = "dats/reqreg.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax Version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax Version lower then 0.3.3.0
Prefix = "+" -- Command Prefix
Comm1 = strlower("reqreg") -- Request Registration
Comm2 = strlower("seereqreg") -- See Request Registration
Comm3 = strlower("accreqreg") -- Accept Request Registration
Comm4 = strlower("denreqreg") -- Denied Request Registration
Comm5 = strlower("delreqreg") -- Delete Request Registration entry
reqprofiles = {[0]=0, [1]=0, [2]=0, [3]=0 , [4]=0 , [5]=0 , [-1]=1 }
seeprofiles = {[0]=1, [1]=1, [2]=1, [3]=0 , [4]=1 , [5]=0 , [-1]=0 }
accprofiles = {[0]=1, [1]=1, [2]=0, [3]=0 , [4]=1 , [5]=0 , [-1]=0 }
denprofiles = {[0]=1, [1]=1, [2]=0, [3]=0 , [4]=1 , [5]=0 , [-1]=0 }
delprofiles = {[0]=1, [1]=1, [2]=0, [3]=0 , [4]=1 , [5]=0 , [-1]=0 }
--## END ##--
function Main()
frmHub:RegBot(sBot)
LoadFromFile(fRR)
end
function OnExit()
SaveToFile(fRR,arrRR,"arrRR")
end
function NewUserConnected(user)
if (arrRR[user.sName] ~= nil) then
if (type(arrRR[user.sName]["DENIED"]) == "table") then
user:SendData(sBot, "Your request for register has been denied.")
arrRR[user.sName]["DENIED"]["WARN"] = nil
arrRR[user.sName]["DENIED"]["OP"]= arrRR[user.sName]["DENIED"]["OP"]
if (uLaterPtokax == 1) then
OnExit()
end
elseif (type(arrRR[user.sName]["ACCEPT"]) == "table") then
user:SendData(sBot, "Your request for register has been accepted.")
arrRR[user.sName]["ACCEPT"]["WARN"] = nil
arrRR[user.sName]["ACCEPT"]["OP"]= arrRR[user.sName]["ACCEPT"]["OP"]
if (uLaterPtokax == 1) then
OnExit()
end
end
end
end
function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd==Prefix..Comm1) and reqprofiles[user.iProfile]==1 then
local s,e,sPass = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sPass == nil) then
user:SendPM(sBot, "Syntax Error, +reqreg , you must write a pass.")
elseif (strfind(sPass, "[%c|\n\r]")) then
user:SendPM(sBot, "Invalid Password. Try Again.")
elseif (strfind(user.sName, "[%c|\n\r]")) then
user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
elseif (user.iProfile ~= -1) then
user:SendPM(sBot, "You are already register in our HUB.")
-- elseif (strsub(user.sName,1,5) ~= "[REG]") then
-- user:SendPM(sBot, "To make the request you need to have the prefix [REG] on your nick.")
elseif (arrRR[user.sName] ~= nil) then
user:SendPM(sBot, "You have already made a request.")
else
arrRR[user.sName] = {["PASS"] = sPass, ["TIME"] = GetTime()}
user:SendPM(sBot, "Your request for register has been saved. Don't forget your password: "..sPass)
SendPmToOps(sBot, "The user "..user.sName.." has requested to be register.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (cmd==Prefix..Comm2) and seeprofiles[user.iProfile]==1 then
local sTmp,sTmp2,sTmp3,sNick,arrTable = "Request of register in the HUB:\r\n\r\n","Users accepted:\r\n\r\n","Users denied:\r\n\r\n"
for sNick, arrTable in arrRR do
if (arrTable["DENIED"] ~= nil) then
if (arrTable["DENIED"]["OP"] == nil) then
sTmp3 = sTmp3.."USER: "..sNick.." DENIED BY: "..arrTable["DENIED"].."\r\n"
else
sTmp3 = sTmp3.."USER: "..sNick.." DENIED BY: "..arrTable["DENIED"]["OP"].."\r\n"
end
elseif (arrTable["ACCEPT"] ~= nil) then
if (arrTable["ACCEPT"]["OP"] == nil) then
sTmp2 = sTmp2.."USER: "..sNick.." ACCEPTED BY: "..arrTable["ACCEPT"].."\r\n"
else
sTmp2 = sTmp2.."USER: "..sNick.." ACCEPTED BY: "..arrTable["ACCEPT"]["OP"].."\r\n"
end
else
sTmp = sTmp.."USER: "..sNick.." TIME OF REQUEST: "..arrTable["TIME"].."\r\n"
end
end
user:SendPM(sBot, sTmp.."\r\n"..sTmp2.."\r\n"..sTmp3)
return 1
elseif (cmd==Prefix..Comm3) and accprofiles[user.iProfile]==1 then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +accept , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
elseif (GetItemByName(sNick) == nil) then
AddRegUser(sNick,arrRR[sNick]["PASS"],3)
arrRR[sNick] = {["ACCEPT"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.." has been registered.")
if (uLaterPtokax == 1) then
OnExit()
end
else
sNick = GetItemByName(sNick)
AddRegUser(sNick.sName,arrRR[sNick.sName]["PASS"],3)
arrRR[sNick.sName] = {["ACCEPT"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.sName.." has been registered.")
sNick:SendPM(sBot, "Your request for register has been accept. Please reconnect with your password.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (cmd==Prefix..Comm4) and denprofiles[user.iProfile]==1 then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +denied , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
elseif (GetItemByName(sNick) == nil) then
arrRR[sNick] = {["DENIED"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.." has been denied the register.")
if (uLaterPtokax == 1) then
OnExit()
end
else
sNick = GetItemByName(sNick)
arrRR[sNick.sName] = {["DENIED"] = {["WARN"] = 1, ["OP"] = user.sName}}
user:SendPM(sBot, "The user "..sNick.sName.." has been denied the register.")
sNick:SendPM(sBot, "Your request for register has been denied.")
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (cmd==Prefix..Comm5) and delprofiles[user.iProfile]==1 then
local s,e,sNick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (sNick == nil) then
user:SendPM(sBot, "Syntax Error, +delete , you must write a nick.")
elseif (arrRR[sNick] == nil) then
user:SendPM(sBot, "The nick "..sNick.." isn't in our table of request (WARNING: the nick is case sensative).")
else
arrRR[sNick] = nil
user:SendPM(sBot, "The entry of the request of the nick "..sNick.." has been deleted.")
end
return 1
end
end
end
function GetTime()
return date("%d").."/"..date("%m").."/20"..date("%y").." "..date("%H")..":"..date("%M")..":"..date("%S")
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..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
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end
function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
Hello,
does somebody convert this script to Lua5?
This is very useful script! :] ;)
PLEASE! :D
Hi,
New script in LUA 5, you can find it HERE (http://board.univ-angers.fr/thread.php?threadid=3829&boardid=26&styleid=1&sid=e5da65f1f8c3cdc990c337e65923f40e) .
Best regards, nErBoS
thanks for releasing the LA in 5, I thought it won't be made... :) - but am glad I thought wrong...
I'll get it now.. and test it...