PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: jsjen on 06 January, 2005, 10:18:12

Title: Masters ability to change passwords
Post by: jsjen on 06 January, 2005, 10:18:12
Hi there, I am wondering if there is a way for ops and masters to change passwords for users when they forget and get banned?


Cheers jason

im using Robocop v9.0f
Title:
Post by: bastya_elvtars on 06 January, 2005, 10:22:15
yep there is, altho no time here 2 write :)

the idea itself owns!
Title:
Post by: Themaster on 06 January, 2005, 10:31:58
maybe this will help you out
-- Set a Bot Name
sBot = "Password"

-- Prefix to use
sPrefix = "+"

-- Commands
sCOM1 = "mypass"
sCOM2 = "repass"
sCOM3 = "changepass"
sCOM4 = "getpass"
sCOM5 = "passwordlist"


-----------------------------------------------------------------------------------
tPassword = {};
tProfiles = {};
-----------------------------------------------------------------------------------
function Main()
readfrom("../RegisteredUsers.dat")
while 1 do
line = read()
if line == nil then break end
local s,e,sName,sPassword,sProfile = strfind(line,"(.+)|(.+)|(.+)")
tPassword[sName] = {Profile = sProfile,Password = sPassword}
end
readfrom()

readfrom("../Profiles.dat")
while 1 do
line = read()
if line == nil then break end
local s,e,sProfile,sName = strfind(line,"(%d+)|(%S+)|%d+")
tProfiles[sName] = tonumber(sProfile)
end
readfrom()
end
-----------------------------------------------------------------------------------
function DataArrival(user,sData)
if ( strsub( sData,1,1 ) == "<" ) then
sData = strsub( sData,1,-2 )
local s,e,sCmd = strfind(sData,"^%b<>%s+(%S+)")
if ( strsub( sCmd,1,1 ) == sPrefix ) then
sCmd = strsub( sCmd,2,-1 )
sCmd = strlower(sCmd)
if ( sCmd == sCOM1 ) then
if (user.iProfile ~= -1) then
if (tPassword[user.sName]) then
user:SendData(sBot,"Your password is : \""..tPassword[user.sName].Password.."\", Keep it in a safe place!")
return 1
else
user:SendData(sBot,"For some reason you could not be found!")
return 1
end
end
elseif ( sCmd == sCOM2 ) then
if (user.iProfile ~= -1) then
local s,e,sPass = strfind(sData,"^%b<>%s+%S+%s+(%S+)")
if sPass and strlen(sPass) >= 4 then
AddRegUser(user.sName,sPass,3)
user:SendData(sBot,"Sucessfully changed your password!")
return 1
else
user:SendData(sBot,"Either you didn't enter a password or it was too short, Password must be atleast 4 characters!")
return 1
end
else
user:SendData(sBot,"You are not registered!")
return 1
end
elseif ( sCmd == sCOM3 ) then
if (user.iProfile == 0) then
local s,e,Name,Pass = strfind(sData,"^%b<>%s+%S+%s+(%S+)%s*(%S+)")
if Name then
if Pass and strlen(Pass) >= 4 then
if tPassword[Name] then
Profile = tonumber(tPassword[Name].Profile)
AddRegUser(Name,Pass,Profile)
user:SendData(sBot,"You have sucessfully changed password of "..Name.." to \""..Pass.."\"")
return 1
else
user:SendData(sBot,"\""..Name.."\" is not registered on this hub!")
return 1
end
else
user:SendData(sBot,"Either you didn't enter a password or it was too short, Password must be atleast 4 characters!")
return 1
end
else
user:SendData(sBot,"Please enter a name that you will change password for!")
return 1
end
end
elseif ( sCmd == sCOM4 ) then
if (user.iProfile == 0) then
local s,e,Name = strfind(sData,"^%b<>%s+%S+%s+(%S+)")
if Name then
if (tPassword[Name]) then
user:SendData(sBot,"\""..Name.."\"'s Password is : \""..tPassword[Name].Password.."\"")
return 1
else
user:SendData(sBot,"\""..Name.."\" is not registered in this hub!")
return 1
end
else
user:SendData(sBot,"Please enter a name to get his / hers password!")
return 1
end
end
elseif ( sCmd == sCOM5 ) then
if (user.iProfile == 0) then
local s,e,sPro = strfind(sData,"^%b<>%s+%S+%s+(%S+)")
if sPro then
if (tProfiles[sPro]) then
Idx = GetProfileIdx(sPro)
Profiles = GetUsersByProfile(sPro)
sMsg = ""
for i,v in Profiles do
sMsg = sMsg.."( "..v.." )\r\nPassword : "..tPassword[v].Password.."\r\n\r\n"
end
user:SendData(sBot,"\r\n\r\n"..sMsg)
return 1
else
user:SendData(sBot,"\""..sPro.."\" is not a valid profile name!")
return 1
end
else
user:SendData(sBot,"Please enter a profile name, etc : "..sPrefix..sCOM5.." VIP")
return 1
end
end
end
end
end
end
Title:
Post by: Anna on 06 January, 2005, 13:34:52
I found it a cool script so I figured I'll try it... but it dont seem to work :(

*edit* found the problem, I'm set as NetFounder... it only works for thoose set as master...

is there any way it can be altered, smothly, to include other profiles (I can obviously copy the code part and enter the correct profilenumber if I wanna allow more to do it, but I have a feeling its not a smooth way)

