Skip to main content

A simple notification CLI for Bark and Weixin

Project description

owl-notify

PyPI version Python License Downloads

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

Installation

pip install owl-notify

Supported Platforms

  • Bark: iOS notification service
  • Weixin (Text): Weixin Work Bot with plain text format
  • Weixin (Markdown V2): Weixin Work Bot with markdown formatting support
  • Custom Webhooks: Any HTTP-based webhook service (Slack, Discord, Feishu, etc.)

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"

[weixin_markdown_v2]
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 (text format)
owl "Title" "Message" --platform weixin

# Send via Weixin (markdown_v2 format)
owl "Title" "Message" --platform weixin_markdown_v2

# 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")

# Method 1: Using platform constants (recommended - type-safe, autocomplete)
owl_notify.send("Title", "Message", platform=owl_notify.platform.bark)
owl_notify.send("Title", "Message", platform=owl_notify.platform.weixin)
owl_notify.send("Title", "Message", platform=owl_notify.platform.weixin_markdown_v2)
owl_notify.send("Title", "Message", platform=owl_notify.platform.webhook("slack"))

# Method 2: Using strings (still supported for backward compatibility)
owl_notify.send("Title", "Message", platform="bark")
owl_notify.send("Title", "Message", platform="weixin")
owl_notify.send("Title", "Message", platform="weixin_markdown_v2")
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=owl_notify.platform.webhook("discord"),
    extra={"from": "Bot", "priority": "high"}
)

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

Class-based Usage (Also Available)

from owl_notify import Notify, platform

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

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

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

# Or use strings (backward compatible)
notifier.send("Title", "Message", platform="bark")
notifier.send("Title", "Message", platform="weixin")

# Use extra fields
notifier.send(
    "Title",
    "Message",
    platform=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.2.tar.gz (14.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.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: owl_notify-0.1.2.tar.gz
  • Upload date:
  • Size: 14.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.2.tar.gz
Algorithm Hash digest
SHA256 4f654e7386a4b9f998b29a071e253f869de1e1bb11b39c0ee37ea846b91b4f61
MD5 5380291114d8264f9f6b20e093d300a1
BLAKE2b-256 032269083cfd613e26133301f0671009c497b72f7af00c019cedb1051b4b1286

See more details on using hashes here.

Provenance

The following attestation bundles were made for owl_notify-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: owl_notify-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7219cb204dd145220db24c1be1f988fa04d9ace667c78654133d936257466bcb
MD5 7334ef124e13e46feb982209f09a11e2
BLAKE2b-256 b8039fa4af3058a0b871500eae3cc8417395b19cbc631b06565fcbe653700a62

See more details on using hashes here.

Provenance

The following attestation bundles were made for owl_notify-0.1.2-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