Files
PMail/server/hooks/base.go
J3n5en f2a642bf79 feat: Add Telegram push hook functionality and configuration options
- 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
2023-08-28 14:38:09 +08:00

31 lines
806 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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(),
}
}