Skip to content

Commit 61ad4c9

Browse files
authored
Merge pull request #607 from ArtisanCloud/develop
Develop
2 parents f6a1022 + 4460619 commit 61ad4c9

File tree

5 files changed

+84
-10
lines changed

5 files changed

+84
-10
lines changed

main.go

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77
"strconv"
88

99
fmt2 "github.com/ArtisanCloud/PowerLibs/v3/fmt"
10+
1011
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
1112
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
1213
"github.com/ArtisanCloud/PowerWeChat/v3/src/miniProgram"
1314
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount"
1415
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/templateMessage/request"
1516
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform"
17+
"github.com/ArtisanCloud/PowerWeChat/v3/src/openWork"
1618
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment"
1719
"github.com/ArtisanCloud/PowerWeChat/v3/src/work"
1820
"go.opentelemetry.io/otel"
@@ -29,6 +31,8 @@ func GetOfficialConfig() *officialAccount.UserConfig {
2931
Log: officialAccount.Log{
3032
Level: "debug",
3133
Stdout: false,
34+
File: "/Users/michaelhu/wechat/official-account/info.log",
35+
Error: "/Users/michaelhu/wechat/official-account/error.log",
3236
},
3337
Http: officialAccount.Http{
3438
ProxyURI: "",
@@ -40,7 +44,7 @@ func GetOfficialConfig() *officialAccount.UserConfig {
4044
Password: "",
4145
DB: 1,
4246
}),
43-
HttpDebug: false,
47+
HttpDebug: true,
4448
Debug: false,
4549
}
4650
}
@@ -55,8 +59,10 @@ func GetWorkConfig() *work.UserConfig {
5559
ResponseType: os.Getenv("array"),
5660
Log: work.Log{
5761
Level: "debug",
58-
File: "./wechat/info.log",
59-
Error: "./wechat/error.log",
62+
//File: "./wechat/info.log",
63+
//Error: "./wechat/error.log",
64+
File: "/Users/michaelhu/wechat/work/info.log",
65+
Error: "/Users/michaelhu/wechat/work/error.log",
6066
ENV: os.Getenv("work.env"),
6167
},
6268

@@ -101,8 +107,10 @@ func GetPaymentConfig() *payment.UserConfig {
101107
ResponseType: os.Getenv("array"),
102108
Log: payment.Log{
103109
Level: "debug",
104-
File: "./wechat/info.log",
105-
Error: "./wechat/error.log",
110+
//File: "./wechat/info.log",
111+
//Error: "./wechat/error.log",
112+
File: "/Users/michaelhu/wechat/payment/info.log",
113+
Error: "/Users/michaelhu/wechat/payment/error.log",
106114
},
107115
Http: payment.Http{
108116
Timeout: 30.0,
@@ -135,8 +143,8 @@ func GetMiniProgramConfig() *miniProgram.UserConfig {
135143
ResponseType: os.Getenv("array"),
136144
Log: miniProgram.Log{
137145
Level: "debug",
138-
File: "./wechat/info.log",
139-
Error: "./wechat/error.log",
146+
File: "/Users/michaelhu/wechat/mini-program/info.log",
147+
Error: "/Users/michaelhu/wechat/mini-program/error.log",
140148
},
141149
Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
142150
Addrs: []string{"127.0.0.1:6379"},
@@ -162,8 +170,10 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig {
162170
ResponseType: os.Getenv("array"),
163171
Log: openPlatform.Log{
164172
Level: "debug",
165-
File: "./wechat/info.log",
166-
Error: "./wechat/error.log",
173+
//File: "./wechat/info.log",
174+
//Error: "./wechat/error.log",
175+
File: "/Users/michaelhu/wechat/platform/info.log",
176+
Error: "/Users/michaelhu/wechat/platform/error.log",
167177
},
168178
Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
169179
Addrs: []string{"127.0.0.1:6379"},
@@ -181,6 +191,28 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig {
181191
}
182192
}
183193

194+
func GetOpenWorkConfig() *openWork.UserConfig {
195+
return &openWork.UserConfig{
196+
AppID: "123",
197+
Secret: "321",
198+
AuthCode: "123",
199+
AESKey: "321",
200+
ResponseType: os.Getenv("array"),
201+
202+
Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
203+
Addrs: []string{"127.0.0.1:6379"},
204+
Password: "",
205+
DB: 1,
206+
}),
207+
208+
// OAuth: "",
209+
// HttpDebug: "",
210+
// Debug: "",
211+
// NotifyURL: "",
212+
// Sandbox: "",
213+
}
214+
}
215+
184216
func initTracer() {
185217
tp := trace.NewTracerProvider()
186218
// Set Global Tracer Provider
@@ -252,11 +284,20 @@ func main() {
252284
}
253285
fmt2.Dump("miniprogram config:", miniProgramApp.GetConfig().All())
254286

255-
// init miniProgram app
287+
// init openplatform app
256288
configOpenPlatform := GetOpenPlatformConfig()
257289
openPlatform, err := openPlatform.NewOpenPlatform(configOpenPlatform)
258290
if err != nil {
259291
fmt.Println(err.Error())
260292
}
261293
fmt2.Dump("openPlatform config:", openPlatform.GetConfig().All())
294+
295+
// init openwork app
296+
configOpenWork := GetOpenWorkConfig()
297+
openWork, err := openWork.NewOpenWork(configOpenWork)
298+
if err != nil {
299+
fmt.Println(err.Error())
300+
}
301+
fmt2.Dump("openPlatform config:", openWork.GetConfig().All())
302+
262303
}

src/work/externalContact/messageTemplate/client.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ func (comp *Client) SendWelcomeMsg(ctx context.Context, options *request.Request
9292
return result, err
9393
}
9494

95+
// 提醒成员群发
96+
// https://developer.work.weixin.qq.com/document/path/97618
97+
func (comp *Client) RemindGroupMsgSend(ctx context.Context, options *request.RequestRemindGroupMsgSend) (*response2.ResponseWork, error) {
98+
99+
result := &response2.ResponseWork{}
100+
101+
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/remind_groupmsg_send", options, nil, nil, result)
102+
103+
return result, err
104+
}
105+
106+
// 停止企业群发
107+
// https://developer.work.weixin.qq.com/document/path/97619
108+
func (comp *Client) CancelGroupMsgSend(ctx context.Context, options *request.RequestCancelGroupMsgSend) (*response2.ResponseWork, error) {
109+
110+
result := &response2.ResponseWork{}
111+
112+
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/cancel_groupmsg_send", options, nil, nil, result)
113+
114+
return result, err
115+
}
116+
95117
func (comp *Client) formatMessage(ctx context.Context, data *object.HashMap) (*object.HashMap, error) {
96118
params := *data
97119

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package request
2+
3+
type RequestCancelGroupMsgSend struct {
4+
MsgID string `json:"msgid"`
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package request
2+
3+
type RequestRemindGroupMsgSend struct {
4+
MsgID string `json:"msgid"`
5+
}

src/work/server/handlers/models/event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const (
2323
CALLBACK_EVENT_LOCATION_SELECT = "location_select"
2424
CALLBACK_EVENT_OPEN_APPROVAL_CHANGE = "open_approval_change"
2525
CALLBACK_EVENT_SHARE_AGENT_CHANGE = "share_agent_change"
26+
CALLBACK_EVENT_TEMPLATE_CARD_EVENT = "template_card_event"
2627
CALLBACK_EVENT_TEMPLATE_CARD_MENU_EVENT = "template_card_menu_event"
2728
CALLBACK_EVENT_SYS_APPROVAL_CHANGE = "sys_approval_change"
2829
CALLBACK_EVENT_KF_MSG_OR_EVENT = "kf_msg_or_event"

0 commit comments

Comments
 (0)