Browse Source

fix: 添加白名单和去掉按键

余尚辉 4 months ago
parent
commit
fa243b8971
2 changed files with 16 additions and 2 deletions
  1. 15 1
      src/core/callcenter/esl/client.py
  2. 1 1
      src/core/voip/bot.py

+ 15 - 1
src/core/callcenter/esl/client.py

@@ -28,7 +28,7 @@ from src.core.callcenter.enumeration import CallCause, DeviceType, DelayActionEn
 from src.core.callcenter.esl.handler.default_esl_event_handler import DefaultEslEventHandler
 from src.core.datasource import SERVE_HOST
 from src.core.voip.constant import *
-
+from src.core.callcenter.dao import *
 
 class InboundClient:
 
@@ -479,10 +479,15 @@ class OutboundClient:
 
     def __init__(self, agent, logger):
         self.logger = logger
+        self.whitelist = self.load_whitelist()
         #threading.Thread(target=self.start, args=('0.0.0.0', 8084, agent, logger)).start()
         server_thread = threading.Thread(target=self.start, args=('0.0.0.0', 8084, agent, logger))
         server_thread.daemon = True  # 设置守护线程
         server_thread.start()
+    def load_whitelist(self):
+        phones = Whitelist.query.filter_by(del_flag=0).all()
+        phone_list = [phone.phone for phone in phones]
+        return phone_list
 
     class ESLRequestHandler(socketserver.BaseRequestHandler):
         def setup(self):
@@ -497,6 +502,15 @@ class OutboundClient:
                     # print(json.loads(info.serialize('json')))
                     event_name = info.getHeader("Event-Name")
                     device_id = info.getHeader("unique-id")
+                    # caller_number = info.getHeader("Caller-Caller-ID-Number")  # 获取来电号码
+
+                     # 检查白名单
+                    # if caller_number in self.server.whitelist:
+                    #     self.server.logger.info("Caller %s is in whitelist, directly transferring call.", caller_number)
+                    #     # 直接转接到指定用户
+                    #     print('come in whitelist')
+                    #     return
+                    
                     kwargs = json.loads(info.serialize('json'))
                     destination = self.server.agent.register(**kwargs)
                     self.server.logger.info("device_id=%s, destination=%s", device_id, destination)

+ 1 - 1
src/core/voip/bot.py

@@ -248,7 +248,7 @@ class MyCall(pj.Call):
             player_id = murmur3_32(self.cur_player_file)
             return self.player_complete_dict.get(player_id)
     def onDtmfDigit(self, prm):
-        if self.is_play_complete() and not self.txtLock:   # 判断是否播放完成 否则不记录用户说的内容
+        if not self.txtLock:   # 判断是否播放完成 否则不记录用户说的内容
             digit = prm.digit
             self.reset_wait_time()
             # 假设为超长类型按键 把用户输入的按键进行拼接 如果为# 则把用户输入所有按键放入队列并发送文本机器人