Does anyone knows or can make one safe script to add and delete a user into the registererusers.dat file by an op?. I mean an standalone script.
What's wrong with the built in commands:
!addreguser - add registered user with specified profile (Master,Operator,Vip or Reg)
!delreguser - remove registered user with
Okey, I just put this togheter... might be bugs but test...
*EDITED*
--=-=-=-=-=-=-=-=-=-=--
-- ADD/DEL USER BOT
-- By NightLitch
-- Delete Part from Snowman's Mean Machine
-- Add Part by myself
-- Hope you all like it...
-- levels (reg, vip, op, master)
-- some bugs fixed....
--=-=-=-=-=-=-=-=-=-=--
--// BotName
BOTNAME = "-REG-BOT-"
--// HubOwner can only delete an Master
HUBOWNER = "tester"
cmd1 = "+adduser"
cmd2 = "+deluser"
--// data Arrival
function DataArrival(curUser, data)
if (strsub(data, 1, 1) == "<" ) then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
local _,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end
cmd = strlower(cmd)
if (cmd == cmd1) then
AddReggedUser(curUser,data)
return 1
elseif (cmd == cmd2) then
dodeluser(curUser,data)
return 1
end
end
end
function AddReggedUser(curUser,data)
local _,_,cmd,AddName,AddPass,AddLvl = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(.+)" )
if (AddName ~= nil and AddPass ~= nil and AddLvl ~= nil) then
ERRORLINE = "You can't register user with ( "..AddLvl.." ) status... You don't have the privileges!!!"
if AddLvl == "reg" then
if (curUser.iProfile) == 0 or (curUser.iProfile) == 1 then
AddRegUser(AddName, AddPass, 3)
AddingUser(curUser,data,AddName,AddPass,AddLvl)
else
curUser:SendData(BOTNAME,ERRORLINE)
end
elseif AddLvl == "vip" then
if (curUser.iProfile) == 0 or (curUser.iProfile) == 1 then
AddRegUser(AddName, AddPass, 2)
AddingUser(curUser,data,AddName,AddPass,AddLvl)
else
curUser:SendData(BOTNAME,ERRORLINE)
end
elseif AddLvl == "op" then
if (curUser.iProfile) == 0 then
AddRegUser(AddName, AddPass, 1)
AddingUser(curUser,data,AddName,AddPass,AddLvl)
else
curUser:SendData(BOTNAME,ERRORLINE)
end
elseif AddLvl == "master" then
if (curUser.iProfile) == 0 and (curUser.sName) == HUBOWNER then
AddRegUser(AddName, AddPass, 0)
AddingUser(curUser,data,AddName,AddPass,AddLvl)
else
curUser:SendData(BOTNAME,ERRORLINE)
end
end
else
curUser:SendData(BOTNAME,"*** the command is +adduser levels (reg, vip, op, master) ***");
end
end
function AddingUser(curUser,data,AddName,AddPass,AddLvl)
curUser:SendData(BOTNAME," "..AddName.." *** Have been succesfull added as new registered user with level ( "..AddLvl.." ) !! ***")
NewUser=GetItemByName(AddName)
if NewUser ~= nil then
NewUser:SendPM(BOTNAME, "Your have been added as registered user with lvl ( "..AddLvl.." ) your password is: ( "..AddPass.." ) Reconnect and use that!!")
end
end
function doGetReguserLevel(username)
if not username then username = "" end
local allprofiles = GetProfiles()
local index, profile, index2, user
for index, profile in allprofiles do
local users = GetUsersByProfile(profile)
for index2, user in users do
if strlower(user) == strlower(username) then
return GetProfileIdx(profile)
end
end
end
return -1
end -- Thanks to Skrollster for this part :)
function dodeluser(curUser,data)
s,e,arg = strfind( data, "%b<>%s+%S+%s+(.+)" )
usr = 0
go = 0
user = GetItemByName(arg)
iUserLevel = doGetReguserLevel(arg)
if iUserLevel then
usr = 1
if iUserLevel == 0 and (curUser.iProfile) == 0 and (curUser.sName) == HUBOWNER then
go = 99
elseif iUserLevel == 1 and (curUser.iProfile) == 0 then
go = 1
elseif (curUser.iProfile) == 0 or (curUser.iProfile) == 1 and iUserLevel == 2 then
go = 2
elseif (curUser.iProfile) == 0 or (curUser.iProfile) == 1 and iUserLevel == 3 then
go = 3
end
end
if usr == 1 and go == 99 then
DelRegUser(arg)
lang = "Revoked Master status for:"
curUser:SendData(BOTNAME, " "..lang.." "..arg)
lang = "just revoked Master status from:"
lang2 = "(OP's eyes only!!!)"
SendToOps(BOTNAME, curUser.sName.." "..lang.." "..arg.." "..lang2)
if user ~= nil then
lang = "You have just lost all your privileges!!!"
curUser:SendData(BOTNAME, " "..lang)
end
elseif usr == 1 and go == 1 then
DelRegUser(arg)
lang = "Revoked OP status for:"
curUser:SendData(BOTNAME, " "..lang.." "..arg)
lang = "just revoked OP status from:"
lang2 = "(OP's eyes only!!!)"
SendToOps(BOTNAME, curUser.sName.." "..lang.." "..arg.." "..lang2)
if user ~= nil then
lang = "You have just lost all your privileges!!!"
curUser:SendData(BOTNAME, " "..lang)
end
elseif usr == 1 and go == 2 then
DelRegUser(arg)
lang = "Revoked VIP status for:"
curUser:SendData(BOTNAME, " "..lang.." "..arg)
lang = "just revoked VIP status from:"
lang2 = "(OP's eyes only!!!)"
SendToOps(BOTNAME, curUser.sName.." "..lang.." "..arg.." "..lang2)
if user ~= nil then
lang = "You have just lost all your privileges!!!"
curUser:SendData(BOTNAME, " "..lang)
end
elseif usr == 1 and go == 3 then
DelRegUser(arg)
lang = "Revoked REG status for:"
curUser:SendData(BOTNAME, " "..lang.." "..arg)
lang = "just revoked REG status from:"
lang2 = "(OP's eyes only!!!)"
SendToOps(BOTNAME, curUser.sName.." "..lang.." "..arg.." "..lang2)
if user ~= nil then
lang = "You have just lost all your privileges!!!"
curUser:SendData(BOTNAME, " "..lang)
end
elseif usr == 0 then
lang = "You can't delete a user that does not exist. The nick you entered is NOT registered."
SendPmToNick(curUser.sName, BOTNAME, lang)
elseif usr == 1 and go == 0 then
lang = "You can NOT delete a user who has the same rank as you or higher."
lang2 = "Usage: +deluser "
curUser:SendData(BOTNAME, " "..lang)
curUser:SendData(BOTNAME, " "..lang2)
end
end
Took it from my MasterBot....
/NightLitch
Thanks nigth i will test it.
There is nothing wrong with built in command, but i don't understand the question, i'm looking for an script, everybody knows the built in commands run so .... ??
function DataArrival(user, data)
if strsub(data,1,1) == "<" or strsub(data,1,4) == "$To:" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,Name,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")
victim = GetItemByName(Name)
if user.iProfile == 1 or user.iProfile == 0 then
if (cmd=="+addmaster") then
Profile = GetProfileName(0)
AddRegUser(Name, pass, 0)
user:SendData(BotName, victim.sName..", Was sucessfully added as Master")
elseif (cmd=="+addop") then
Profile = GetProfileName(1)
AddRegUser(Name, pass, 1)
user:SendData(BotName, victim.sName..", Was sucessfully added as an OP")
elseif (cmd=="+addvip") then
Profile = GetProfileName(2)
AddRegUser(Name, pass, 2)
user:SendData(BotName, victim.sName..", Was sucessfully added as VIP")
elseif (cmd=="+addreg") then
Profile = GetProfileName(3)
AddRegUser(Name, pass, 3)
user:SendData(BotName, victim.sName..", Was sucessfully added as Reg")
end
end
end
end