mirror of
https://github.com/silenceper/wechat.git
synced 2026-03-01 00:35:26 +08:00
Compare commits
4 Commits
2fe51afe13
...
64c3bb60ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64c3bb60ba | ||
|
|
b70ecd93a7 | ||
|
|
e7ff8d90ed | ||
|
|
5467bc6245 |
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
golangci:
|
golangci:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [ '1.16','1.17','1.18','1.19','1.20' ]
|
go-version: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
||||||
name: golangci-lint
|
name: golangci-lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
# strategy set
|
# strategy set
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [ '1.16','1.17','1.18','1.19','1.20' ]
|
go: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|||||||
10
cache/redis.go
vendored
10
cache/redis.go
vendored
@@ -8,6 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Redis .redis cache
|
// Redis .redis cache
|
||||||
|
// Deprecated: user defined implementation cache、ContextCache interface
|
||||||
|
// The implementation was officially removed in v2.1.6
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
conn redis.UniversalClient
|
conn redis.UniversalClient
|
||||||
@@ -35,12 +37,12 @@ func NewRedis(ctx context.Context, opts *RedisOpts) *Redis {
|
|||||||
return &Redis{ctx: ctx, conn: conn}
|
return &Redis{ctx: ctx, conn: conn}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConn 设置conn
|
// SetConn 设置 conn
|
||||||
func (r *Redis) SetConn(conn redis.UniversalClient) {
|
func (r *Redis) SetConn(conn redis.UniversalClient) {
|
||||||
r.conn = conn
|
r.conn = conn
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRedisCtx 设置redis ctx 参数
|
// SetRedisCtx 设置 redis ctx 参数
|
||||||
func (r *Redis) SetRedisCtx(ctx context.Context) {
|
func (r *Redis) SetRedisCtx(ctx context.Context) {
|
||||||
r.ctx = ctx
|
r.ctx = ctx
|
||||||
}
|
}
|
||||||
@@ -69,12 +71,12 @@ func (r *Redis) SetContext(ctx context.Context, key string, val interface{}, tim
|
|||||||
return r.conn.SetEX(ctx, key, val, timeout).Err()
|
return r.conn.SetEX(ctx, key, val, timeout).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsExist 判断key是否存在
|
// IsExist 判断 key 是否存在
|
||||||
func (r *Redis) IsExist(key string) bool {
|
func (r *Redis) IsExist(key string) bool {
|
||||||
return r.IsExistContext(r.ctx, key)
|
return r.IsExistContext(r.ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsExistContext 判断key是否存在
|
// IsExistContext 判断 key 是否存在
|
||||||
func (r *Redis) IsExistContext(ctx context.Context, key string) bool {
|
func (r *Redis) IsExistContext(ctx context.Context, key string) bool {
|
||||||
result, _ := r.conn.Exists(ctx, key).Result()
|
result, _ := r.conn.Exists(ctx, key).Result()
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ const (
|
|||||||
getGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/get?access_token=%s"
|
getGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/get?access_token=%s"
|
||||||
// delGroupWelcomeTemplateURL 删除入群欢迎语素材
|
// delGroupWelcomeTemplateURL 删除入群欢迎语素材
|
||||||
delGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/del?access_token=%s"
|
delGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/del?access_token=%s"
|
||||||
|
// remindGroupMsgSendURL 提醒成员群发
|
||||||
|
remindGroupMsgSendURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remind_groupmsg_send?access_token=%s"
|
||||||
|
// cancelGroupMsgSendURL 停止企业群发
|
||||||
|
cancelGroupMsgSendURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/cancel_groupmsg_send?access_token=%s"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddMsgTemplateRequest 创建企业群发请求
|
// AddMsgTemplateRequest 创建企业群发请求
|
||||||
@@ -422,3 +426,47 @@ func (r *Client) DelGroupWelcomeTemplate(req *DelGroupWelcomeTemplateRequest) er
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemindGroupMsgSendRequest 提醒成员群发请求
|
||||||
|
type RemindGroupMsgSendRequest struct {
|
||||||
|
MsgID string `json:"msgid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemindGroupMsgSend 提醒成员群发
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/97610
|
||||||
|
func (r *Client) RemindGroupMsgSend(req *RemindGroupMsgSendRequest) error {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(remindGroupMsgSendURL, accessToken), req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return util.DecodeWithCommonError(response, "RemindGroupMsgSend")
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelGroupMsgSendRequest 停止企业群发请求
|
||||||
|
type CancelGroupMsgSendRequest struct {
|
||||||
|
MsgID string `json:"msgid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelGroupMsgSend 提醒成员群发
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/97611
|
||||||
|
func (r *Client) CancelGroupMsgSend(req *CancelGroupMsgSendRequest) error {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(cancelGroupMsgSendURL, accessToken), req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return util.DecodeWithCommonError(response, "CancelGroupMsgSend")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user