Skip to content

Instantly share code, notes, and snippets.

Alexey Melnichuk moteus

Block or report user

Report or block moteus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@moteus
moteus / freeswitch.i
Created Nov 29, 2016
Dbh query with params for FS
View freeswitch.i
%module freeswitch
%{
#include "freeswitch_lua.h"
%}
%typemap(in, checkfn = "lua_isfunction") SWIGLUA_FN {
$1.L = L;
$1.idx = $input;
}
@moteus
moteus / add_call_block.lua
Created Sep 2, 2016
Add call block number to FusionPBX
View add_call_block.lua
-- In dialplan
--
-- actin set pin_number=123456
-- actin lua add_call_block.lua
--
require "resources.functions.split"
local Database = require "resources.functions.database"
local log = require "resources.functions.log".call_block
@moteus
moteus / radiolisten.lua
Last active Dec 14, 2016
Radio Station listening for Freeswitch
View radiolisten.lua
-- Radio Station listening for Freeswitch
-- File containing stations. Modify location as needed
--
-- file format like
-- # Radiostation name
-- <ID>=<url>
--
STATIONS_FILE = [[c:\FreeSWITCH\scripts\radiostations.txt]]
@moteus
moteus / dbf.lua
Created Aug 22, 2016
Basic IO for dbf file format.
View dbf.lua
local printf = function(...) return print(string.format(...)) end
local function prequire(...)
local ok, mod = pcall(require, ...)
if ok then return mod end
return nil, mod
end
local function iif(cond, val1, val2)
if cond then return val1 end return val2
View service
-- File to conrol FusionPBX Lua services/monitors
-- @usage:
-- # stop `call_flow_subscribe` monitor
-- fs_cli -x "lua service flow shutdown"
-- # stop `mwi_subscribe` monitor
-- fs_cli -x "lua service mwi shutdown"
require "resources.functions.config"
local log = require "resources.functions.log".service
View apply_var.lua
local log = require "resources.functions.log".apply_var
function apply_global_var(str, t)
return (string.gsub(str, "$${.-}", function(key)
key = string.sub(key, 4, -2)
local var = t and t[key] or freeswitch.getGlobalVariable(key)
if not var then
log.warningf("unknown global variable: %s", key)
end
return var or ''
View gw_monitor.lua
--- Service for FusionPBX to monitor on gateway status
-- and send email notification when gateway change its status.
--
-- Require FusionPBX 4.3 or higher
--
-- start: `fs_cli -x 'luarun gw_monitor.lua'`
-- stop: `fs_cli -x 'lua service gw_monitor stop'`
-- pid file: `${script_dir}/run/gw_monitor.pid`
local email = 'mail@address'
@moteus
moteus / fax_queue_monitor.lua
Last active Dec 14, 2016
FusionPBX fax_queue_monitor based on EventCounsumer class
View fax_queue_monitor.lua
require "resources.functions.config"
require "resources.functions.split"
local log = require "resources.functions.log".fax_queue_monitor
local Next = require "app.fax.resources.scripts.queue.next"
local EventConsumer = require "resources.functions.event_consumer"
local pid_file = scripts_dir .. "/run/fax_queue.tmp"
local events = EventConsumer.new(pid_file)
@moteus
moteus / fsc.lua
Last active Dec 14, 2016
FusionPBX service control script
View fsc.lua
-- File to conrol FusionPBX Lua services/monitors
-- @usage:
-- # stop `call_flow_subscribe`
-- fs_cli -x "lua fsc.lua flow shutdown"
local destination = assert(argv[1])
local command = assert(argv[2])
local event = freeswitch.Event("CUSTOM", "fusion::" .. destination .. "::" .. command);
event:fire()
View call_block_edit.lua
local Database = require "resources.functions.database"
local log = require "resources.functions.log".call_block
require "resources.functions.split"
local api = freeswitch.API()
if not session:ready() then return end
local domain_name = session:getVariable("domain_name")
You can’t perform that action at this time.