diff --git a/callattendant/app.cfg.example b/callattendant/app.cfg.example index baad0b4..64ab3f1 100644 --- a/callattendant/app.cfg.example +++ b/callattendant/app.cfg.example @@ -24,6 +24,42 @@ TESTING = False # This should not be changed/overrriden except during development/testing #DATABASE = "callattendant.db" +# PHONE_DISPLAY_SEPARATOR: Specify the character used to format phone numbers, e.g, a space, hyphen or period, +PHONE_DISPLAY_SEPARATOR = "-" + +# PHONE_DISPLAY_FORMAT: Define the formatting of phone numbers in the various lists. You must use the +# separator character defined by PHONE_DISPLAY_SEPARATOR above in the format string. +# +# The phone display format handles variable length phone numbers. Excess digits not included +# in the format string are prepended to the number with a separator. +# For example, the AUS number 006173XXXYYYY would be formatted as follows: +# General format: 006173-XXX-YYYY +# AU format: 00-61-73-XXX-YYYY +# US format: 006-173-XXX-YYYY +# UK format: 00-6173-XXX-YYYY +# FR format: 0061-73X-XX-YY-YY +# +# Example: General +# PHONE_DISPLAY_FORMAT = "###-####" +# +# Example: US +# PHONE_DISPLAY_FORMAT = "###-###-####" +# +# Example: UK +# PHONE_DISPLAY_FORMAT = "####-###-####" +# +# Example: FR +# PHONE_DISPLAY_FORMAT = "###-##-##-##" +# +# Example: AU +# PHONE_DISPLAY_FORMAT = "##-##-###-####" +# +# Example: Raw - no formatting +# PHONE_DISPLAY_FORMAT = "" +# +PHONE_DISPLAY_FORMAT = "###-###-####" + + # SCREENING_MODE: A tuple containing: "whitelist" and/or "blacklist", or empty SCREENING_MODE = ("whitelist", "blacklist") @@ -38,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 392efa5..378dbf9 100644 --- a/callattendant/config.py +++ b/callattendant/config.py @@ -28,7 +28,11 @@ "DATABASE": "callattendant.db", "SCREENING_MODE": ("whitelist", "blacklist"), + "PHONE_DISPLAY_SEPARATOR": "-", + "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: diff --git a/callattendant/userinterface/templates/callers_blocked.html b/callattendant/userinterface/templates/callers_blocked.html index cbf4537..cafabb2 100644 --- a/callattendant/userinterface/templates/callers_blocked.html +++ b/callattendant/userinterface/templates/callers_blocked.html @@ -68,9 +68,8 @@