daily-webhooks

command module
v1.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 13 Imported by: 0

README

Daily Webhooks

Actions Status codecov Go Version Go Report Card Release Docker Hub License

Fetch something interesting from the Internet, and send them to your webhooks.

How it works

Daily-Webhooks designed to be simple, core components as shown below.

+---------------------------------------------------+
|                    internet                       |
+---------------------------------------------------+
        ^                 ^                 ^
        |                 |                 |
+---------------+ +---------------+ +---------------+  ----+
| fetch task 01 | | fetch task 02 | | fetch task 03 |      |
+---------------+ +---------------+ +---------------+      |
        |                 |                 |              |
        |                 |                 |              |
+---------------------------------------------------+      |
|                       cron                        |      |
+---------------------------------------------------+      |
            \         /       \         /                  +=> Daily Webhooks
             \       /         \       /                   |
          +------------+     +------------+                |
          |   render   |     |   render   |                |
          +------------+     +------------+                |
                |                  |                       |
          +------------+     +------------+                |
          | channel 01 |     | channel 02 |                |
          +------------+     +------------+     -----------+
                |                  |
                v                  v
          +------------+     +------------+
          |  webhook   |     |  webhook   |
          +------------+     +------------+

Configuration

Daily-Webhooks use YAML for configuration files, the default configuration file is ${HOME}/.config/daily-webhooks/config.yaml.

All the configuration options Daily-Webhooks used are as follows, please note that some options are optional, and some are required.

log-level: info

http:
  timeout: 10000
  # Set URL proxy, "http", "https", and "socks5" types are supported.
  # proxy: http://127.0.0.1:7890
  retry-times: 3

channels:
  - name: channel01
    type: bark
    bark-custom-server: "https://api.day.app/push" # optional
    bark-device-key: "device-key" # required
    bark-custom-icon: "https://day.app/assets/images/avatar.jpg" # optional, only works on iOS 15+
  - name: channel02
    type: dingtalk
    dingtalk-server: "https://oapi.dingtalk.com/robot/send" # optional
    dingtalk-access-token: "token" # required
    dingtalk-secret: "secret" # required
  - name: channel03
    type: discard
  - name: channel04
    type: email
    email-server: "smtp.qq.com:587" # required
    email-username: "username" # required
    email-password: "password" # required
    email-from: "sender@qq.com" # required
    email-to: "receiver@qq.com" # required

fetch-tasks:
  - type: chinese-poetry
    # Use "github.com/robfig/cron" to run cron jobs, reference the document for more details.
    # "https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format"
    cron: "0 0 8 * * *"
    chinese-poetry-server: "https://v2.jinrishici.com/sentence" # optional
    chinese-poetry-token: "user-token" # required
    channels:
      - channel01
      - channel02
      - channel03
      - channel04
  - type: exec-shell
    cron: "0 0 9 * * *"
    exec-shell-script: "date -u" # required, execute the command as "/bin/sh -c 'date -u'"
    channels:
      - channel01
  - type: health-check
    cron: "0 0 7-22/3 * * *"
    health-check-apis: # optional, but it's better to have one
      - name: Google
        url: "https://www.gstatic.com/generate_204"
    channels:
      - channel02
  - type: pokemon-wiki
    cron: "0 0 10 * * *"
    channels:
      - channel03
  - type: today-in-history
    cron: "0 0 11 * * *"
    channels:
      - channel04

Install and Getting started

Using Docker

Pull the Docker image.

docker pull maomao233/daily-webhooks

Start a Docker container, use -e "TZ=Asia/Shanghai" option to specify the timezone in container.

docker run -d --restart=always -v "$HOME/.config/daily-webhooks/:/app/" -e "TZ=Asia/Shanghai" --name daily-webhooks maomao233/daily-webhooks
Using Go

Install by using the go install command.

go install github.com/fantasticmao/daily-webhooks@latest

Run Daily-Webhooks as a daemon by using systemd with the configuration daily-webhooks.service .

Manual Deployment

Download the pre-compiled executable file from GitHub Releases.

Run Daily-Webhooks as a daemon by using systemd with the configuration daily-webhooks.service .

Supported Channels

Supported Fetch Tasks

Supported Task Type Description Data Comes From
chinese-poetry Recommend a Chinese poetry 今日诗词
TODO en-word-of-the-day English-Word of the Day Merriam-Webster
exec-shell Execute shell commands Stdout or Stderr
health-check Check the status of applications Health check response from applications
TODO jp-word-of-the-day Japanese-Word of the Day
TODO pokemon-wiki Introduce Pokemon by random 神奇宝贝百科
today-in-history What happened today in history 历史上的今天 - 百度百科

Issues and Pull requests are always welcome!

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL