Python client to interact with TeleNoti API
Project description
HumanTech - Telegram Notification - Python Client
How to install
$ pip install telenotipy
How to use
- Create a new TelegramNotificationClient with your API token
from telenotipy import TelegramNotificationClient
client = TelegramNotificationClient('API TOKEN')
The token must be retrieved from the TeleNotiPy server instance.
- Send notifications to your users!
client.send_notification(
to=['UserID1', 'UserID2']
message="Hi from My Application"
)
Simple flow
- First you want to send a subscription to a Telegram User
from telenotipy import TelegramNotificationClient
client = TelegramNotificationClient('MY API TOKEN')
subscription = client.create_subscription()
# Send subscription.id to a Telegram user
# The user must send the command /start followed by this token to the bot
# This can be simplified by giving the user a Start link:
# - https://telegram.me/MyTeleNotiPyBot?start=TheSubscriptionID
- Then you might want to check if the user has accepted the subscription
from telenotipy import TelegramNotificationClient
client = TelegramNotificationClient('MY API TOKEN')
subscription = client.get_subscription(the_subscription_id)
print(subscription.is_bound)
# If the subscription is bound, it means that the user has accepted
- You want to send notifications to one or more Telegram Users
from telenotipy import TelegramNotificationClient
client = TelegramNotificationClient('MY API TOKEN')
client.send_notification(
to=[the_subscription_id_1, the_subscription_id_2, ...]
message="Hi, here is my message!"
)
Advanced usage
Use a different server
client = TelegramNotificationClient('API TOKEN', 'The telenotipy server address')
Create a new subscription
subscription = client.create_subscription()
subscription.id # The User Token
subscription.is_bound # Whether the subscription is bound to a Telegram User, is False when creating
List your existing subscriptions
subscriptions = client.list_subscriptions(page=1)
subscriptions.previous_page # The Previous page number
subscriptions.next_page # The Next page number
subscriptions.count # The total count of subscriptions (all pages)
subscriptions.results # The list of subscriptions
Get the info about an existing subscription
subscription_id = 'The Subscription ID'
subscription = client.get_subscription(subscription_id):
subscription.id # The User Token
subscription.is_bound # Whether the subscription is bound to a Telegram User
Delete an existing subscription
subscription_id = 'The Subscription ID'
client.delete_subscription(subscription_id):
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
telenotipy-0.0.2.tar.gz
(3.9 kB
view details)
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 telenotipy-0.0.2.tar.gz.
File metadata
- Download URL: telenotipy-0.0.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
510a93ebf8a5911f23f9405170e360e3d995d068482df762ce9e75760dd72a57
|
|
| MD5 |
dbc79198684e86eb5cd621cef73f4bc5
|
|
| BLAKE2b-256 |
7566486045f2cd45479712845df1831e0cefb000461dbf3994c0e47589a9e0ad
|
File details
Details for the file telenotipy-0.0.2-py3-none-any.whl.
File metadata
- Download URL: telenotipy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2711cad5a6619b0c4d45a274d96a0b048cb8012ea929fa9464df355401f40f3a
|
|
| MD5 |
69b88cb3a6c15ad95a0bf797b979e7d3
|
|
| BLAKE2b-256 |
6a7ff3541d61f802c5d7f0c472183413f76ad2495471bba4b91a06b489fbf7ce
|