-
Notifications
You must be signed in to change notification settings - Fork 4
/
messages.py
38 lines (30 loc) · 1003 Bytes
/
messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Tasks for sending sms messages for Twilio
found in the docs from.
https://www.twilio.com/docs/quickstart/python/sms
"""
import os
from twilio.rest import Client
from threading import Thread
account_sid = os.environ.get("SID")
auth_token = os.environ.get("AUTH_TOKEN")
def send_sms(message=None, phone=os.environ.get("PHONE")):
"""Send messages to Users.
Args:
message (str): Message to be send to user
phone (str): Phone number to send to
"""
client = Client(account_sid, auth_token)
message = client.messages.create(
to=phone,
from_=os.environ.get("NUMBER"),
body="Hello from Ready For It!")
print(message.sid)
def send_async_sms(message=None, phone=None):
"""Sends messages asynchronously for now using Threads
Args:
message (str): Message to be sent to user
phone (str): Phone numberto send to
"""
thr = Thread(target=send_sms, args=())
thr.start()
return thr