mypass and repass works, but cant seem to get the others to work :(
Title:
Post by: Madman on 06 January, 2005, 17:46:37
-- Set a Bot Name
sBot = "Password"

-- Prefix to use
sPrefix = "+"

-- Commands
sCOM1 = "mypass"
sCOM2 = "repass"
sCOM3 = "changepass"
sCOM4 = "getpass"
sCOM5 = "passwordlist"

AllowedProfiles = { -- Set 1 To Allow Command sCOM 3-5
[0] = 1, -- Masters
[1] = 0, -- Operators
[2] = 0, -- VIP
[3] = 0, -- Reg
[4] = 0, -- Moderator
[5] = 1, -- NetFounder
}

-----------------------------------------------------------------------------------
tPassword = {};
tProfiles = {};
-----------------------------------------------------------------------------------
function Main()
readfrom("../RegisteredUsers.dat")
while 1 do
line = read()
if line == nil then break end
local s,e,sName,sPassword,sProfile = strfind(line,"(.+)|(.+)|(.+)")
tPassword[sName] = {Profile = sProfile,Password = sPassword}
end
readfrom()

readfrom("../Profiles.dat")
while 1 do
line = read()
if line == nil then break end
local s,e,sProfile,sName = strfind(line,"(%d+)|(%S+)|%d+")
tProfiles[sName] = tonumber(sProfile)
end
readfrom()
end
-----------------------------------------------------------------------------------
function DataArrival(user,sData)
if ( strsub( sData,1,1 ) == "<" ) then
sData = strsub( sData,1,-2 )
local s,e,sCmd = strfind(sData,"^%b<>%s+(%S+)")
if ( strsub( sCmd,1,1 ) == sPrefix ) then
sCmd = strsub( sCmd,2,-1 )
sCmd = strlower(sCmd)
if ( sCmd == sCOM1 ) then
if (user.iProfile ~= -1) then
if (tPassword[user.sName]) then
user:SendData(sBot,"Your password is : \""..tPassword[user.sName].Password.."\", Keep it in a safe place!")
return 1
else
user:SendData(sBot,"For some reason you could not be found!")
return 1
end
end
elseif ( sCmd == sCOM2 ) then
if (user.iProfile ~= -1) then
local s,e,sPass = strfind(sData,"^%b<>%s+%S+%s+(%S+)")
if sPass and strlen(sPass) >= 4 then
AddRegUser(user.sName,sPass,3)
user:SendData(sBot,"Sucessfully changed your password to: \""..tPassword[user.sName].Password)
return 1
else
user:SendData(sBot,"Either you didn't enter a password or it was too short, Password must be atleast 4 characters!")
return 1
end
else
user:SendData(sBot,"You are not registered!")
return 1
end
elseif ( sCmd == sCOM3 ) then
if AllowedProfiles[user.iProfile]==1 then
local s,e,Name,Pass = strfind(sData,"^%b<>%s+%S+%s+(%S+)%s*(%S+)")
if Name then
if Pass and strlen(Pass) >= 4 then
if tPassword[Name] then
Profile = tonumber(tPassword[Name].Profile)
AddRegUser(Name,Pass,Profile)
user:SendData(sBot,"You have sucessfully changed password of "..Name.." to \""..Pass.."\"")
return 1
else
user:SendData(sBot,"\""..Name.."\" is not registered on this hub!")
return 1
end
else
user:SendData(sBot,"Either you didn't enter a password or it was too short, Password must be atleast 4 characters!")
return 1
end
else
user:SendData(sBot,"Please enter a name that you will change password for!")
return 1
end
end
elseif ( sCmd == sCOM4 ) then
if AllowedProfiles[user.iProfile]==1 then
local s,e,Name = strfind(sData,"^%b<>%s+%S+%s+(%S+)")
if Name then
if (tPassword[Name]) then
user:SendData(sBot,"\""..Name.."\"'s Password is : \""..tPassword[Name].Password.."\"")
return 1
else
user:SendData(sBot,"\""..Name.."\" is not registered in this hub!")
return 1
end
else
user:SendData(sBot,"Please enter a name to get his / hers password!")
return 1
end
end
elseif ( sCmd == sCOM5 ) then
if AllowedProfiles[user.iProfile]==1 then
local s,e,sPro = strfind(sData,"^%b<>%s+%S+%s+(%S+)")
if sPro then
if (tProfiles[sPro]) then
Idx = GetProfileIdx(sPro)
Profiles = GetUsersByProfile(sPro)
sMsg = ""
for i,v in Profiles do
sMsg = sMsg.."( "..v.." )\r\nPassword : "..tPassword[v].Password.."\r\n\r\n"
end
user:SendData(sBot,"\r\n\r\n"..sMsg)
return 1
else
user:SendData(sBot,"\""..sPro.."\" is not a valid profile name!")
return 1
end
else
user:SendData(sBot,"Please enter a profile name, etc : "..sPrefix..sCOM5.." VIP")
return 1
end
end
end
end
end
end

Try this....
Title:
Post by: Anna on 06 January, 2005, 18:30:04
Thanx, works fine now :D
Title:
Post by: jsjen on 06 January, 2005, 21:20:03
I would have thought there would have been one already
thanks heaps for the quick response mate
Title:
Post by: kepp on 06 January, 2005, 23:42:48
If you tried a search you would have found it