1
0

add fieldpoc dect claim script

This commit is contained in:
Ember 'n0emis' Keske
2022-07-21 00:55:10 +02:00
parent 9795ed55b8
commit 03957afd7e
7 changed files with 49 additions and 5 deletions

30
hosts/yate/dect_claim.py Normal file
View 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)

View File

@@ -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

Binary file not shown.