A package for handling messaging and OTP functionalities.
Project description
Bitmoro Messaging and OTP Library

This library provides a convenient interface for sending messages and handling OTP (One-Time Password) operations using the Bitmoro API from Python.
Installation
pip install bitmoro
Usage
The code below shows how to get started using the messaging and OTP features.
Sending Messages
from bitmoro import MessageSender
token = 'your_token_here' # Replace with your API token
sender = MessageSender(token)
def send_message():
try:
success = sender.send_sms('Hello, World!', ['+1234567890'], 'YourSenderId')
print('Message sent:', success)
except Exception as error:
print('Error sending message:', error)
send_message()
Scheduling Messages
from bitmoro import MessageScheduler
from datetime import datetime, timedelta
token = 'your_token_here' # Replace with your API token
scheduler = MessageScheduler(token)
def schedule_message():
future_time = datetime.now() + timedelta(minutes=10)
try:
scheduler.schedule_sms('Scheduled message!', ['+1234567890'], future_time, 'YourSenderId')
print('Message scheduled successfully.')
except Exception as error:
print('Error scheduling message:', error)
schedule_message()
Handling OTPs
from bitmoro import OtpHandler
token = 'your_token_here' # Replace with your API token
otp_handler = OtpHandler(token)
def send_otp():
try:
otp_handler.send_otp_message('9841452888', 'md_alert')
print('OTP sent successfully.')
except Exception as error:
print('Error sending OTP:', error)
def verify_otp():
otp = input("Enter the OTP received: ")
try:
is_valid = otp_handler.verify_otp('9841452888', otp)
print('OTP valid:', is_valid)
except Exception as error:
print('Error verifying OTP:', error)
send_otp()
verify_otp()
Features
- Send Messages: Easily send SMS messages to multiple recipients using a straightforward API.
- OTP Generation and Verification: Generate secure OTPs and verify them for authentication purposes.
- Error Handling: Includes custom error classes to handle API errors effectively.
Streaming Responses
The library supports streaming responses for real-time applications. This can be particularly useful for use cases where immediate feedback is required.
Request & Response Types
The library includes TypeScript definitions for all request parameters and response fields, ensuring type safety and better developer experience.
Automated Function Calls
Automate repetitive tasks by integrating function calls within your message handling and OTP verification processes.
Bulk Operations
For applications requiring bulk message sending or OTP generation, the library provides helper functions to streamline these operations.
Error Handling
When the library is unable to connect to the API, or if the API returns a non-success status code, a MessageSenderError will be thrown. Here’s an example of how to handle such errors:
def main():
try:
sender.send_sms('Hello, World!', ['+1234567890'])
except MessageSenderError as err:
print(err) # Error message
except Exception as err:
raise err
main()
Explanation
- Language Identifier: Use
pythonafter the opening triple backticks to specify Python syntax highlighting. - Token: Replace
'your_token_here'with your actual API token. - Phone Number and Sender ID: Adjust the phone number
['+1234567890']and the sender ID'YourSenderId'to match your requirements. - Function: The
send_messagefunction demonstrates how to instantiate theMessageSenderclass and send a message, handling any exceptions that may occur.
By using the correct syntax highlighting, your README will be more readable and user-friendly for developers who are using your library.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitmoro-0.1.1.tar.gz.
File metadata
- Download URL: bitmoro-0.1.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d618e5e31e852a4b919a2bd4ed3541482834382aa594e5824eb9fe04503820c0
|
|
| MD5 |
573473a163812a6c402194b7b7de82d1
|
|
| BLAKE2b-256 |
8ff2dfc01bba1b4c96a985ebfa363eac0185ba428cd4f3f1f7abf1205bf39ebc
|
File details
Details for the file bitmoro-0.1.1-py3-none-any.whl.
File metadata
- Download URL: bitmoro-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5fbf08bf311cd15bcfbdac4a59efcdb54f6fbc5931048f240a4ca000436fbff
|
|
| MD5 |
7b760ce6c54c6e503648aeccd1fa0e46
|
|
| BLAKE2b-256 |
3bb079e238106a70d3521da0270e6bdd3a07c7df50b9aa8ef604d1763f79d06a
|