feat: able to send alert message via message pusher (close #993)

This commit is contained in:
JustSong
2024-03-10 19:16:06 +08:00
parent 71c61365eb
commit 5b50eb94e5
12 changed files with 161 additions and 6 deletions

22
common/message/main.go Normal file
View File

@@ -0,0 +1,22 @@
package message
import (
"fmt"
"github.com/songquanpeng/one-api/common/config"
)
const (
ByAll = "all"
ByEmail = "email"
ByMessagePusher = "message_pusher"
)
func Notify(by string, title string, description string, content string) error {
if by == ByEmail {
return SendEmail(title, config.RootUserEmail, content)
}
if by == ByMessagePusher {
return SendMessage(title, description, content)
}
return fmt.Errorf("unknown notify method: %s", by)
}