diff --git a/callattendant/app.cfg.example b/callattendant/app.cfg.example index 05ac58b..64ab3f1 100644 --- a/callattendant/app.cfg.example +++ b/callattendant/app.cfg.example @@ -74,6 +74,14 @@ BLOCK_NAME_PATTERNS = {"V[0-9]{15}": "Telemarketer Caller ID", } # Example: {"P": "Private number", "O": "Out of area",} BLOCK_NUMBER_PATTERNS = {} +# BLOCK_SERVICE: The name of the online service used to lookup robocallers and spam numbers. +# Currently, only NOMOROBO is supported and it is for the USA. Areas outside the USA should set +# to blank. When the online service is blank (disabled), only the blacklist and blocked +# name/number patterns are used to block numbers. +# +# Example: "NOMOROBO" (USA) or "" (disabled). +BLOCK_SERVICE = "NOMOROBO" + # BLOCKED_ACTIONS: A tuple containing a combination of the following actions: # "greeting", "record_message", "voice_mail". diff --git a/callattendant/app.py b/callattendant/app.py index 034bece..bb3f6e2 100755 --- a/callattendant/app.py +++ b/callattendant/app.py @@ -26,6 +26,7 @@ import sys import queue import sqlite3 +import time from pprint import pprint from shutil import copyfile @@ -115,6 +116,10 @@ def process_calls(self): # Instruct the modem to start feeding calls into the caller queue self.modem.handle_calls(self.handle_caller) + # If testing, allow queue to be filled before processing for clean, readable logs + if self.config["TESTING"]: + time.sleep(1) + # Process incoming calls while 1: try: diff --git a/callattendant/config.py b/callattendant/config.py index 902fa5f..378dbf9 100644 --- a/callattendant/config.py +++ b/callattendant/config.py @@ -32,6 +32,7 @@ "PHONE_DISPLAY_FORMAT": "###-###-####", "BLOCK_ENABLED": True, + "BLOCK_SERVICE": "NOMOROBO", "BLOCK_NAME_PATTERNS": {"V[0-9]{15}": "Telemarketer Caller ID", }, "BLOCK_NUMBER_PATTERNS": {}, diff --git a/callattendant/screening/callscreener.py b/callattendant/screening/callscreener.py index f81d444..4898f02 100644 --- a/callattendant/screening/callscreener.py +++ b/callattendant/screening/callscreener.py @@ -62,14 +62,15 @@ def is_blacklisted(self, callerid): reason = block["number_patterns"][key] print(reason) return True, reason - print(">> Checking nomorobo...") - result = self._nomorobo.lookup_number(number) - if result["spam"]: - reason = "{} with score {}".format(result["reason"], result["score"]) - if self.config["DEBUG"]: - print(">>> {}".format(reason)) - self.blacklist_caller(callerid, reason) - return True, reason + if block["service"].upper() == "NOMOROBO": + print(">> Checking nomorobo...") + result = self._nomorobo.lookup_number(number) + if result["spam"]: + reason = "{} with score {}".format(result["reason"], result["score"]) + if self.config["DEBUG"]: + print(">>> {}".format(reason)) + self.blacklist_caller(callerid, reason) + return True, reason print("Caller has been screened") return False, "Not found" finally: