Skip to main content

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.

Release files for persian-sms-manager 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for persian-sms-manager 2.1.2
File Size Uploaded
persian_sms_manager-2.1.2.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for persian-sms-manager 2.1.2
File Interpreter ABI Platform
persian_sms_manager-2.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.7 kB

Release files / persian_sms_manager-2.1.2.tar.gz

Download URL persian_sms_manager-2.1.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
61e54bd654e450ffb9d1251629a7d650e19d054b85e26375252af0c19bbddd48
BLAKE2b-256 checksum
How to use checksums
1cc4d8d20ec0d13e8216cf40c2abfe9c4f030f1643f6ba3bde85ab586f1134d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / persian_sms_manager-2.1.2-py3-none-any.whl

Download URL persian_sms_manager-2.1.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b2acc7e393951dad63b104e3a37202c33002f9d7298b0d9087acfddf8609e4c
BLAKE2b-256 checksum
How to use checksums
5f1ed92e5d87cceb2d520ef513cde5192a4b42de618c215389c45651b6e66171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 release files

2.1.1

2 release files

2.0.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page