Skip to main content

A simple client for ntfy.sh.

Project description

Description

A simple tool to make sending notifications to ntfy.sh or your self-hosted instance easy and clean.

Usage

Example: echo test failure | ntfyr -t test -s http://ntfy.sh -G skull,failure -T 'Bad thing happened!'

ntfyr [-h] [-A ACTIONS] [-X ATTACH] [-C CLICK] [-D DELAY] [-E EMAIL]
      [-P {max,urgent,high,default,low,min,1,2,3,4,5}] [-G TAGS [TAGS ...]]
      [-T TITLE] [-m MESSAGE] [--timestamp [TIMESTAMP]] -t TOPIC [-s SERVER]
      [-u USER] [-p PASSWORD] [-o TOKEN] [-c CONFIG] [--debug]

Arguments

  -t TOPIC, --topic TOPIC              The topic to send the notification to. Required.
  -s SERVER, --server SERVER           The server to send the notification to. Defaults to https://ntfy.sh.
  -u USER, --user USER                 The user to authenticate to the server with.
  -p PASSWORD, --password PASSWORD     The password to authenticate to the server with.
  -o TOKEN, --token TOKEN              The token to authenticate to the server with.
  -c CONFIG [CONFIG ...], --config CONFIG [CONFIG ...] One or more configuration files with default values. The values in each file are merged onto the file after it (left to right) if more than one file is given. The values specified as arguments override the values in these files.
  -m MESSAGE, --message MESSAGE        The body of the message to send. The default (or if "-"is given) is to read from stdin.
  --timestamp                          Add a timestamp to the message. If this argument is given without a value '%Y-%m-%d %H:%M:%S %Z' is used as the timestamp format. If the strig `%message` is in the format string it is replaced with the message after the timestamp is formatted.
  -h, --help                           Show this help message and exit.
  --debug                              Show extra information in the error messages.

The following specify metadata (headers). See https://ntfy.sh/docs/publish/ for more information.

  -A ACTIONS, --actions ACTIONS
  -X ATTACH, --attach ATTACH
  -C CLICK, --click CLICK
  -D DELAY, --delay DELAY
  -E EMAIL, --email EMAIL
  -P {max,urgent,high,default,low,min,1,2,3,4,5}, --priority {max,urgent,high,default,low,min,1,2,3,4,5}
  -G TAGS [TAGS ...], --tags TAGS [TAGS ...]
  -T TITLE, --title TITLE

Install

  • Install via pipx:
    pipx install ntfyr
    
  • Install system-wide with pipx:
    PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install ntfyr
    
  • Install manually:
    git clone https://github.com/haxwithaxe/ntfyr.git
    cd ntfyr
    python3 setup.py install
    

Configuration

No configuration is required. However a config file with default values can be given via -c path/to/config.ini, --config path/to/config.ini, or in the default location at /etc/ntfyr/config.ini. Any of the long options (options beginning with --) without the leading dashes can be used to specify a default value for that option. For example the following sets a default server and credentials:

[ntfyr]
server = http://ntfy.example.com
user = alice
password = supersecret
timestamp = %%Y-%%m-%%d %%H:%%M:%%S %%Z

Commandline arguments override config values. Passing an option with an empty string will disable the default value in the config file. For example the following will disable the authentication that the above config enables:

ntfyr --user '' --password '' -t mytopic -m 'Hello world!'

The timestamp option requires the % symbols to be escaped by doubling them (%%).

Dependencies

This module depends on requests and tzlocal.

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

ntfyr-0.3.1.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

ntfyr-0.3.1-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file ntfyr-0.3.1.tar.gz.

File metadata

  • Download URL: ntfyr-0.3.1.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ntfyr-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d579eb58c14afba1a3491e0456aa164b1c9d8266ceb3096ec3dbcd959468960e
MD5 d23bcc28d46c080bbe778ab857e5118b
BLAKE2b-256 47e62cd0b20d99107de0ce2cc8bbeba2ab49bb6d388fbd5ca46dca4e35280baa

See more details on using hashes here.

File details

Details for the file ntfyr-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ntfyr-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ntfyr-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82d0691ca56e44c1cc0ecaef382def8faee376e1bb03714365a04bc37731f80e
MD5 aea4df362bebf24e99cd51d6f11dfe70
BLAKE2b-256 5edeb2f2bf9fc37f31cd9fa9e981f1b3c147fcfc3b9abfe05dd5fce50ca956b5

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