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-1.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

persian_sms_manager-1.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: persian_sms_manager-1.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for persian_sms_manager-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e38eab4679a51385282cbdd1502f1416e257a22d0a362d4c13901e4ab25653ea
MD5 26295892753034c4d8c9e01b88d93bb6
BLAKE2b-256 a8484cd70dece597673627b4a5c7b8548c3f8781c225fac0bd00c4d9ecc9895a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for persian_sms_manager-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c95e6f9c29582c987b6179b68fde7ef26a89229b9f064a2d1add89b3f972fbcb
MD5 832474be0a5da9edc6910f9f17f29036
BLAKE2b-256 544c3bac1142fb13d23f5525a29f4e58592faffc4bb682ba00b62ad595b85e24

See more details on using hashes here.

Supported by

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