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 / native.lua
Last active Dec 14, 2016
Database class to works with parameters
View native.lua
--
-- Native backend to FusionPBX database class
--
local log = require "resources.functions.log".database
assert(freeswitch, "Require FreeSWITCH environment")
local param_pattern = "%f[%a%d:][:]([%a][%a%d_]*)"
@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 / 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]]
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")
View freeswitch.xml
<?xml version="1.0"?>
<document type="freeswitch/xml">
<X-PRE-PROCESS cmd="set" data="local_address=192.168.123.58"/>
<X-PRE-PROCESS cmd="set" data="local_port=5064"/>
<X-PRE-PROCESS cmd="set" data="domain_name=$${local_address}"/>
<X-PRE-PROCESS cmd="set" data="external_address=$${local_address}"/>
<X-PRE-PROCESS cmd="set" data="external_port=5088"/>
<section name="configuration">
@moteus
moteus / call_forward_api.lua
Last active Apr 18, 2017
FusionPBX. Use Lua code to build CF dialplan from Web UI
View call_forward_api.lua
local Database = require "resources.functions.database"
local route_to_bridge = require "resources.functions.route_to_bridge"
local json = require "resources.functions.lunajson"
local function decode_value(v)
return (string.gsub(v, [[\u00(%x%x)]], {
['22'] = '"';
['27'] = "'";
['26'] = "&";
['3C'] = "<"; ['3c'] = "<";
View sms_forward.lua
--! @usage
-- forward incoming message to some extension
-- <action application="lua" data="sms_forward.lua '${from}' '100@my.domain.com'" />
local function escape(s)
s = string.gsub(s, '\\', '\\\\')
s = string.gsub(s, '|', '\\|')
return s
end
@moteus
moteus / sms_bcd2gsm.lua
Last active May 1, 2017
API command to fix ALPHANUMERIC source numbers received from mod_gsmopen
View sms_bcd2gsm.lua
-- API command to fix ALPHANUMERIC source numbers received from mod_gsmopen
-- Usage: <action application="set" data="from=${lua(sms_bcd2gsm.lua ${from})}" />
-- !! Do not forget that for resending uses not `from` header but `from_full`.
--
-- https://github.com/moteus/lua-tpdu
--
assert(stream, 'this is API command')
local tut = require "tpdu.utils"
@moteus
moteus / com2tcp.lua
Last active May 16, 2017
Connect to serial port via tcp
View com2tcp.lua
local uv = require "lluv"
uv.rs232 = require "lluv.rs232"
local sockets = {}
local port = uv.rs232('COM4',{
baud = '_9600';
data_bits = '_8';
parity = 'NONE';
stop_bits = '_1';
View gismeteo.lua
local curl = require "cURL"
local lom = require "lxp.lom"
local GISMETEO_CODES = {
['7495'] = '27612_1';
['7496'] = '27612_1';
['7499'] = '27612_1';
}
local gismeteo_base_url = "http://informer.gismeteo.ru/xml/"
You can’t perform that action at this time.