-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathforward_config.lua
More file actions
153 lines (138 loc) · 4.48 KB
/
forward_config.lua
File metadata and controls
153 lines (138 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
-- 转发规则配置文件
-- 支持多个渠道,关键词匹配和正则匹配
-- channel: 转发渠道 (wecom, feishu, dingding, custom_post, email)
-- keyword: 关键词匹配,部分匹配不区分大小写 ("all" 表示匹配所有消息)
-- regular: Lua正则模式匹配,区分大小写 (与keyword二选一)
-- webhook: 接收地址
-- secret: 签名密钥 (可选,用于dingding)
-- content_type: 内容类型 (可选,用于custom_post)
-- post_body: POST内容模板 (可选,用于custom_post)
-- smtp_server: SMTP服务器地址 (用于email)
-- smtp_port: SMTP服务器端口 (用于email,默认SSL=465,明文=25)
-- smtp_ssl: 是否启用SSL (用于email,默认true)
-- smtp_username: SMTP用户名 (用于email)
-- smtp_password: SMTP密码/授权码 (用于email)
-- email_from: 发件人邮箱 (用于email)
-- email_to: 收件人邮箱 (用于email)
--[[
========== 各渠道配置示例 ==========
企业微信 - 关键词匹配:
{
channel = "wecom",
keyword = "all",
webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your-webhook-key"
}
飞书 - 关键词匹配:
{
channel = "feishu",
keyword = "all",
webhook = "https://open.feishu.cn/open-apis/bot/v2/hook/your-webhook-id"
}
钉钉 - 关键词匹配:
{
channel = "dingding",
keyword = "all",
webhook = "https://oapi.dingtalk.com/robot/send?access_token=your-access-token",
secret = "your-secret" -- 可选,用于签名验证
}
自定义POST - 关键词匹配:
{
channel = "custom_post",
keyword = "all",
webhook = "https://your-api-endpoint.com/webhook",
content_type = "application/json",
post_body = {
title = "通知标题",
desp = "通知内容: {msg}" -- {msg} 会被替换为实际消息内容
}
}
邮件转发 - SSL加密(如QQ邮箱、163邮箱等):
{
channel = "email",
keyword = "all",
smtp_server = "smtp.qq.com",
smtp_port = 465,
smtp_ssl = true,
smtp_username = "user@qq.com",
smtp_password = "授权码", -- QQ邮箱需要使用授权码而非登录密码
email_from = "user@qq.com",
email_to = "recipient@example.com"
}
邮件转发 - 明文(如内网邮件服务器):
{
channel = "email",
keyword = "验证码",
smtp_server = "mail.example.com",
smtp_port = 25,
smtp_ssl = false,
smtp_username = "user@example.com",
smtp_password = "password",
email_from = "user@example.com",
email_to = "recipient@example.com"
}
========== 正则模式匹配示例 ==========
匹配验证码(4-6位连续数字):
{
channel = "wecom",
regular = "%d%d%d%d%d?%d?",
webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your-key"
}
匹配以"验证码"开头的消息:
{
channel = "feishu",
regular = "^验证码",
webhook = "https://open.feishu.cn/open-apis/bot/v2/hook/your-id"
}
注意:Lua pattern 不支持 | 语法,匹配多个不同关键词请分别建规则:
{
channel = "dingding",
regular = "腾讯云",
webhook = "https://oapi.dingtalk.com/robot/send?access_token=your-token"
}
{
channel = "dingding",
regular = "阿里云",
webhook = "https://oapi.dingtalk.com/robot/send?access_token=your-token"
}
匹配包含"订单"后跟数字的消息:
{
channel = "feishu",
regular = "订单%d+",
webhook = "https://open.feishu.cn/open-apis/bot/v2/hook/your-id"
}
========== Lua pattern 常用语法 ==========
-- %d 数字 %a 字母 %w 字母数字
-- %s 空白 %l 小写字母 %u 大写字母
-- . 任意字符 * 0次或多次 + 1次或多次
-- ? 0次或1次 ^ 开头 $ 结尾
-- [set] 字符集 % 转义特殊字符
======================================
]]
return {
{
channel = "wecom",
keyword = "all",
webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your-webhook-id"
},
{
channel = "feishu",
keyword = "test",
webhook = "https://open.feishu.cn/open-apis/bot/v2/hook/your-webhook-id"
},
{
channel = "dingding",
keyword = "阿里云",
webhook = "https://oapi.dingtalk.com/robot/send?access_token=your-access-token",
secret = "your-secret"
},
{
channel = "custom_post",
keyword = "百度",
webhook = "https://your-api-endpoint.com/webhook",
content_type = "application/json",
post_body = {
title = "通知标题",
desp = "通知内容: {msg}"
}
}
}