Skip to content

Commit

Permalink
Merge pull request veops#2 from ttktatakai/main
Browse files Browse the repository at this point in the history
docs: add shields tag && rename module name
  • Loading branch information
pycook authored Nov 29, 2023
2 parents c799b5b + 86cb9ef commit afabda1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Messenger

<h3 align="center">Messenger</h3>
<p align="center">
<a href="https://github.com/veops/messenger/blob/main/LICENSE"><img src="https://img.shields.io/github/license/veops/messenger" alt="Apache License 2.0"></a>
<a href=""><img src="https://img.shields.io/badge/Go-%3E%3D%201.18-%23007d9c" alt="go>=1.18"></a>
<a href="https://goreportcard.com/report/github.com/veops/messenger"><img src="https://goreportcard.com/badge/github.com/veops/messenger" alt="API"></a>
</p>
messenger是一个简单轻量的消息发送服务,支持邮件、微信、飞书、钉钉,同时支持配置动态修改,使用简单灵活

---

## 安装

### 源码
Expand Down Expand Up @@ -30,18 +36,18 @@ docker run -d --name messenger -p 8888:8888 -v $(pwd)/conf:/messenger/conf --res

参数说明:

| 参数 | 是否必须 | 类型 | 说明 |
| :----- | :------- | :----- | :----------------------------------------------------- |
| sender || string | sender名称:发送消息具体sender的名称,对应conf中的name |
| msgtype | 是 | string | 消息内容类型:每种消息发送方式支持多种消息内容类型,各发送方式支持的消息内容类型参考如下 <br> email: text/plain text/html <br> wechatBot: [微信机器人](https://developer.work.weixin.qq.com/document/path/99110#%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F) &emsp;&emsp;&emsp;&nbsp; wechatApp:[微信应用](https://developer.work.weixin.qq.com/document/path/90236#%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B) <br> feishuBot:[飞书机器人](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#5a997364) &emsp;&emsp;&emsp;&nbsp; feishuApp:[飞书应用](https://open.feishu.cn/document/server-docs/im-v1/message-content-description/create_json#3c92befd) <br> dingdingBot:[钉钉机器人](https://open.dingtalk.com/document/orgapp/custom-robot-access#title-72m-8ag-pqw) &emsp;&emsp; dingdingApp:[钉钉应用](https://open.dingtalk.com/document/orgapp/types-of-messages-sent-by-robots?spm)|
|content||string|消息内容:邮件可直接填写内容字符串,其他消息内容本身具有结构,传入其JSON序列化之后的字符串,如微信应用的文本消息填写`{"content":"my content"}`序列化后字符串|
|title||string|消息标题:仅用于 email 类型|
|tos||[]string|接收人列表:发送邮件、应用消息时需要填写|
|ccs||[]string|抄送人列表:仅用于 email 类型|
|extra||string|额外参数:通常情况下您只需要关注消息内容类型和其内容发送人,但是当您需要传递一些额外参数时,比如微信应用开启重复检查和检查时间间隔,可以将extra设置为`{"enable_duplicate_check":1, "duplicate_check_interval": 1800}`序列化后字符串|
|sync||bool|同步发送:默认情况下,发送请求接受成功即返回200,消息会异步发送,若sync为true则会同步等待消息发送结果并返回|
|simple|否|bool|简单内容:默认情况下,消息内容是json字符串(参考content参数),对于简单的消息类型text和markdown可设置simple=true,此时content仅填写内容字符串本身即可,如`my content`。<br>支持的消息类型(msgtype)<br>text: wechatBot wechatApp feishuBot feishuApp dingdingBot dingdingApp<br>markdown: wechatBot wechatApp dingdingBot dingdingApp
|ats||[]string|@列表: 使用@all代表@所有人; 支持wechatBot, feishuBot, dingdingBot |
| 参数 | 是否必须 | 类型 | 说明 |
| :------ | :------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sender || string | sender名称:发送消息具体sender的名称,对应conf中的name |
| msgtype | 是 | string | 消息内容类型:每种消息发送方式支持多种消息内容类型,各发送方式支持的消息内容类型参考如下 <br> email: text/plain text/html <br> wechatBot: [微信机器人](https://developer.work.weixin.qq.com/document/path/99110#%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F) &emsp;&emsp;&emsp;&nbsp; wechatApp:[微信应用](https://developer.work.weixin.qq.com/document/path/90236#%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B) <br> feishuBot:[飞书机器人](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#5a997364) &emsp;&emsp;&emsp;&nbsp; feishuApp:[飞书应用](https://open.feishu.cn/document/server-docs/im-v1/message-content-description/create_json#3c92befd) <br> dingdingBot:[钉钉机器人](https://open.dingtalk.com/document/orgapp/custom-robot-access#title-72m-8ag-pqw) &emsp;&emsp; dingdingApp:[钉钉应用](https://open.dingtalk.com/document/orgapp/types-of-messages-sent-by-robots?spm) |
| content || string | 消息内容:邮件可直接填写内容字符串,其他消息内容本身具有结构,传入其JSON序列化之后的字符串,如微信应用的文本消息填写`{"content":"my content"}`序列化后字符串 |
| title || string | 消息标题:仅用于 email 类型 |
| tos || []string | 接收人列表:发送邮件、应用消息时需要填写 |
| ccs || []string | 抄送人列表:仅用于 email 类型 |
| extra | 否 | string | 额外参数:通常情况下您只需要关注消息内容类型和其内容发送人,但是当您需要传递一些额外参数时,比如微信应用开启重复检查和检查时间间隔,可以将extra设置为`{"enable_duplicate_check":1, "duplicate_check_interval": 1800}`序列化后字符串 |
| sync || bool | 同步发送:默认情况下,发送请求接受成功即返回200,消息会异步发送,若sync为true则会同步等待消息发送结果并返回 |
| simple || bool | 简单内容:默认情况下,消息内容是json字符串(参考content参数),对于简单的消息类型text和markdown可设置simple=true,此时content仅填写内容字符串本身即可,如`my content`。<br>支持的消息类型(msgtype)<br>text: wechatBot wechatApp feishuBot feishuApp dingdingBot dingdingApp<br>markdown: wechatBot wechatApp dingdingBot dingdingApp |
| ats || []string | @列表: 使用@all代表@所有人; 支持wechatBot, feishuBot, dingdingBot |

返回结果:
```json
Expand Down Expand Up @@ -123,9 +129,9 @@ func main() {

参数说明:

| 参数(请求体) | 是否必须 | 类型 | 说明 |
| :----- | :------- | :----- | :----------------------------------------------------- |
|body||json|请求body为您的sender配置,如`{"wechatBot": [{"name": "yourSenderName", "url": "https://xxx"}]`<br>POST:同类型配置会被全部覆盖<br>PUT:同类型同名称的配置会被更新,新配置将被添加<br>DELETE:同类型同名称配置将被删除|
| 参数(请求体) | 是否必须 | 类型 | 说明 |
| :------------- | :------- | :--- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| body || json | 请求body为您的sender配置,如`{"wechatBot": [{"name": "yourSenderName", "url": "https://xxx"}]`<br>POST:同类型配置会被全部覆盖<br>PUT:同类型同名称的配置会被更新,新配置将被添加<br>DELETE:同类型同名称配置将被删除 |

返回结果:
```json
Expand All @@ -148,10 +154,10 @@ func main() {

参数说明:

| 参数 | 是否必须 | 类型 | 说明 |
| :----- | :------- | :----- | :------------ |
|sender||string|查询用户id时使用的sender名称|
|phone||string|手机号|
| 参数 | 是否必须 | 类型 | 说明 |
| :----- | :------- | :----- | :--------------------------- |
| sender || string | 查询用户id时使用的sender名称 |
| phone || string | 手机号 |

返回结果:
```json
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
module messenger
module github.com/veops/messenger

go 1.20

require (
github.com/go-resty/resty/v2 v2.7.0
github.com/jinzhu/copier v0.4.0
github.com/knadh/koanf v1.5.0
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
)
Expand Down Expand Up @@ -47,5 +46,4 @@ require (
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
moul.io/http2curl v1.0.0
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hjson/hjson-go/v4 v4.0.0 h1:wlm6IYYqHjOdXH1gHev4VoXCaW20HdQAGCxdOEEg2cs=
github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
Expand Down Expand Up @@ -466,7 +464,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
moul.io/http2curl v1.0.0 h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8=
moul.io/http2curl v1.0.0/go.mod h1:f6cULg+e4Md/oW1cYmwW4IWQOVl2lGbmCNGOHvzX2kE=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/gin-gonic/gin"
"golang.org/x/sync/errgroup"

"messenger/global"
"messenger/middleware"
"messenger/send"
"github.com/veops/messenger/global"
"github.com/veops/messenger/middleware"
"github.com/veops/messenger/send"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion send/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/samber/lo"
"github.com/spf13/cast"

"messenger/global"
"github.com/veops/messenger/global"
)

const (
Expand Down

0 comments on commit afabda1

Please sign in to comment.