-Click and expand to see supported parameter types
+Click to expand and view supported parameter types
#### 📅 Date and Time Parameters
-
-Use the `{{%format}}` format to define date and time parameters:
+Use `{{%format}}` format to define date and time parameters:
- `{{%Y-%m-%d}}` - Current date, format: 2006-01-02 (e.g., 2025-09-22)
- `{{%H:%M:%S}}` - Current time, format: 15:04:05 (e.g., 17:30:45)
- `{{%s}}` - Unix timestamp (e.g., 1727859600)
- `{{%Y}}` - Current year (e.g., 2025)
- `{{%m}}` - Current month, format: 01-12
-- `{{%d}}` - Current day, format: 01-31
+- `{{%d}}` - Current date, format: 01-31
- `{{%H}}` - Current hour, format: 00-23
- `{{%M}}` - Current minute, format: 00-59
- `{{%S}}` - Current second, format: 00-59
@@ -124,124 +124,124 @@ Use the `{{%format}}` format to define date and time parameters:
#### 🎲 Random Number Parameters
-- `{{rand}}` - Generates a random number in the range 0–1000000
-- `{{rand_int}}` - Generates a large-range random integer
-- `{{rand(min,max)}}` - Generates a random number within a specified range
- - Example: `{{rand(1,100)}}` - Generates a random number between 1 and 100
- - Example: `{{rand(1000,9999)}}` - Generates a 4-digit random number
+- `{{rand}}` - Generate random number in range 0-1000000
+- `{{rand_int}}` - Generate large range random integer
+- `{{rand(min,max)}}` - Generate random number in specified range
+ - Example: `{{rand(1,100)}}` - Generate random number between 1-100
+ - Example: `{{rand(1000,9999)}}` - Generate 4-digit random number
#### 🔤 Random String Parameters
-- `{{rand_str}}` - Generates an 8-character random string (letters + numbers)
-- `{{rand_str(length)}}` - Generates a random string of specified length
- - Example: `{{rand_str(16)}}` - Generates a 16-character random string
-- `{{rand_str_secure}}` - Generates a 16-character cryptographically secure random string
-- `{{rand_hex(length)}}` - Generates a random hexadecimal string of specified length
- - Example: `{{rand_hex(8)}}` - Generates an 8-character hexadecimal string
- - Example: `{{rand_hex(32)}}` - Generates a 32-character hexadecimal string
+- `{{rand_str}}` - Generate 8-character random string (letters + numbers)
+- `{{rand_str(length)}}` - Generate random string of specified length
+ - Example: `{{rand_str(16)}}` - Generate 16-character random string
+- `{{rand_str_secure}}` - Generate 16-character cryptographically secure random string
+- `{{rand_hex(length)}}` - Generate hexadecimal random string of specified length
+ - Example: `{{rand_hex(8)}}` - Generate 8-character hexadecimal string
+ - Example: `{{rand_hex(32)}}` - Generate 32-character hexadecimal string
#### 🆔 UUID Parameters
-- `{{uuid}}` - Generates a standard UUID (with hyphens)
+- `{{uuid}}` - Generate standard UUID (with hyphens)
- Example: `bf3655f7-8a93-4822-a458-2913a6fe4722`
-- `{{uuid_short}}` - Generates a short UUID (without hyphens)
+- `{{uuid_short}}` - Generate short UUID (without hyphens)
- Example: `14d44b7334014484bb81b015fb2401bf`
#### 🌍 Environment Variable Parameters
-- `{{env(variable_name)}}` - Reads the value of an environment variable
- - Example: `{{env(API_KEY)}}` - Reads the API_KEY environment variable
- - Example: `{{env(VERSION)}}` - Reads the VERSION environment variable
- - If the environment variable does not exist, returns an empty string
+- `{{env(variable_name)}}` - Read environment variable value
+ - Example: `{{env(API_KEY)}}` - Read API_KEY environment variable
+ - Example: `{{env(VERSION)}}` - Read VERSION environment variable
+ - Returns empty string if environment variable doesn't exist
-Ensure that the environment variable is set in your GitHub repository settings under "Settings" -> "Secrets and variables" -> "Actions".
+Environment variables can be set through GitHub Actions Repository Secrets
-#### 📊 Serial Number and Hash Parameters
+#### 📊 Sequence and Hash Parameters
-- `{{seq}}` - Sequence number based on the current time (6-digit number)
+- `{{seq}}` - Time-based sequence number (6 digits)
- `{{seq_daily}}` - Daily sequence number (seconds since midnight)
-- `{{hash_short}}` - Short hash value (6-digit hexadecimal)
-- `{{hash_md5_like}}` - MD5-style long hash value (32-digit hexadecimal)
+- `{{hash_short}}` - Short hash value (6-character hexadecimal)
+- `{{hash_md5_like}}` - MD5-style long hash value (32-character hexadecimal)
#### 🌐 Network and System Information Parameters
-- `{{local_ip}}` - Gets the local IP address of the system
-- `{{hostname}}` - Gets the hostname of the system
-- `{{user_agent}}` - Generates a random User-Agent string for HTTP requests
-- `{{http_method}}` - Generates a random HTTP method (GET, POST, PUT, DELETE, etc.)
+- `{{local_ip}}` - Get system local IP address
+- `{{hostname}}` - Get system hostname
+- `{{user_agent}}` - Generate random User-Agent string
+- `{{http_method}}` - Generate random HTTP method (GET, POST, PUT, DELETE, etc.)
#### 🔐 Encoding and Decoding Parameters
-- `{{base64(content)}}` - Base64 encodes the provided content
- - Example: `{{base64(hello world)}}` - Encodes "hello world" to Base64
-- `{{url_encode(content)}}` - URL encodes the provided content
- - Example: `{{url_encode(hello world)}}` - URL encodes "hello world"
-- `{{json_escape(content)}}` - JSON escapes the provided content
- - Example: `{{json_escape("test")}}` - Escapes quotes and special characters for JSON
+- `{{base64(content)}}` - Base64 encode the provided content
+ - Example: `{{base64(hello world)}}` - Encode "hello world" to Base64
+- `{{url_encode(content)}}` - URL encode the provided content
+ - Example: `{{url_encode(hello world)}}` - URL encode "hello world"
+- `{{json_escape(content)}}` - JSON escape the provided content
+ - Example: `{{json_escape("test")}}` - Escape quotes and special characters for JSON
#### 🔢 Mathematical Operation Parameters
-- `{{add(a,b)}}` - Adds two numbers
+- `{{add(a,b)}}` - Add two numbers
- Example: `{{add(10,5)}}` - Returns 15
-- `{{sub(a,b)}}` - Subtracts two numbers
+- `{{sub(a,b)}}` - Subtract two numbers
- Example: `{{sub(10,5)}}` - Returns 5
-- `{{mul(a,b)}}` - Multiplies two numbers
+- `{{mul(a,b)}}` - Multiply two numbers
- Example: `{{mul(10,5)}}` - Returns 50
-- `{{div(a,b)}}` - Divides two numbers
+- `{{div(a,b)}}` - Divide two numbers
- Example: `{{div(10,5)}}` - Returns 2
#### 📝 Text Processing Parameters
-- `{{upper(text)}}` - Converts text to uppercase
+- `{{upper(text)}}` - Convert text to uppercase
- Example: `{{upper(hello)}}` - Returns "HELLO"
-- `{{lower(text)}}` - Converts text to lowercase
+- `{{lower(text)}}` - Convert text to lowercase
- Example: `{{lower(HELLO)}}` - Returns "hello"
-- `{{reverse(text)}}` - Reverses the text
+- `{{reverse(text)}}` - Reverse text
- Example: `{{reverse(hello)}}` - Returns "olleh"
-- `{{substr(text,start,length)}}` - Extracts substring from text
+- `{{substr(text,start,length)}}` - Extract substring from text
- Example: `{{substr(hello world,0,5)}}` - Returns "hello"
#### 🎨 Color Generation Parameters
-- `{{color_hex}}` - Generates a random hexadecimal color code
+- `{{color_hex}}` - Generate random hexadecimal color code
- Example: `#FF5733`
-- `{{color_rgb}}` - Generates a random RGB color value
+- `{{color_rgb}}` - Generate random RGB color value
- Example: `rgb(255, 87, 51)`
-- `{{color_hsl}}` - Generates a random HSL color value
+- `{{color_hsl}}` - Generate random HSL color value
- Example: `hsl(120, 50%, 75%)`
#### 📁 File and MIME Type Parameters
-- `{{mime_type}}` - Generates a random MIME type
+- `{{mime_type}}` - Generate random MIME type
- Example: `application/json`, `image/png`, `text/html`
-- `{{file_ext}}` - Generates a random file extension
+- `{{file_ext}}` - Generate random file extension
- Example: `.jpg`, `.pdf`, `.txt`
#### 👤 Fake Data Generation Parameters
-- `{{fake_email}}` - Generates a realistic fake email address
+- `{{fake_email}}` - Generate realistic fake email address
- Example: `john.smith@example.com`
-- `{{fake_phone}}` - Generates a fake phone number
+- `{{fake_phone}}` - Generate fake phone number
- Example: `+1-555-0123`
-- `{{fake_name}}` - Generates a fake person name
+- `{{fake_name}}` - Generate fake person name
- Example: `John Smith`
-- `{{fake_domain}}` - Generates a fake domain name
+- `{{fake_domain}}` - Generate fake domain name
- Example: `example-site.com`
#### ⏰ Time Calculation Parameters
-- `{{time_add(duration)}}` - Adds duration to current time
- - Example: `{{time_add(1h)}}` - Adds 1 hour to current time
- - Example: `{{time_add(30m)}}` - Adds 30 minutes to current time
+- `{{time_add(duration)}}` - Add specified duration to current time
+ - Example: `{{time_add(1h)}}` - Add 1 hour to current time
+ - Example: `{{time_add(30m)}}` - Add 30 minutes to current time
- Supported units: s (seconds), m (minutes), h (hours), d (days)
-- `{{time_sub(duration)}}` - Subtracts duration from current time
- - Example: `{{time_sub(1d)}}` - Subtracts 1 day from current time
- - Example: `{{time_sub(2h30m)}}` - Subtracts 2 hours and 30 minutes
+- `{{time_sub(duration)}}` - Subtract specified duration from current time
+ - Example: `{{time_sub(1d)}}` - Subtract 1 day from current time
+ - Example: `{{time_sub(2h30m)}}` - Subtract 2 hours 30 minutes from current time
-Below is an example configuration file:
+Here is an example configuration file:
```yaml
services:
@@ -258,18 +258,178 @@ services:
### Custom Notifications
-PongHub uses GitHub Actions for exception alert notifications by default.
+PongHub now supports multiple notification methods. When services have issues or certificates are about to expire, alerts can be sent through multiple channels.
+
+
+Click to expand and view supported notification types
+
+
+
+PongHub supports the following notification methods:
+
+- **Default Notification** - Notification through GitHub Actions workflow failure
+- **Email Notification** - Send emails via SMTP
+- **Discord** - Send to Discord channels via Webhook
+- **Slack** - Send to Slack channels via Webhook
+- **Telegram** - Send messages via Bot API
+- **WeChat Work** - Send messages via WeChat Work group bot
+- **Custom Webhook** - Send to any HTTP endpoint
+
+To use, add a `notifications` configuration block in your `config.yaml` file:
+
+```yaml
+notifications:
+ enabled: true # Enable notification functionality
+ methods: # Notification methods to enable
+ - email
+ - discord
+ - slack
+ - telegram
+ - wechat
+ - webhook
+
+ # Specific configuration for each notification method...
+```
+
+#### ⚙️ Default Notification
+
+By default, PongHub will send notifications when GitHub Actions workflows fail.
+
+Default notification is automatically enabled when:
+
+- No `notifications` field is configured
+- `notifications.enabled: true` but no `methods` specified
+- Explicitly configured `methods: ["default"]`
+
+#### 📧 Email Notification
-If you need custom notifications, you can create a `notify.sh` script in the root directory. The script can read the contents of the `data/notify.txt` file and send notifications via email, SMS, or other methods. If the script uses environment variables, ensure that these variables are correctly set in the "Settings" -> "Secrets and variables" -> "Actions" section of your GitHub repository.
+```yaml
+email:
+ smtp_host: "smtp.gmail.com" # Leave empty to read from environment variables
+ smtp_port: 587 # SMTP port, default is 587
+ from: "alerts@yourdomain.com" # Sender email address
+ to: # Recipient email addresses
+ - "admin@yourdomain.com"
+ - "ops@yourdomain.com"
+ subject: "PongHub Service Alert" # Email subject (optional)
+ use_tls: true # Use TLS (optional)
+ use_starttls: true # Use StartSSL (optional)
+ skip_verify: true # Skip SSL certificate verification (optional)
+```
+
+Required environment variables:
+
+- `SMTP_USERNAME` - SMTP username
+- `SMTP_PASSWORD` - SMTP password
+
+#### 💬 Discord Configuration
+
+```yaml
+discord:
+ webhook_url: "https://discord.com/api/webhooks/your_webhook_id/your_webhook_token" # Leave empty to read from environment variables
+ username: "PongHub Bot" # Username for sending messages (optional)
+ avatar_url: "" # Avatar URL for sending messages (optional)
+```
+
+Required environment variables:
-## Development
+- `DISCORD_WEBHOOK_URL` - Discord Webhook URL
-This project uses Makefile for local development and testing. You can run the project locally with the following command:
+#### 💬 Slack Configuration
+
+```yaml
+slack:
+ webhook_url: "https://hooks.slack.com/services/your/webhook/url" # Leave empty to read from environment variables
+ channel: "#alerts" # Channel to send messages to (optional)
+ username: "PongHub Bot" # Username for sending messages (optional)
+ icon_emoji: ":robot_face:" # Message icon (optional)
+```
+
+Required environment variables:
+
+- `SLACK_WEBHOOK_URL` - Slack Webhook URL
+
+#### 💬 Telegram Configuration
+
+```yaml
+telegram:
+ bot_token: "your_bot_token" # Leave empty to read from environment variables
+ chat_id: "your_chat_id" # Leave empty to read from environment variables
+```
+
+Required environment variables:
+
+- `TELEGRAM_BOT_TOKEN` - Telegram Bot Token
+- `TELEGRAM_CHAT_ID` - Telegram Chat ID
+
+#### 💬 WeChat Work Configuration
+
+```yaml
+wechat:
+ webhook_url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your_key" # Leave empty to read from environment variables
+```
+
+Required environment variables:
+
+- `WECHAT_WEBHOOK_URL` - WeChat Work group bot Webhook URL
+
+#### 💬 Custom Webhook Configuration
+
+```yaml
+webhook:
+ url: "https://your-webhook-endpoint.com/notify" # Leave empty to read from environment variables
+ method: "POST" # HTTP method (optional, default POST)
+ headers: # Custom request headers (optional)
+ Content-Type: "application/json"
+```
+
+Required environment variables:
+
+- `WEBHOOK_URL` - Custom Webhook URL
+
+
+
+
+All required environment variables can be set through GitHub Actions Repository Secrets.
+
+Here is an example configuration file:
+
+```yaml
+services:
+ - name: "Example Service"
+ endpoints:
+ - url: "https://example.com/health"
+notifications:
+ enabled: true
+ methods:
+ - email
+ - discord
+ email:
+ smtp_host: "smtp.gmail.com"
+ smtp_port: 587
+ from: "alerts@yourdomain.com"
+ to:
+ - "admin@yourdomain.com"
+ - "ops@yourdomain.com"
+ discord:
+ webhook_url: "https://discord.com/api/webhooks/your_webhook_id/your_webhook_token"
+ username: "PongHub Bot"
+```
+
+## Local Development
+
+This project uses Makefile for local development and testing. You can run the project locally using the following command:
```bash
make run
```
+The project has some test cases that can be run with the following command:
+
+```bash
+make test
+```
+
## Disclaimer
-[PongHub](https://github.com/WCY-dt/ponghub) is intended for personal learning and research only. The developers are not responsible for its usage or outcomes. Do not use it for commercial purposes or illegal activities.
+[PongHub](https://github.com/WCY-dt/ponghub) is for personal learning and research only. We are not responsible for the usage behavior or results of the program. Please do not use it for commercial purposes or illegal activities.
diff --git a/README_CN.md b/README_CN.md
index b2617fc992..ed03d8c999 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -66,6 +66,7 @@ PongHub 是一个开源的服务状态监控网站,旨在帮助用户监控和
| `services.endpoints.body` | 字符串 | 请求体内容 | ✖️ | 仅在 `POST`/`PUT` 请求时使用 |
| `services.endpoints.status_code` | 整数 | 响应体期望的 HTTP 状态码(默认 `200`) | ✖️ | 默认 `200` |
| `services.endpoints.response_regex` | 字符串 | 响应体内容的正则表达式匹配 | ✖️ | |
+| `notifications` | 对象 | 通知配置 | ✖️ | 详见 [自定义通知](#自定义通知) |
下面是一个示例配置文件:
@@ -257,9 +258,163 @@ services:
### 自定义通知
-PongHub 默认利用 GitHub Actions 报错实现异常告警通知。
+PongHub 现在支持多种通知方式,当服务出现问题或证书即将过期时,可以通过多个渠道发送警报通知。
-如果需要自定义通知,可以在根目录下创建 `notify.sh` 脚本,脚本可以读取 `data/notify.txt` 文件中的内容,并通过邮件、短信或其他方式发送通知。如果脚本使用到了环境变量,请确保在 GitHub 仓库的 "Settings" -> "Secrets and variables" -> "Actions" 中正确设置这些变量。
+