SHARE
TWEET

Untitled

a guest Jun 15th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top