PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: 6Marilyn6Manson6 on 21 May, 2005, 09:17:27

Title: Enable.Disable Registered User
Post by: 6Marilyn6Manson6 on 21 May, 2005, 09:17:27
Hello.. i request script with 2 commands:


!regdisable            Disable a user's registration, but he can be re-enabled later. You should use this if you only want to punish a user for example.
!regenable              Enable a user's registration, when he was previously disabled with !regdisable


ps: i want it in LUA 4 and LUA 5.. double script :P .. thanks bye bye
Title:
Post by: [NL]Pur on 21 May, 2005, 10:33:21
why not just nickban the registered user, you whould get the same without the all the overhead caused by   tracking of disabled users.
Title:
Post by: Dessamator on 21 May, 2005, 12:57:43
--Reg Account manager v1
--By Dessamator
--Request By Marylin Manson(or something like it)
--Commands : !regenable -- to enable an account
-- !regdisable -- to disable an account
-- !regstatus -- to see disabled account

tReg = {}
file ="accounts.dat"

--Config
bot =frmHub:GetHubBotName() -- Bot name
--

function Main()
LoadFromFile(file)
end


function ChatArrival(user,data)
data=string.sub(data, 1,-2)
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)%s+(%S+)")
if cmd=="!regdisable" and not(tReg[usr]) then
tReg[usr] = 1
user:SendData(bot,usr.." has been disabled!")
return 1
elseif cmd=="!regenable" and (tReg[usr]) then
tReg[usr] =nil
user:SendData(bot,usr.." has been enabled!")
return 1
end
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)")
if cmd=="!regstatus" then
temp="\r\n\These are the disabled accounts :\r\n"
for usr,pos in tReg do
temp=temp.."\t\Nick :"..usr.."\r\n"
end
user:SendData(bot,temp)
end
end

function OnExit()
SaveToFile(file, tReg,"tReg")
end


function ValidateNickArrival(User, Data)
for usr,pos in tReg do
if User.sName == usr then
User:SendData(bot,"Your account has been disabled!")
DisconnectByName(User.sName)
return 1
end
end
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 string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.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)
local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
handle:flush()
        handle:close()
end

function LoadFromFile(file)
local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
handle:flush()
handle:close()
        end

end


or use pur's idea :)
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 13:36:09
Thanks [NL]Pur ... thanks Dessemator... but i want a small upgrade :P ... Can you add command:

!disableprofile X   -- For disability all registered user of single level

example:

!disableprofile 0 -- disability all master registration
!disableprofile 1 -- disability all operator registration




and command:

!enableprofile X   -- For enable all registered user of single level

example:

!enableprofile 0 -- enable all master registration
!enableprofile 1 -- enable all operator registration

thanks a lot :)
Title:
Post by: Dessamator on 21 May, 2005, 15:37:07
--Account manager v1.1
--By Dessamator
--Request By Marylin Manson(or something like it)
--Commands : !regenable -- to enable an account
-- !regdisable -- to disable an account
-- !regstatus -- to see disabled account
-- !disableprofile -- to disable an account
-- !enableprofile -- to enable an account
-- !dprofiles -- to see disabled account

tReg = {}
tProfiles = {}
file ="accounts.dat"
file1="profiles.dat"

--Config
bot =frmHub:GetHubBotName() -- Bot name
--

function Main()
LoadFromFile(file)
LoadFromFile(file1)
end


function ChatArrival(user,data)
data=string.sub(data, 1,-2)
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)%s+(%S+)")
if cmd=="!regdisable" and not(tReg[usr]) then
tReg[usr] = 1
user:SendData(bot,usr.." has been disabled!")
return 1
elseif cmd=="!regenable" and (tReg[usr]) then
tReg[usr] =nil
user:SendData(bot,usr.." has been enabled!")
return 1
elseif cmd=="!disableprofile" and tonumber(usr) then
tProfiles[usr] = 1
user:SendData(bot,GetProfileName(usr).." Profile has been disabled!")
return 1
elseif cmd=="!enableprofile" and tonumber(usr) then
tProfiles[usr] = nil
user:SendData(bot,GetProfileName(usr).." Profile has been enabled!")
return 1

end
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)")
if cmd=="!regstatus" then
local temp="\r\n\These are the disabled accounts :\r\n"
for tUser,pos in tReg do
temp=temp.."\t\Nick :"..tUser.."\r\n"
end
user:SendData(bot,temp)
elseif cmd=="!dprofiles" then
local temp="\r\n\These are the disabled Profiles :\r\n"
for profile,pos in tProfiles do
temp=temp.."\t\Profile : "..GetProfileName(profile).."\r\n"
end
user:SendData(bot,temp)
end
end

function OnExit()
SaveToFile(file, tReg,"tReg")
SaveToFile(file1, tProfiles,"tProfiles")
end


function ValidateNickArrival(User, Data)
for usr,pos in tReg do
if User.sName == usr then
User:SendData(bot,"Your account has been disabled!")
DisconnectByName(User.sName)
return 1
end
end
for profile,pos in tProfiles do
if User.iProfile == tonumber(profile) then
User:SendData(bot,"Your Profile has been disabled!")
DisconnectByName(User.sName)
end
end
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 string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.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)
local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
handle:flush()
        handle:close()
end

function LoadFromFile(file)
local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
handle:flush()
handle:close()
        end

end


Done !
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 15:41:01
Very THANKS
Title:
Post by: Dessamator on 21 May, 2005, 16:25:53
QuoteOriginally posted by 6Marilyn6Manson6
Very THANKS

ur welcome  :))