mirror of https://github.com/sipwise/sems.git
git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@2 8eb893ce-cfd4-0310-b710-fb5ebe64c474sayer/1.4-spce2.6
parent
a2a334f12d
commit
41328e1028
Binary file not shown.
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# path for wav files
|
||||
wav_path = "/home/ilk/answer_machine/wav/ivr/"
|
||||
# path for received messages
|
||||
messages_path = "/tmp/ivr/"
|
||||
x=100
|
||||
|
||||
|
||||
import os
|
||||
import ivr
|
||||
import re
|
||||
print "Python: Try to redirect"
|
||||
ret = ivr.redirect("<sip:ivr@195.37.78.148>")
|
||||
if ret :
|
||||
print "Python: Redirected"
|
||||
else:
|
||||
print "Python: Not redirected"
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -1,68 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# path for wav files
|
||||
wav_path = "/home/ilk/answer_machine/wav/ivr/"
|
||||
# path for received messages
|
||||
messages_path = "/tmp/ivr/"
|
||||
x=100
|
||||
|
||||
|
||||
import os
|
||||
import ivr
|
||||
import re
|
||||
|
||||
# function returns name from URI
|
||||
def get_name(str):
|
||||
user_expr_ext = re.compile('<sip:[\w&=+$,;?/-_.!~*()\']+@')
|
||||
user_expr = re.compile(':[\w&=+$,;?/-_.!~*()\']+[^@]')
|
||||
m = user_expr_ext.search(str)
|
||||
if m:
|
||||
user_temp = user_expr.search(m.group())
|
||||
user = re.search('[^:].+',user_temp.group())
|
||||
if user:
|
||||
return user.group()
|
||||
|
||||
print "IVR"
|
||||
|
||||
caller = get_name(ivr.getFrom())
|
||||
callee = get_name(ivr.getTo())
|
||||
|
||||
print "Caller:", caller
|
||||
print "Callee:", callee
|
||||
|
||||
# if user is owner of mailbox
|
||||
# user can listed, delete or choose next message
|
||||
if caller == callee:
|
||||
if os.path.isdir(messages_path + callee):
|
||||
for files in os.listdir(messages_path + callee):
|
||||
while x > 0:
|
||||
if x > 3:
|
||||
x=ivr.playAndDetect(wav_path + "ivr_instruction.wav",60000)
|
||||
if x == 1:
|
||||
# listen message
|
||||
ivr.play(messages_path + callee + "/" + files)
|
||||
x=100
|
||||
if x == 2:
|
||||
# delete message
|
||||
os.remove(messages_path + callee + "/" + files)
|
||||
x=1
|
||||
ivr.play(wav_path + "ivr_next_message.wav")
|
||||
break
|
||||
if x == 3:
|
||||
# listen next message
|
||||
x=1
|
||||
ivr.play(wav_path + "ivr_next_message.wav")
|
||||
break
|
||||
# no new messages
|
||||
if x > 0:
|
||||
ivr.play(wav_path + "ivr_no_messages.wav")
|
||||
# if user is not user of mailbox
|
||||
# user can left message
|
||||
else :
|
||||
print "play invitation"
|
||||
ivr.play(wav_path + "ivr_invitation.wav")
|
||||
print "record message"
|
||||
if os.path.isdir(messages_path + callee) != True:
|
||||
os.mkdir(messages_path + callee)
|
||||
ivr.record(messages_path + callee + "/" + callee + str(ivr.getTime()) + ".wav", 60)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# path for wav files
|
||||
wav_path = "/home/ilk/answer_machine/wav/ivr/"
|
||||
# path for received messages
|
||||
messages_path = "/tmp/ivr/"
|
||||
x=100
|
||||
ret=0
|
||||
|
||||
|
||||
import os
|
||||
import ivr
|
||||
import re
|
||||
x=ivr.playAndDetect(wav_path + "ivr_redirect.wav",60000)
|
||||
print "Python: Try to redirect"
|
||||
if x == 1:
|
||||
ret = ivr.redirect("<sip:ivr@195.37.78.148>")
|
||||
if x == 2:
|
||||
ret = ivr.redirect("<sip:horoscope_date@195.37.78.148>")
|
||||
if ret :
|
||||
print "Python: Redirected"
|
||||
else:
|
||||
print "Python: Not redirected"
|
||||
Binary file not shown.
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
wav_path = "/home/ilk/answer_machine/wav/horoscope/"
|
||||
m=100
|
||||
date=0
|
||||
|
||||
import os
|
||||
import ivr
|
||||
print "Try horoscope "
|
||||
m = ivr.playAndDetect(wav_path + "enter_month.wav",60000)
|
||||
if m >= 0:
|
||||
if m == 1 :
|
||||
m2 = ivr.detect(6000)
|
||||
if m2 >= 0 and m2 < 3:
|
||||
date = 1000 + m2 * 100
|
||||
else :
|
||||
date = m * 100
|
||||
else :
|
||||
if m == 0 :
|
||||
m2 = ivr.detect(6000)
|
||||
date = m2 * 100
|
||||
else :
|
||||
date = m * 100
|
||||
d = ivr.playAndDetect(wav_path + "enter_date.wav",60000)
|
||||
if d >= 0 and d < 4:
|
||||
d2 = ivr.detect(6000)
|
||||
if d2 >= 0:
|
||||
date += d * 10 + d2
|
||||
else :
|
||||
date += d
|
||||
else :
|
||||
date += d
|
||||
if 121 <= date <= 131 or 201 <= date <= 219 :
|
||||
ivr.play(wav_path + "hor_1.wav")
|
||||
if 220 <= date <= 231 or 301 <= date <= 319 :
|
||||
ivr.play(wav_path + "hor_2.wav")
|
||||
if 320 <= date <= 331 or 401 <= date <= 418 :
|
||||
ivr.play(wav_path + "hor_3.wav")
|
||||
if 419 <= date <= 431 or 501 <= date <= 519 :
|
||||
ivr.play(wav_path + "hor_4.wav")
|
||||
if 520 <= date <= 531 or 601 <= date <= 620 :
|
||||
ivr.play(wav_path + "hor_5.wav")
|
||||
if 621 <= date <= 631 or 701 <= date <= 721 :
|
||||
ivr.play(wav_path + "hor_6.wav")
|
||||
if 722 <= date <= 731 or 801 <= date <= 822 :
|
||||
ivr.play(wav_path + "hor_7.wav")
|
||||
if 823 <= date <= 831 or 901 <= date <= 922 :
|
||||
ivr.play(wav_path + "hor_8.wav")
|
||||
if 923 <= date <= 931 or 1001 <= date <= 1022 :
|
||||
ivr.play(wav_path + "hor_9.wav")
|
||||
if 1023 <= date <= 1031 or 1101 <= date <= 1121 :
|
||||
ivr.play(wav_path + "hor_10.wav")
|
||||
if 1122 <= date <= 1131 or 1201 <= date <= 1220 :
|
||||
ivr.play(wav_path + "hor_11.wav")
|
||||
if 1221 <= date <= 1231 or 101 <= date <= 120 :
|
||||
ivr.play(wav_path + "hor_12.wav")
|
||||
Binary file not shown.
@ -1,91 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
# DTMF testing script for sems ivr (perl version)
|
||||
# The purpose of this is to illustrate how to write a perl script for sems ivr module
|
||||
# It plays back the keys user enters and can be used for DTMF detection testing.
|
||||
my @keys=();
|
||||
use Sys::Syslog qw(:DEFAULT setlogsock);
|
||||
|
||||
syslog('info', 'this is the beginning');
|
||||
my $wav_path = '/usr/local/lib/sems/audio/';
|
||||
|
||||
# enable DTMF detection, it is disabled by default
|
||||
ivr::enableDTMFDetection();
|
||||
|
||||
# setup callback functions
|
||||
# It is important to setup the OnBYE callback. This gives the script a chance to exit
|
||||
# gracefully. This allows files to be close, database updated, state synchronized.
|
||||
# Otherwise the script is killed by the sems ivr module abruptly.
|
||||
syslog('info', 'setting DTMF callback: '. ivr::setCallback('func_on_DTMF', 'onDTMF') );
|
||||
syslog('info', 'setting BYE callback: '. ivr::setCallback('func_on_BYE', 'onBYE') );
|
||||
|
||||
# play initial greeting
|
||||
syslog('info', 'filling media '. ivr::enqueueMediaFile($wav_path . 'thanks_calling_number_reader.wav', 0));
|
||||
|
||||
# save the user input to a wav file, use called user and domain as part of file name
|
||||
# username part is retrived via ivr::getUser()
|
||||
# domain is retrieved via ivr::getDomain()
|
||||
ivr::startRecording('/tmp/record-(' . ivr::getUser(). '@'. ivr::getDomain(). ')-'. ivr::getTime(). '.wav');
|
||||
|
||||
# if not key input for 3 cycles, then exit. Each cycle is 5 seconds (or 5000 msec)
|
||||
# It is important for the script to exist by itself. For example, it the caller UA crashes,
|
||||
# it won't be able to send BYE, this instance of the script is going to be a orphan.
|
||||
# This can easily to be a victim of DOS attack.
|
||||
my $exit_flag=3;
|
||||
|
||||
# main loop
|
||||
while($exit_flag>=0) {
|
||||
|
||||
# sleep 5000 msec, there are other functions of seconds and useconds
|
||||
# it either sleeps for 5000 msec or interrupted by ivr::wakeUp();
|
||||
$sleep_time = ivr::msleep(5000);
|
||||
syslog('info', 'wake up after sleep '. $sleep_time . ' msec.\n');
|
||||
|
||||
# user input key is saved in @keys array
|
||||
my $key = shift (@keys);
|
||||
|
||||
# check if there is any key
|
||||
if (defined($key)) {
|
||||
syslog('info', 'A new key '. $key . " is pressed after $sleep_time msec");
|
||||
|
||||
# play the key wav file
|
||||
ivr::enqueueMediaFile("$wav_path" . $key . '.wav', 0);
|
||||
|
||||
# we get a key, restart timer
|
||||
$exit_flag=3;
|
||||
|
||||
} else {
|
||||
# no key input, decrease exit counter
|
||||
$exit_flag--;
|
||||
}
|
||||
}
|
||||
|
||||
# stop recording
|
||||
ivr::stopRecording();
|
||||
|
||||
#syslog('info', 'processed in ' .ivr::yield() . 'usec');
|
||||
|
||||
syslog('info', 'this is the end');
|
||||
|
||||
# reset the callback function, recommended, avoid callback function called after script is over
|
||||
syslog('info', 'setting DTMF callback: '. ivr::setCallback('', 'onDTMF') );
|
||||
syslog('info', 'setting BYE callback: '. ivr::setCallback('', 'onBYE') );
|
||||
|
||||
|
||||
# DTMF callback function, called when there is any key input
|
||||
sub func_on_DTMF {
|
||||
# save the key to @keys
|
||||
push @keys, @_;
|
||||
syslog('info', "callback says: a key @_ is entered");
|
||||
# wakeup main script sleep function
|
||||
ivr::wakeUp();
|
||||
}
|
||||
|
||||
# BYE callback function, called when caller hangs up
|
||||
sub func_on_BYE {
|
||||
syslog('info', 'callback says: a bye in detected');
|
||||
# set flag for main loop
|
||||
$exit_flag=0;
|
||||
# wakeup main script sleep function
|
||||
ivr::wakeUp();
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
wav_path = "/home/ilk/answer_machine/wav/horoscope/"
|
||||
x=100
|
||||
|
||||
import os
|
||||
import ivr
|
||||
print "Try horoscope "
|
||||
x=ivr.playAndDetect(wav_path + "hor_invitation.wav",60000)
|
||||
if x == 0:
|
||||
ivr.play(wav_path + "hor_1.wav")
|
||||
if x == 1:
|
||||
ivr.play(wav_path + "hor_2.wav")
|
||||
if x == 2:
|
||||
ivr.play(wav_path + "hor_3.wav")
|
||||
if x == 3:
|
||||
ivr.play(wav_path + "hor_4.wav")
|
||||
if x == 4:
|
||||
ivr.play(wav_path + "hor_5.wav")
|
||||
if x == 5:
|
||||
ivr.play(wav_path + "hor_6.wav")
|
||||
if x == 6:
|
||||
ivr.play(wav_path + "hor_7.wav")
|
||||
if x == 7:
|
||||
ivr.play(wav_path + "hor_8.wav")
|
||||
if x == 8:
|
||||
ivr.play(wav_path + "hor_9.wav")
|
||||
if x == 9:
|
||||
ivr.play(wav_path + "hor_10.wav")
|
||||
if x == 10:
|
||||
ivr.play(wav_path + "hor_11.wav")
|
||||
if x == 11:
|
||||
ivr.play(wav_path + "hor_12.wav")
|
||||
Binary file not shown.
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
wav_path = "/home/ilk/answer_machine/wav/horoscope/"
|
||||
m=100
|
||||
date=0
|
||||
|
||||
import os
|
||||
import ivr
|
||||
print "Try horoscope "
|
||||
m = ivr.playAndDetect(wav_path + "enter_month.wav",60000)
|
||||
if m >= 0:
|
||||
if m == 1 :
|
||||
m2 = ivr.detect(6000)
|
||||
if m2 >= 0 and m2 < 3:
|
||||
date = 1000 + m2 * 100
|
||||
else :
|
||||
date = m * 100
|
||||
else :
|
||||
if m == 0 :
|
||||
m2 = ivr.detect(6000)
|
||||
date = m2 * 100
|
||||
else :
|
||||
date = m * 100
|
||||
d = ivr.playAndDetect(wav_path + "enter_date.wav",60000)
|
||||
if d >= 0 and d < 4:
|
||||
d2 = ivr.detect(6000)
|
||||
if d2 >= 0:
|
||||
date += d * 10 + d2
|
||||
else :
|
||||
date += d
|
||||
else :
|
||||
date += d
|
||||
if 121 <= date <= 131 or 201 <= date <= 219 :
|
||||
ivr.play(wav_path + "hor_1.wav")
|
||||
if 220 <= date <= 231 or 301 <= date <= 319 :
|
||||
ivr.play(wav_path + "hor_2.wav")
|
||||
if 320 <= date <= 331 or 401 <= date <= 418 :
|
||||
ivr.play(wav_path + "hor_3.wav")
|
||||
if 419 <= date <= 431 or 501 <= date <= 519 :
|
||||
ivr.play(wav_path + "hor_4.wav")
|
||||
if 520 <= date <= 531 or 601 <= date <= 620 :
|
||||
ivr.play(wav_path + "hor_5.wav")
|
||||
if 621 <= date <= 631 or 701 <= date <= 721 :
|
||||
ivr.play(wav_path + "hor_6.wav")
|
||||
if 722 <= date <= 731 or 801 <= date <= 822 :
|
||||
ivr.play(wav_path + "hor_7.wav")
|
||||
if 823 <= date <= 831 or 901 <= date <= 922 :
|
||||
ivr.play(wav_path + "hor_8.wav")
|
||||
if 923 <= date <= 931 or 1001 <= date <= 1022 :
|
||||
ivr.play(wav_path + "hor_9.wav")
|
||||
if 1023 <= date <= 1031 or 1101 <= date <= 1121 :
|
||||
ivr.play(wav_path + "hor_10.wav")
|
||||
if 1122 <= date <= 1131 or 1201 <= date <= 1220 :
|
||||
ivr.play(wav_path + "hor_11.wav")
|
||||
if 1221 <= date <= 1231 or 101 <= date <= 120 :
|
||||
ivr.play(wav_path + "hor_12.wav")
|
||||
Binary file not shown.
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# path for wav files
|
||||
wav_path = "/home/rco/src/cvs/sems/new_audio/wav/ivr/"
|
||||
# path for received messages
|
||||
messages_path = "/tmp/ivr/"
|
||||
x=100
|
||||
|
||||
|
||||
import os
|
||||
import ivr
|
||||
import re
|
||||
|
||||
# function returns name from URI
|
||||
def get_name(str):
|
||||
user_expr_ext = re.compile('<sip:[\w&=+$,;?/-_.!~*()\']+@')
|
||||
user_expr = re.compile(':[\w&=+$,;?/-_.!~*()\']+[^@]')
|
||||
m = user_expr_ext.search(str)
|
||||
if m:
|
||||
user_temp = user_expr.search(m.group())
|
||||
user = re.search('[^:].+',user_temp.group())
|
||||
if user:
|
||||
return user.group()
|
||||
|
||||
print "IVR"
|
||||
|
||||
caller = get_name(ivr.getFrom())
|
||||
callee = get_name(ivr.getTo())
|
||||
|
||||
print "Caller:", caller
|
||||
print "Callee:", callee
|
||||
|
||||
print "play invitation"
|
||||
ivr.play(wav_path + "ivr_invitation.wav")
|
||||
print "record message"
|
||||
if os.path.isdir(messages_path + callee) != True:
|
||||
os.mkdir(messages_path + callee)
|
||||
ivr.record(messages_path + callee + "/" + callee + str(ivr.getTime()) + ".wav", 60)
|
||||
|
||||
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# path for wav files
|
||||
wav_path = "/home/ilk/answer_machine/wav/ivr/"
|
||||
# path for received messages
|
||||
messages_path = "/tmp/ivr/"
|
||||
x=100
|
||||
|
||||
|
||||
import os
|
||||
import ivr
|
||||
import re
|
||||
|
||||
print "Python: Try to redirect"
|
||||
ret = ivr.redirect("<sip:ivr@195.37.78.174>")
|
||||
if ret :
|
||||
print "Python: Redirected"
|
||||
else:
|
||||
print "Python: Not redirected"
|
||||
Binary file not shown.
@ -1,121 +0,0 @@
|
||||
#
|
||||
# $Id: ser_for_ivr.cfg,v 1.1.8.1 2005/09/02 13:47:47 rco Exp $
|
||||
#
|
||||
# this script is configured for use as voicemail UAS; it processes
|
||||
# INVITEs and BYEs and asks SEMS to record media via "vm"; in this
|
||||
# script, all record-routing and other constructs known from proxy
|
||||
# scripts are not present -- it is a simple UAS
|
||||
#
|
||||
|
||||
# ----------- global configuration parameters ------------------------
|
||||
|
||||
debug=9 # debug level (cmd line: -dddddddddd)
|
||||
#fork=yes
|
||||
log_stderror=yes # (cmd line: -E)
|
||||
|
||||
|
||||
check_via=no # (cmd. line: -v)
|
||||
dns=no # (cmd. line: -r)
|
||||
rev_dns=no # (cmd. line: -R)
|
||||
port=5060
|
||||
children=4
|
||||
fifo="/tmp/ser_fifo"
|
||||
listen=195.37.78.184
|
||||
|
||||
# ------------------ module loading ----------------------------------
|
||||
|
||||
loadmodule "modules/sl/sl.so"
|
||||
loadmodule "modules/tm/tm.so"
|
||||
loadmodule "modules/rr/rr.so"
|
||||
loadmodule "modules/maxfwd/maxfwd.so"
|
||||
loadmodule "modules/usrloc/usrloc.so"
|
||||
loadmodule "modules/registrar/registrar.so"
|
||||
loadmodule "modules/vm/vm.so"
|
||||
loadmodule "modules/dbtext/dbtext.so"
|
||||
|
||||
|
||||
# ----------------- setting module-specific parameters ---------------
|
||||
|
||||
# You may want to define things like databases here. Please refer to
|
||||
# the extensive SER documentation for this purpose. Module parameters
|
||||
# are always described in the modules README files.
|
||||
#
|
||||
# For pure ivr functionality only a database is needed, we use
|
||||
# a simple textfile for this purpose. Actually this is only neccessary until
|
||||
# the vm module is reworked. Simply copy the etc/db directory from the ivr
|
||||
# directory somewhere and specify it in the following statement:
|
||||
|
||||
modparam("voicemail", "db_url","/home/ilk/sip_router/modules/vm/db")
|
||||
|
||||
# ------------------------- request routing logic -------------------
|
||||
|
||||
# main routing logic
|
||||
|
||||
route{
|
||||
|
||||
|
||||
# initial sanity checks -- messages with
|
||||
# max_forwars==0, or excessively long requests
|
||||
if (!mf_process_maxfwd_header("10")) {
|
||||
sl_send_reply("483","Too Many Hops");
|
||||
break;
|
||||
};
|
||||
if (msg:len >= max_len ) {
|
||||
sl_send_reply("513", "Message too big");
|
||||
break;
|
||||
};
|
||||
|
||||
if (!uri==myself) {
|
||||
sl_send_reply("404", "not reponsible for host in r-uri");
|
||||
break;
|
||||
};
|
||||
|
||||
if (method=="REGISTER") {
|
||||
|
||||
# Uncomment this if you want to use digest authentication
|
||||
# if (!www_authorize("iptel.org", "subscriber")) {
|
||||
# www_challenge("iptel.org", "0");
|
||||
# break;
|
||||
# };
|
||||
|
||||
save("location");
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
# ivr specific configuration - begin
|
||||
|
||||
if(method=="ACK" || method=="INVITE" || method=="BYE"){
|
||||
|
||||
if (!t_newtran()) {
|
||||
log("could not create new transaction\n");
|
||||
sl_send_reply("500","could not create new transaction");
|
||||
break;
|
||||
};
|
||||
|
||||
t_reply("100","Trying -- just wait a minute !");
|
||||
if(method=="INVITE"){
|
||||
log("**************** vm start - begin ******************\n");
|
||||
if (uri=~"sip:ivr@.*") {
|
||||
if (!vm("/tmp/am_fifo", "ivr")) {
|
||||
log("couldn't contact ivr server\n");
|
||||
t_reply("500", "couldn not contact ivr server");
|
||||
};
|
||||
};
|
||||
log("**************** vm start - end ******************\n");
|
||||
} else if(method=="BYE"){
|
||||
log("**************** vm end - begin ******************\n");
|
||||
if(!vm("/tmp/am_fifo","bye")){
|
||||
log("could not contact ivr\n");
|
||||
t_reply("500","could not contact ivr");
|
||||
};
|
||||
log("**************** vm end - end ******************\n");
|
||||
};
|
||||
break;
|
||||
};
|
||||
if (method=="CANCEL") {
|
||||
sl_send_reply("200", "cancels are junked here");
|
||||
break;
|
||||
};
|
||||
sl_send_reply("501", "method not understood here");
|
||||
}
|
||||
Loading…
Reference in new issue