-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhandler.lua.example
More file actions
54 lines (42 loc) · 1.07 KB
/
handler.lua.example
File metadata and controls
54 lines (42 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- Receive current channels status
local status = ami.Status()
-- Receive Codec translation
local stuff = ami.command{command = 'core show translation'}
-- Redirect some(not necessarily current) channel
local status = ami.redirect{
channel = 'SIP/1-0000012c',
context = 'transfer',
exten = 's',
priority = 1
}
-- Get Global Variable
local var = ami.getvar {variable = 'TEST'}
-- Get variable of some channel
local cvar = ami.getvar {
variable = 'CHANNEL',
channel = 'SIP/1-0000012c'
}
-- Add event-listener
ami.addEvent('hangup', function(e) print(e['Channel'] .. ' is ' .. e['Event']))
-- OR
ami.addEvents{
['Hangup'] = function(e)
print(e['Channel'] .. ' is ' .. e['Event'])
end,
['Answer'] == function(e)
print(e['Channel'] .. ' is ' .. e['Event'])
end
}
-- Processing all new calls
function subroutine(...)
local pin
local app, channel = ...
app.Answer()
app.Read('PIN','beep',_,_,_,8)
pin = channel.get('PIN')
app.Verbose('User entered ' .. pin)
if pin ~= '0000' then
app.Vebose('Wrong pin code ...') return
end
app.Dial('SIP/trunk/1234',120,'gr')
end