Browse Source

Update sms.py

Add Private / Public Mode
aprs-duplicate-filtering
Mike 2 years ago
committed by GitHub
parent
commit
0a32055d27
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      sms.py

+ 15
- 0
sms.py View File

@ -5,6 +5,12 @@ from twilio.rest import Client
app = Flask(__name__)
# Set this variable to enable/disable private mode
private_mode = False # Change this value as needed
# List of callsigns allowed to send messages if private_mode is TRUE. Accepts ALL SSIDs for a CALLSIGN listed.
allowed_callsigns = ['CALLSIGN0', 'CALLSIGN1', 'CALLSIGN2'] # Add more callsigns as needed
# Twilio credentials
TWILIO_ACCOUNT_SID = 'SID'
TWILIO_AUTH_TOKEN = 'TOKEN'
@ -158,6 +164,15 @@ def receive_aprs_messages():
# Remove the first 11 characters from the message to exclude the "Callsign :" prefix
verbose_message = message_text[11:].split('{')[0].strip()
# If private_mode is enabled, check against allowed_callsigns; otherwise, process normally
if private_mode:
# Use regular expression to match main callsign and accept all SSIDs
callsign_pattern = re.compile(r'^({})(-\d+)?$'.format('|'.join(map(re.escape, allowed_callsigns))))
if not callsign_pattern.match(from_callsign):
print("Unauthorized sender:", from_callsign)
send_ack_message(from_callsign, message_id) # Send ACK for unauthorized sender
continue # Skip processing messages from unauthorized senders
# Display verbose message content
print("From: {}".format(from_callsign))
print("Message: {}".format(verbose_message))


Loading…
Cancel
Save