Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lunarise script #30

Open
hjpotter92 opened this issue Mar 22, 2015 · 2 comments
Open

Lunarise script #30

hjpotter92 opened this issue Mar 22, 2015 · 2 comments

Comments

@hjpotter92
Copy link
Member

While browsing the backups folder, I found this script I wrote a few years ago. I was wondering if the feature was worth implementing yet again...

function OnStartup()
    tConfig = {
        sBotName = SetMan.GetString( 21 ),
        sPrefixes = "[%!%#%?%/%*%-%+%.]",
        tGarble = {
            a = "4",
            e = "3",
            s = "z",
            S = "5",
            A = "4",
            E = "e",
            o = "0",
            O = "0",
            t = "+",
            T = "7",
            l = "1",
            ph = "f",
            y = "j",
            W = "\\/\\/",
            V = "\\/",
            x = "><"
        }
    }
    tLunarized = {}
    tUsingProfiles = {
        [-1] = false,               -- Regular users
        [0] = true,                 -- Admin
        [1] = true,                 -- Final Years
        [2] = true,                 -- Ops
        [3] = true,                 -- VIPs
        [4] = false,                -- Moderators
        [5] = false,                -- Registered users
        [6] = false,                -- sVIPs
        [7] = false                 -- Gymkhana users
    }
end

function ChatArrival( tUser, sMessage )
    local _, _, sCommand, sNick = sMessage:find( "%b<>%s"..tConfig.sPrefixes.."(%w+)%s(%S+)|" )
    if sCommand and (sCommand:lower() == "lunarize" or sCommand:lower() == "lunarise") and tUsingProfiles[tUser.iProfile] then
        if not sNick then
            Core.SendToUser( tUser, "<"..tConfig.sBotName.."> Sorry, nickname was not specified." )
            return true
        else
            local tTempUser = Core.GetUser( sNick )
            if not tTempUser then
                Core.SendToUser( tUser, "<"..tConfig.sBotName.."> Sorry, the user is currently offline." )
                return true
            end
            tLunarized[tTempUser.sNick:lower()] = true
            Core.SendToAll( "<"..tConfig.sBotName.."> The user "..tTempUser.sNick.." has been lunarized." )
            return true
        end
    elseif sCommand and (sCommand:lower() == "unlunarize" or sCommand:lower() == "unlunarise") and tUsingProfiles[tUser.iProfile] then
        if not sNick then
            Core.SendToUser( tUser, "<"..tConfig.sBotName.."> Sorry, nickname was not specified." )
            return true
        else
            if not tLunarized[sNick:lower()] then
                Core.SendToUser( tUser, "<"..tConfig.sBotName.."> Sorry, the user was not lunarized." )
                return true
            end
            tLunarized[sNick:lower()] = nil
            Core.SendToAll( "<"..tConfig.sBotName.."> The user "..sNick.." has been unlunarized." )
            return true
        end
    elseif sCommand and (sCommand:lower() == "lunarize" or sCommand:lower() == "lunarise" or sCommand:lower() == "unlunarize" or sCommand:lower() == "unlunarise") and not tUsingProfiles[tUser.iProfile] then
        Core.SendToUser( tUser, "<"..tConfig.sBotName.."> You don't have permissions to use this command." )
        return false
    end
    if not tLunarized[tUser.sNick:lower()] then
        return false
    elseif sCommand and tUsingProfiles[tUser.iProfile] then
        return false
    else
        local _, _, sMessage = sMessage:find( "%b<>%s(.*)" )
        sMessage = GarbleMessage( sMessage )
        Core.SendToAll( "<"..tUser.sNick.."> "..sMessage )
        return true
    end
    return false
end

function ToArrival( tUser, sMessage )
    local _, _, sTo, sCommand = sMessage:find( "^\$To: (%S+) .*%b<>%s"..tConfig.sPrefixes.."(%w+)%s" )
    if sTo == tConfig.sBotName then
        if sCommand and (sCommand:lower() == "lunarize" or sCommand:lower() == "lunarise") and tUsingProfiles[tUser.iProfile] then
            local _, _, sMessage = sMessage:find( "%b$$(.*)" )
            ChatArrival( tUser, sMessage )
            return true
        elseif sCommand and (sCommand:lower() == "unlunarize" or sCommand:lower() == "unlunarise") and tUsingProfiles[tUser.iProfile] then
            local _, _, sMessage = sMessage:find( "%b$$(.*)" )
            ChatArrival( tUser, sMessage )
            return true
        end
    end
    return false
end

function GarbleMessage( sLine )
    for cIndex, sLeet in pairs( tConfig.tGarble ) do
        sLine = sLine:gsub( cIndex, sLeet )
    end
    return sLine
end

The script would need to be rewritten (and probably put inside chatlogger.lua) before actually putting it to use. I just wanted to raise the discussion whether it'd be useful or abused?

@System64
Copy link

It would be quite useful, please include it.

@nishithshah2211
Copy link
Member

@hjpotter92 Abused how? We can put a command to set off lunarize just like desu etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants