https://github.com/zggsong/message
Send notification messages (bark, mail), and support real-time monitoring of configuration file changes
https://github.com/zggsong/message
bark golang mail
Last synced: about 1 year ago
JSON representation
Send notification messages (bark, mail), and support real-time monitoring of configuration file changes
- Host: GitHub
- URL: https://github.com/zggsong/message
- Owner: ZGGSONG
- License: mit
- Created: 2023-02-15T03:01:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-15T04:10:35.000Z (over 3 years ago)
- Last Synced: 2025-02-14T08:34:02.348Z (over 1 year ago)
- Topics: bark, golang, mail
- Language: Go
- Homepage: https://pkg.go.dev/github.com/zggsong/message
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/zggsong/message)

[](https://pkg.go.dev/mod/github.com/zggsong/message)
Send notification messages (bark, mail), and support real-time monitoring of configuration file changes
## Install
```shell
go get github.com/zggsong/message
```
## Usage
```shell
touch config.yml
```
write the following contents to the file
```yml
message:
enabled: true #是否开启发送信息
type: "bark" #选择发送信息方式
bark:
url: ""
key: ""
mail:
host: "" #例:smtp.qq.com
protocol: #Optional
port: #例:587
username: ""
password: ""
from_name: "" #"zgg "
to: "" #分号内空格分开
```
> [Bark is an iOS App which allows you to push custom notifications to your iPhone](https://github.com/Finb/Bark)
```go
func main() {
/*配置初始化*/
conf, err := message.InitConfig()
if err != nil {
log.Fatalf("failed to initialize config: %v", err)
}
message.GLO_CONF = conf
/*测试发送*/
var s = message.Service{Body: message.Body{
Title: "test title",
Content: "this is content, time is " + time.Now().Format("2006-01-02 15:04:05"),
}}
if err = s.Run(); err != nil {
log.Fatalf("failed to send message: %v", err)
} else {
log.Printf("send message successfully...")
}
/*监听配置*/
for {
_conf := <-message.GLO_CONF_CH
log.Printf("config changed: %v", _conf)
message.GLO_CONF = _conf
}
}
```
## License
Message © [zggsong](https://github.com/zggsong), Follow [MIT](https://github.com/zggsong/message/blob/master/LICENSE) certificate.