Jump to content
Gold Sponsor: Data-Way IT-Consulting, Austria

  • IsRedirectedFromByNumber()

    IsRedirectedFromByNumber()

    Lua   → VBScript

     

    This function returns true if the call was redirected/transferred by a certain user (extension) or list of extensions, separated by ; (semikolon).

    Please see the Introduction chapter for some usage instructions.

     

    ------------------------------------------------------------------
    -- IsRedirectedFromByNumber
    --
    -- Returns true if the current call is redirected by any of the numbers
    -- given in the semicolon separated list. It also returns the number that
    -- redirected the call.
    --
    -- Parameter:
    --   sNumbers    semicolon separated list of all numbers
    --
    -- Return:
    --   boolean,
    --      true  - call redirected from given number
    --      false - call not redirected from given number
    --   string
    --      empty if call wasn't redirected by anyone from the list, 
    --      otherwise the extension that redirected the call.
    ------------------------------------------------------------------
    function IsRedirectedFromByNumber( sNumbers )
        PBXScript.OutputTrace ("------> IsRedirectedFromByNumber ( '" .. sNumbers .. "' )")
    
        local bReturn = false
        local sReturn = ""
        local sName   = ""
    
        local tNumbers = StringSplitToTable(sNumbers, ";")
    
        for i = 1, #tNumbers do
            PBXScript.OutputTrace ("Checking extension: " .. tNumbers[i])
            sName = GetUserNameFromExtension(tNumbers[i])
            PBXScript.OutputTrace ("Found username: " .. sName)
    
            if (sName ~= "") then
    
                if IsRedirectedFromByName(sName) then
                    PBXScript.OutputTrace ("Call is redirected from this user")
                    bReturn = true
                    sReturn = tNumbers[i]
                else
                    PBXScript.OutputTrace ("Call is not redirected from this user")
                end
    
            end
    
        end
    
        PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn))
        PBXScript.OutputTrace ("sReturn = " .. sReturn)
        PBXScript.OutputTrace ("<------ IsRedirectedFromByNumber")
    
        return bReturn, sNumber
    end

     

    Please note: if you are still using a "Lua Beta Testing" version of SwyxWare (i.e. v13.1x), you need to copy&paste the following function also into the Start block of your GSE script.

     

    -- split parts of string, separated by a given separator, into a table
    function StringSplitToTable ( sInput, sSeperator )
        local t={}
        if (sSeperator == nil) then
            sSeperator = "%s"
        end
        if (type(sInput) == "string") then
            if (type(sSeperator) == "string") then
                for sStr in string.gmatch(sInput, "([^".. sSeperator .."]+)") do
                    table.insert(t, sStr)
                end
            end
        end
        return t
    end

     

     

    This function makes use of the function GetUserNameFromExtension() to get the username for a given extension, and also the function IsRedirectedFromByName() to then check if the call is redirected/transferred from that user. It makes also use of the Server Script API function PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. It also uses the GSE build-in helper function StringSplitToTable() to find the caller number in the data from the file.

     

    This function was converted from VBScript into Lua from the initially posted version in this forum topic.
     

     


    Tom Wellige
     Share


     Share




    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.