-
Notifications
You must be signed in to change notification settings - Fork 0
/
agi-reroute.py
38 lines (22 loc) · 1.01 KB
/
agi-reroute.py
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
#!/usr/bin/python
"""
SCRIPT BY MENDEL HORNBACHER TO REROUTE CALLS IN ASTERISK BASED ON DB INPUT
STATUS: BUG FIXING
"""
from asterisk.agi import *
agi = AGI()
import sys
import sqlite3test
agi.verbose("PYTHON AGI SCRIPT: CONNECTING TO DATABASE")
db = sqlite3test.sqlitedb("/usr/agi/test.db")
agi.verbose("PYTHON AGI SCRIPT: STARTED")
agi.verbose("PYTHON AGI SCRIPT: CALLER ID -> " + agi.env['agi_callerid'])
agi.verbose("PYTHON AGI SCRIPT: CALLER ID TYPE -> " + str(type(agi.env['agi_callerid'])))
database = db.get_from_queue(agi.env['agi_callerid'], agi)
agi.verbose("PYTHON AGI SCRIPT: DATABASE TYPE -> "+str(type(database)))
if len(database) > 0:
agi.verbose("PYTHON AGI SCRIPT: CALLER ID FOUND IN DB -> REROUTING CALLER ID -> " + str(database[0]))
agi.goto_on_exit(context=str(database[1]), extension=str(database[2]), priority=str(database[3]))
else:
agi.verbose("PYTHON AGI SCRIPT: CALLER ID NOT IN DB -> NOT REROUTING CALLER ID -> " +str(agi.env['agi_callerid']))
agi.verbose("PYTHON AGI SCRIPT: ENDED")