Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. def sms_subscription():
  2. contact_num = request.values.get('From')
  3. response = request.values.get('Body')
  4. resp = MessagingResponse()
  5.  
  6. #NEW SUBSCRIBERS
  7. if response.lower() == 'memphis':
  8. with open('Subscriber_List.csv', 'r+') as subscriber_list:
  9. subscriber_list_writer = csv.writer(subscriber_list)
  10. for contact in subscriber_list:
  11. if contact == contact_num:
  12. resp.message("Your already subscribed")
  13. return str(resp)
  14.  
  15. else:
  16. subscriber_list_writer.writerow([contact_num])
  17. resp.message("Thanks for subscribing to our local coupon book. As we get new deals, we'll notify via SMS. To opt-out reply 'STOP'")
  18. return str(resp)
  19.  
  20. else:
  21. resp.message("Be sure to check spelling and for spaces and try again.")
  22. return str(resp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement