add fieldpoc dect claim script
This commit is contained in:
30
hosts/yate/dect_claim.py
Normal file
30
hosts/yate/dect_claim.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import asyncio
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
|
||||
from yate.ivr import YateIVR
|
||||
|
||||
SOUNDS_PATH = "/run/current-system/sw/share/sounds/yate"
|
||||
|
||||
|
||||
async def main(ivr: YateIVR):
|
||||
caller_id = ivr.call_params.get("caller", "")
|
||||
caller_id = re.sub("[^\\d]", "", caller_id)
|
||||
called_id = ivr.call_params.get("called", "")
|
||||
called_id = re.sub("[^\\d]", "", called_id)
|
||||
|
||||
await ivr.play_soundfile(
|
||||
os.path.join(SOUNDS_PATH, "yintro.slin"),
|
||||
complete=True)
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect(("localhost", 9437))
|
||||
s.recv(1024)
|
||||
s.sendall(f"claim {caller_id} {called_id}".encode('utf-8'))
|
||||
s.recv(1024)
|
||||
|
||||
|
||||
app = YateIVR()
|
||||
app.run(main)
|
@@ -42,4 +42,12 @@
|
||||
[dialin]
|
||||
\${sip_x-called}^.*$=lateroute/\\1";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
(writers.makePythonWriter python39 python39.pkgs "/bin/dect_claim" { libraries = [ python39.pkgs.python-yate ]; } (builtins.readFile ./dect_claim.py))
|
||||
(runCommand "yintro.slin" {} ''
|
||||
mkdir -p $out/share/sounds/yate
|
||||
ln -s ${./yintro.slin} $out/share/sounds/yate/yintro.slin
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
BIN
hosts/yate/yintro.slin
Normal file
BIN
hosts/yate/yintro.slin
Normal file
Binary file not shown.
Reference in New Issue
Block a user