Skip to content

Commit

Permalink
Add WhatsApp argument
Browse files Browse the repository at this point in the history
Adds the WhatsApp argument for including WhatsApp numbers as well.
  • Loading branch information
Sliicy committed Aug 2, 2020
1 parent 4426a81 commit 8814eb5
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions eruv_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def army_to_meridian(input_time):
'--donate',
action='store_true',
help='Append a reminder to donate for select cities.')
parser.add_argument(
'--include-whatsapp',
action='store_true',
help='Send SMS messages to WhatsApp numbers as well. These numbers normally do not receive SMS alerts.')
parser.add_argument(
'--no-candlelighting',
action='store_true',
Expand Down Expand Up @@ -234,6 +238,7 @@ def army_to_meridian(input_time):
# Phone Number, City, Rabbi's City, Zip Code):
all_numbers = subscriber_sheet.col_values(2)[1:]
all_user_cities = subscriber_sheet.col_values(3)[1:]
whatsapp_list = subscriber_sheet.col_values(4)[1:]
all_rabbi_cities = rabbi_sheet.col_values(3)[1:]
all_rabbi_zipcodes = rabbi_sheet.col_values(4)[1:]
all_cities = status_sheet.col_values(1)
Expand Down Expand Up @@ -391,6 +396,13 @@ def army_to_meridian(input_time):
for city_item in [x.strip() for x in city_found.split(',')]:
if city == city_item:

# Skip if WhatsApp user, unless requested:
if whatsapp_list[user_index].lower() == 'whatsapp':
if arguments.include_whatsapp:
print('\nSending SMS to a WhatsApp number!\n')
else:
continue

# Final message:
message = parsha + prequel + city + ' Eruv is ' + city_statuses[city_index] + sequel + '. ' + candle_lighting + havdalah + (
'Have ' + random.choice(greetings) + ' Shabbos' + holiday + '!' if sequel == '' else '')
Expand Down Expand Up @@ -430,22 +442,14 @@ def army_to_meridian(input_time):

# Keep track of total # of users:
population += 1

# Keep track of current index of user:
user_index += 1

if arguments.custom_message:
print('\n' +
str(population) +
' users ' +
('would have been ' if arguments.test else '') +
'notified: ' +
message + '.\n')
else:
print('\n' +
str(population) +
' users ' +
('would have been ' if arguments.test else '') +
'notified that ' +
city +
' is ' +
city_statuses[city_index] + '.\n')
print('\n' +
str(population) +
' users ' +
('would have been ' if arguments.test else '') +
'notified' +
(': "' + message + '"' if arguments.custom_message else ' that ' + city + ' is ' + city_statuses[city_index] + '.') + '\n')
city_index += 1

0 comments on commit 8814eb5

Please sign in to comment.