Skip to main content

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

persian_sms_manager-2.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

persian_sms_manager-2.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file persian_sms_manager-2.1.1.tar.gz.

File metadata

  • Download URL: persian_sms_manager-2.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for persian_sms_manager-2.1.1.tar.gz
Algorithm Hash digest
SHA256 4f668aa2fe0a85a0361f08563e0022706472ea758e1c62d8d9e603aafb50aa35
MD5 3ad77f4e6738f1cf98e985f2bd3ef9d6
BLAKE2b-256 0f5e901d90cda48aceab8daa0b1a0c295f1814b08302c7675604165b915b8c3e

See more details on using hashes here.

File details

Details for the file persian_sms_manager-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for persian_sms_manager-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd58e83ecac184badf8eedfb3f54a1c09aaef50371e77a0cc37dcb33c38382c7
MD5 a7cfce2e0c8940e3df5618083a019515
BLAKE2b-256 e3cc39fcece1858a1da187a9e46c12938eebd4b4de46791403f6c98e57f521f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page