mirror of
https://github.com/Jinnrry/PMail.git
synced 2025-10-05 23:36:50 +08:00

- Add "tgChatId" and "tgBotToken" fields to configuration files - Modify "config.go" to include new configuration fields - Implement Telegram push hook functionality in "telegram_push.go" - Add test file "telegram_push_test.go" to test Telegram push hook functionality
31 lines
806 B
Go
31 lines
806 B
Go
package hooks
|
||
|
||
import (
|
||
"pmail/dto"
|
||
"pmail/dto/parsemail"
|
||
"pmail/hooks/telegram_push"
|
||
"pmail/hooks/wechat_push"
|
||
)
|
||
|
||
type EmailHook interface {
|
||
// SendBefore 邮件发送前的数据
|
||
SendBefore(ctx *dto.Context, email *parsemail.Email)
|
||
// SendAfter 邮件发送后的数据,err是每个收信服务器的错误信息
|
||
SendAfter(ctx *dto.Context, email *parsemail.Email, err map[string]error)
|
||
// ReceiveParseBefore 接收到邮件,解析之前的原始数据
|
||
ReceiveParseBefore(email []byte)
|
||
// ReceiveParseAfter 接收到邮件,解析之后的结构化数据
|
||
ReceiveParseAfter(email *parsemail.Email)
|
||
}
|
||
|
||
// HookList
|
||
var HookList []EmailHook
|
||
|
||
// Init 这里注册hook对象
|
||
func Init() {
|
||
HookList = []EmailHook{
|
||
wechat_push.NewWechatPushHook(),
|
||
telegram_push.NewTelegramPushHook(),
|
||
}
|
||
}
|