Created
October 24, 2017 02:05
-
-
Save grizmio/701e9884c09e104427799ec52d14c747 to your computer and use it in GitHub Desktop.
a function for python2.7 agi using pyst2, it dials an extension with pjsip and get the result status. Useful in a simple ivr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python2.7 | |
# python2.7 agi using pyst2 | |
# A function to dial an extension with pjsip and get the result status | |
from asterisk.agi import * # pyst2 | |
def dial_pjsip(anexo=''): | |
""" | |
returns: | |
# CHANUNAVAIL | |
# CONGESTION | |
# NOANSWER | |
# BUSY | |
# ANSWER -> Exito! | |
# CANCEL | |
# DONTCALL - For the Privacy and Screening Modes. Will be set if the called party chooses to send the calling party to the 'Go Away' # script. | |
# TORTURE - For the Privacy and Screening Modes. Will be set if the called party chooses to send the calling party to the 'torture' # script. | |
# INVALIDARGS | |
""" | |
pjsip_dial_arg_str = agi.get_full_variable('${PJSIP_DIAL_CONTACTS(%s)}' % anexo) | |
pjsip_dial_arg_str += ',,g' # para que no muera, continue | |
d_status = agi.appexec('Dial', pjsip_dial_arg_str) | |
dial_status = agi.get_variable('DIALSTATUS') | |
status = True if dial_status == 'ANSWER' else False | |
return status, dial_status | |
dial_pjsip('1001') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment