mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-18 09:24:07 +00:00
feat: able to send alert message via message pusher (close #993)
This commit is contained in:
22
common/message/main.go
Normal file
22
common/message/main.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user