From 522583f876dfe1ebd978f0959e6a9d330604ee2d Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Sun, 15 Dec 2024 21:09:58 +0330 Subject: [PATCH] sms bullshit --- backend/.env.local | 4 +++- backend/requirements.txt | 1 + backend/utils/sms.py | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 backend/utils/sms.py diff --git a/backend/.env.local b/backend/.env.local index 9f8c9e3..9e28739 100644 --- a/backend/.env.local +++ b/backend/.env.local @@ -24,4 +24,6 @@ SITE_TITLE = '' SITE_HEADER = '' # jwt token configs ACCESS_TOKEN_LIFETIME = 5000 -REFRESH_TOKEN_LIFETIME = 5000 \ No newline at end of file +REFRESH_TOKEN_LIFETIME = 5000 + +SMS_API_KEY = '' \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt index 53c4c54..de429bc 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -26,6 +26,7 @@ factory_boy==3.3.1 Faker==28.4.1 frozenlist==1.4.1 geoip2==4.8.0 +ghasedak_sms==1.0.3 gnupg==2.3.1 h11==0.14.0 httpagentparser==1.9.5 diff --git a/backend/utils/sms.py b/backend/utils/sms.py new file mode 100644 index 0000000..e0de4c8 --- /dev/null +++ b/backend/utils/sms.py @@ -0,0 +1,16 @@ +from dotenv import load_dotenv +import os +from ghasedak_sms import Ghasedak + +load_dotenv(".env.local") +sms_api = Ghasedak(api_key=os.getenv("SMS_API_KEY")) + +### ارسال پیامک تکی + # response = sms_api.send_single_sms(message=hello, world!, receptor='0935*****', linenumber='3000*****', senddate='', checkid='') + +### ارسال پیامک گروهی + # response = sms_api.send_bulk_sms(message='hello, world!', receptors=['09xxxxxxxxx', '09xxxxxxxxx'], linenumber='3000*****', senddate='', checkid='') + +### ارسال پیام otp + + #response = sms_api.send_otp_sms(receptor='09359****', message='OTP message') \ No newline at end of file