Skip to main content
https://img.shields.io/pypi/l/ntfy-real-time-client.svg PyPI-Server https://img.shields.io/pypi/pyversions/ntfy-real-time-client.svg https://img.shields.io/pypi/status/ntfy-real-time-client.svg Project generated with PyScaffold

ntfy-real-time-client

THIS IS NOT READY YET

https://github.com/iacchus/python-pushover-open-client/blob/main/src/python_pushover_open_client/__init__.py

Command line app and framework for receiving and processing NTFY push notifications in real time.

Features

  • Receive notifications real time via NTFY websocket server.

  • Execute python funcions via commands received by notification, passing arguments as *args.

  • Execute shell commands, passing arguments.

  • Execute python functions to all received notifications (eg.,. you can use Popen to send all notifications to notify-send.)

  • Can be run as a system service, enabling your scripts from boot time.

  • It is being developed with facilities to make it easy subclassing.

Installing

pip install ntfy-real-time-client

Python minimum version 3.10 is needed.

Setting Up

u can start by setting three required envvars: NTFY_SERVER_HOSTNAME, NTFY_TOPIC and NTFY_TOKEN.

file: ~/.zshrc or ~/.bashrc etc

export NTFY_SERVER_HOSTNAME="ntfy.yourdomain.comm"
export NTFY_TOPIC="general"
export NTFY_TOKEN="tk_mahb1gt0k3nz4321"

Then restart the shell.

Using

Command line

Our command line ntfy-real-time-client still needs more functions, but we already have one. His whole interface is here.

ntfy-real-time-client json

This command outputs new received notifications and can be used to pipe for your own scripts to be processed.

Programatically

Here is an example script of how using decorators to use the lib. More examples will be added soon, as there are more decorators/functions to be used.

file: notify.py

#!/usr/bin/env python

from subprocess import Popen

from ntfy_real_time_client import register_command
from ntfy_real_time_client import register_parser
from ntfy_real_time_client import NTFYClientRealTime


# Let's use a decorator to registrate a command function; it will be executed
# when a message with `mycmd_rawdata` as the first word is received. All
# the arguments, *ie.*, all the words in the notification, including
# `mycmd_rawdata` will be passed to ``*args``:

@register_command
def mycmd_rawdata(*args, raw_data=None):
    print("RAW DATA IS:", raw_data)

# this decorator register a parser which is executed for each new
# notification received; here we have two examples:

@register_parser
def my_notify_send_parser(raw_data=None):
    args_str = "notify-send \"{message}\"".format(message=raw_data["message"])
    Popen(args=args_str, shell=True)


@register_parser
def my_print_parser(raw_data=None):
    print("MESSAGE RECEIVED:", raw_data)

# this instantiates the NTFY websocket class and runs it
client = NTFYClientRealTime()
client.run_forever()

You can save the script above to a file (eg. ~/notify.py), then make it executable and run, after you have installed the package and entered your NTFY credentials:

chmod +x notify.py
./notify.py

Then while it is running, try to send a notification to the device (or all the devices) via NTFY website or other notification sending app.

Contributing

Please open an issue if you want to contribute with code. Or use discussions.

The sources’ package in reality contain only two files:

  • __init__.py - This contains the ntfy_real_time_client library itself.

  • __main__.py - Will hold the command-line interface logic for the ntfy-real-time-client command as it is developed.

Support

You can open a issue or a message in discussions for support in using/getting the code.

Is it ready already?

100%

Note

This project has been set up using PyScaffold 4.1.4. For details and usage information on PyScaffold see https://pyscaffold.org/.

Release files for ntfy-real-time-client 0.0.3

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

Source distribution (sdist)

Source distribution for ntfy-real-time-client 0.0.3
File Size Uploaded
ntfy_real_time_client-0.0.3.tar.gz 40.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ntfy-real-time-client 0.0.3
File Interpreter ABI Platform
ntfy_real_time_client-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 60.5 kB

Release files / ntfy_real_time_client-0.0.3.tar.gz

Download URL ntfy_real_time_client-0.0.3.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1ee935562790e58130c6ae31af276b894bcf3be5e772f7fd95cc7c6aae437743
BLAKE2b-256 checksum
How to use checksums
bfc398f8197500ca7b388dac04d24e43cee7f1366edbe387b6d9c83de7eba8b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / ntfy_real_time_client-0.0.3-py3-none-any.whl

Download URL ntfy_real_time_client-0.0.3-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3458785e84817f7213166db3be4ec6fabae59597c28d20837f12f422073ee7cb
BLAKE2b-256 checksum
How to use checksums
bb52237fd60f29a50d397c4cb2465d3539ebbf09a1fc17bb83790cde97ce99d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.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