-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87f8dd9
commit bf023d5
Showing
4 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Send messages to the user. | ||
For now, only phone. Eventually, consider e-mail. | ||
""" | ||
from .utils import TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_PHONE_NUMBER | ||
from .logger import logger | ||
|
||
from twilio.rest import Client | ||
|
||
|
||
def sms(phone: str, link: str) -> None: | ||
""" | ||
Send a link to the user's phone number. | ||
""" | ||
try: | ||
client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) | ||
|
||
message_body = f"Here is the link to your BeReal Wrapped!\n{link}" | ||
message = client.messages.create(body=message_body, from_=TWILIO_PHONE_NUMBER, to=phone) | ||
|
||
logger.info("Sent message to %s: %s", phone, message.sid) | ||
except Exception as e: | ||
logger.error("Failed to send SMS: %s", e) | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters