Telefonní systém kosmické lodi Hipporion ze SKSP2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

141 lines
4.3 KiB

extensions = {}
extensions.participants = {}
extensions.orgs = {}
extensions.emerg = {}
extensions.emerg_listen = {}
extensions.ann_bracket = {}
extensions.odorik = {}
extensions.external = {}
function sip_exten(ch, ext)
app.dial("PJSIP/" .. ext, 40)
local status = channel.DIALSTATUS:get()
app.verbose("status: " .. status)
if status == "BUSY" then
flags="b"
else
flags="u"
end
app.voicemail(ext, flags)
end
function ann_unicast(ch, ext)
app.dial("PJSIP/emerg" .. string.sub(ext, 4))
end
function sip_nightmode(ch, ext)
local hour = tonumber(os.date("%H"))
local minute = tonumber(os.date("%M"))
if hour < 12 or (hour == 12 and minute < 10) or hour > 23 or (hour == 23 and minute > 20) then
app.playback("/opt/ksp/sounds/nocni_klid")
app.voicemail(ext)
else
sip_exten(ch, ext)
end
end
function voicemail_direct(ch, ext)
app.voicemail(string.sub(ext, 3))
end
function voicemail_listen(ch, ext)
local caller = channel.CALLERID("num"):get()
app.voicemailmain(caller, "s") -- no password prompt
end
function conf(ch, ext)
app.confbridge(ext)
end
function add(ctxs, ext, func)
for i = 1, #ctxs do
extensions[ctxs[i]][ext] = func
end
end
function ann_listen(ch, ext)
app.confbridge("120", "ann", "ann_listen", "empty_menu")
end
function ann_speak(ch, ext)
app.confbridge("120", "ann", "ann_speak")
end
function ann_bracket(ch, ext)
app.system("/opt/ksp/ann_listen_all.sh")
app.confbridge("120", "ann", "ann_speak")
end
function ann_bracket_hangup(ch, ext)
app.system("/opt/ksp/ann_end_all.sh")
end
function ann_bracket_goto(ch, ext)
app.goto("ann_bracket", "122", 1)
end
function fbi(ch, ext)
app.dial("PJSIP/910119352@odorik")
end
function odorik_incoming(ch, ext)
app.answer()
app.read("klapka", "/opt/ksp/sounds/klapka")
local klapka = channel.klapka:get()
app.goto("external", klapka, 1)
end
function su(ch, ext)
app.read("heslo", "/opt/ksp/sounds/heslo")
local heslo = channel.heslo:get()
if heslo == "2886287" then
app.read("klapka", "/opt/ksp/sounds/klapka")
local klapka = channel.klapka:get()
app.goto("orgs", klapka, 1)
else
app.playback("/opt/ksp/sounds/spatne_heslo")
app.hangup()
end
end
--http://lua-users.org/wiki/StringTrim
function trim1(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function call_rand(ch, ext)
local caller = channel.CALLERID("num"):get():gsub("'", "")
local handle = io.popen("/opt/ksp/rand_line.sh '" .. caller .. "'")
local line = trim1(handle:read("*all"))
handle:close()
app.verbose("RAND: " .. line)
app.dial("PJSIP/"..line)
end
function snd(name)
return function(ch, ext)
app.answer()
app.playback("/opt/ksp/sounds/" .. name)
app.hangup()
end
end
add({"orgs"}, "_2X", sip_exten) -- org phones
add({"orgs"}, "_[345]X", sip_exten) -- participant phones
-- night mode restriction applies only when calling from participant phones
add({"participants", "external"}, "_2X", sip_nightmode) -- org phones
add({"participants", "external"}, "_[345]X", sip_nightmode) -- participant phones
add({"orgs", "participants", "external"}, "_11.", conf)
add({"orgs", "participants", "emerg_listen", "external"}, "120", ann_listen)
add({"orgs"}, "121", ann_speak)
-- Because hangup actions are per-context and not per-extension, we need to jump to
-- a separate context to allow a hangup handler to terminate listeners after a call
-- to 122 is done.
add({"orgs"}, "122", ann_bracket_goto)
add({"ann_bracket"}, "122", ann_bracket)
add({"ann_bracket"}, "h", ann_bracket_hangup)
add({"orgs"}, "_123XX", ann_unicast)
add({"orgs", "participants"}, "131", voicemail_listen) -- does not work, done in extensions.conf!!
add({"orgs", "participants", "external"}, "_14XX", voicemail_direct)
add({"participants", "external"}, "78", su)
add({"odorik"}, "s", odorik_incoming)
add({"orgs", "participants", "external"}, "160", fbi)
add({"orgs", "participants", "external"}, "910119352", fbi)
-- Na některých telefonech je od původních majitelů nálepka "call helpdesk at 8888"
add({"orgs", "participants", "external"}, "8888", fbi)
add({"orgs", "participants", "external"}, "4445", snd("hr"))
add({"orgs", "participants", "external"}, "130", call_rand)
--add({"orgs", "participants"}, "_131", snd("sadtromb"))