Skip to main content

A simple notification CLI for Bark and Weixin

Project description

owl-notify

A simple notification CLI for Bark, Weixin, and custom webhooks.

Installation

pip install owl-notify

Configuration

Create a config file at ~/.owl-notify.toml:

[bark]
server_url = "https://api.day.app"
token = "your-bark-token"

[weixin]
bot_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your-key"

# Custom webhook example
[webhook.slack]
url = "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
method = "POST"
body = '''
{
  "text": "{{title}}\n\n{{message}}"
}
'''

CLI Usage

# Send via Bark (default)
owl "Title" "Message"

# Send via Weixin
owl "Title" "Message" --platform weixin

# Send via custom webhook
owl "Title" "Message" --platform webhook.slack

# Use extra fields for webhook templates
owl "Title" "Message" --platform webhook.discord --extra from="Bot" --extra priority="high"

# Short form
owl "Title" "Message" -p webhook.slack -e from="Alert System"

# Use custom config file
owl "Title" "Message" --config /path/to/config.toml

# Show config file path
owl --show-config

Python API

Simple Usage (Recommended)

import owl_notify

# Use default config (~/.owl-notify.toml)
owl_notify.send("Title", "Message")

# Send via different platforms
owl_notify.send("Title", "Message", platform="weixin")
owl_notify.send("Title", "Message", platform="webhook.slack")

# Use custom config file
owl_notify.send("Title", "Message", config_path="/path/to/config.toml")

# Use extra fields for webhook templates
owl_notify.send(
    "Title",
    "Message",
    platform="webhook.discord",
    extra={"from": "Bot", "priority": "high"}
)

# All parameters together
owl_notify.send(
    "Title",
    "Message",
    platform="webhook.slack",
    extra={"from": "System"},
    config_path="/custom/config.toml"
)

Class-based Usage (Also Available)

from owl_notify import Notify

# Use default config (~/.owl-notify.toml)
notifier = Notify()

# Or specify config path
notifier = Notify(config_path="/path/to/config.toml")

# Send notification
notifier.send("Title", "Message", platform="bark")
notifier.send("Title", "Message", platform="weixin")

# Send via custom webhook
notifier.send("Title", "Message", platform="webhook.slack")

# Use extra fields
notifier.send(
    "Title",
    "Message",
    platform="webhook.discord",
    extra={"from": "Bot", "priority": "high"}
)

Custom Webhook Configuration

You can define custom webhook integrations in your config file. Each webhook instance has a unique name.

Configuration Format

[webhook.instance_name]
url = "https://api.example.com/webhook"  # Required
method = "GET"  # Optional, defaults to POST
body = '''{ "key": "{{template}}" }'''  # For POST requests

Template Placeholders

Use {{placeholder}} syntax in URLs and body templates:

  • {{title}} - Notification title
  • {{message}} - Notification message
  • {{key}} - Any extra field passed via --extra key=value

Common Platform Examples

Slack

[webhook.slack]
url = "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
method = "POST"
body = '''
{
  "text": "{{title}}\n\n{{message}}"
}
'''

Discord

[webhook.discord]
url = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
method = "POST"
body = '''
{
  "content": "**{{title}}**\n{{message}}",
  "username": "{{from}}"
}
'''

Usage with extra fields:

owl "Alert" "Something happened" -p webhook.discord -e from="Monitor"

Feishu (飞书)

[webhook.feishu]
url = "https://open.feishu.cn/open-apis/bot/v2/hook/YOUR_WEBHOOK_TOKEN"
method = "POST"
body = '''
{
  "msg_type": "text",
  "content": {
    "text": "{{title}}\n{{message}}\nFrom: {{from}}"
  }
}
'''

Custom GET Request

[webhook.custom_api]
url = "https://api.example.com/notify?title={{title}}&message={{message}}&priority={{priority}}"
method = "GET"

Usage:

owl "Alert" "Message" -p webhook.custom_api -e priority="high"

License

Apache License 2.0

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

owl_notify-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

owl_notify-0.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file owl_notify-0.1.1.tar.gz.

File metadata

  • Download URL: owl_notify-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for owl_notify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5472bb404c1a05c388cf0b8386361b0bfa3f50785efe99d78adff9a5de8c7841
MD5 a89c1bb54aabaaa131c7309d85014e82
BLAKE2b-256 338556843f7eaf5e4f4009eed360bc4f25e97ba438d2bc16c4704d74b9543d51

See more details on using hashes here.

Provenance

The following attestation bundles were made for owl_notify-0.1.1.tar.gz:

Publisher: publish.yml on liguoqinjim/owl-notify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file owl_notify-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: owl_notify-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for owl_notify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21c51710f258511c7869204ddd475c245c683b5ad48f79e054e79d3eb36e4401
MD5 c890cb6c07a0f6acf4b7444e9b5e35cb
BLAKE2b-256 b2c078db4b51865cc2083c6f4053eb75c896cb135565561d841816779c9f3de5

See more details on using hashes here.

Provenance

The following attestation bundles were made for owl_notify-0.1.1-py3-none-any.whl:

Publisher: publish.yml on liguoqinjim/owl-notify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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