A package for managing Iranian SMS services
Project description
Iranian SMS Manager
A Python package for managing Iranian SMS services, providing support for multiple SMS providers and a modular, extensible design.
Requirements
- Python 3.11+
- requests
Installation
You can install this package directly from GitHub:
pip install git+https://github.com/AAbbasRR/persianSMSManager.git
Alternatively, clone the repository and install manually:
git clone https://github.com/AAbbasRR/persianSMSManager.git
cd persianSMSManager
pip install .
or
pip install persian_sms_manager
Usage
This package allows you to send SMS messages, including OTP (One-Time Password) codes, through various SMS services. Currently, it supports RayganSMS and AnotherSMSService.
Configuration
You need to configure the SMS service you want to use. Here is an example for RayganSMS and AnotherSMSService.
Example with RayganSMS:
from persian_sms_manager import SMSManager
# Configure RayganSMS
sms_manager = SMSManager(
service_name="raygansms",
user_mobile="09123456789",
username="your_username",
password="your_password"
)
# Send a message
sms_manager.service.send_message("This is a test message")
# Send OTP code
sms_manager.service.send_otp_code("register")
# Send automatic OTP code
sms_manager.service.send_auto_otp_code()
# Check automatic OTP code
valid = sms_manager.service.check_auto_otp_code("123456")
Adding New SMS Services
To add support for a new SMS service, create a new class in the package that inherits from BaseSMSService and implements the required methods. Then, update the SMSManager class to include this new service.
Example
Create a file new_sms_service.py:
from persian_sms_manager.base import BaseSMSService
import requests
class NewSMSService(BaseSMSService):
def __init__(self, user_mobile, api_key):
super().__init__(user_mobile)
self.api_key = api_key
def send_request(self, endpoint, data):
data.update({
"api_key": self.api_key,
})
response = requests.post(f"https://new-sms-service.com/{endpoint}", data=data)
return response.status_code == 200
def send_message(self, message):
data = {
"mobile": self.user_mobile,
"message": message,
}
return self.send_request("send_message", data)
def send_otp_code(self, title_type):
otp_code = "12345"
message = f"your otp: {otp_code}."
return self.send_message(message)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
Author
Abbas Rahimzadeh - arahimzadeh79@gmail.com
Acknowledgments
Special thanks to the open-source community for their valuable contributions and resources.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file persian_sms_manager-1.1.3.tar.gz
.
File metadata
- Download URL: persian_sms_manager-1.1.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92a07b0c520cce2ae44fde7e18afb6045202f87a94efecd14ecabb99eeb109c2 |
|
MD5 | 91979aeb92f314b8a061bda3bac716b3 |
|
BLAKE2b-256 | 560f3a4855504822df9decf708feb704e1325aff7fb161b7982538437deb4c23 |
File details
Details for the file persian_sms_manager-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: persian_sms_manager-1.1.3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67d4f710cba63f0a8fd8d49f54e7dc027a5ae4f4bf3b9cd6fa0b9a903281f3c6 |
|
MD5 | 4d5ddc9c34b15b20e97deed5d4e5ab2c |
|
BLAKE2b-256 | 962ca4f197f5743805bd28e4fa922806c2b493e669be27cf39874f2847222483 |