mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-17 11:12:26 +08:00
Compare commits
3 Commits
v2.1.7-rc.
...
06b89b6ca2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06b89b6ca2 | ||
|
|
ea684369a9 | ||
|
|
6053598a03 |
6
.github/ISSUE_TEMPLATE/bug.md
vendored
6
.github/ISSUE_TEMPLATE/bug.md
vendored
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: 报告 Bug
|
name: 报告Bug
|
||||||
about: 反馈 BUG 信息
|
about: 反馈BUG信息
|
||||||
title: "[BUG]"
|
title: "[BUG]"
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: ''
|
||||||
@@ -18,4 +18,4 @@ assignees: ''
|
|||||||
|
|
||||||
|
|
||||||
**使用的版本**
|
**使用的版本**
|
||||||
- SDK 版本:[比如 v0.0.0]
|
- SDK版本: [比如 v0.0.0]
|
||||||
|
|||||||
8
.github/ISSUE_TEMPLATE/feature.md
vendored
8
.github/ISSUE_TEMPLATE/feature.md
vendored
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: API 需求
|
name: API需求
|
||||||
about: 待实现的 API 接口,SDK 的强大离不开社区的帮助,欢迎为项目贡献 PR
|
about: 待实现的API接口,SDK的强大离不开社区的帮助,欢迎为项目贡献PR
|
||||||
title: "[Feature]"
|
title: "[Feature]"
|
||||||
labels: enhancement
|
labels: enhancement
|
||||||
assignees: ''
|
assignees: ''
|
||||||
@@ -8,8 +8,8 @@ assignees: ''
|
|||||||
---
|
---
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
!!!SDK 的强大离不开社区的帮助,欢迎为本项目贡献 PR!!!
|
!!!SDK的强大离不开社区的帮助,欢迎为本项目贡献PR!!!
|
||||||
-->
|
-->
|
||||||
**你想要实现的模块或 API**
|
**你想要实现的模块或API**
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
6
.github/ISSUE_TEMPLATE/question.md
vendored
6
.github/ISSUE_TEMPLATE/question.md
vendored
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: 使用咨询
|
name: 使用咨询
|
||||||
about: 关于 SDK 使用相关的咨询,在使用前请先阅读官方微信文档
|
about: 关于SDK使用相关的咨询,在使用前请先阅读官方微信文档
|
||||||
title: "[咨询]"
|
title: "[咨询]"
|
||||||
labels: question
|
labels: question
|
||||||
assignees: ''
|
assignees: ''
|
||||||
@@ -9,7 +9,7 @@ assignees: ''
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
重要:
|
重要:
|
||||||
1、在使用本 SDK 前请先阅读对应的官方微信 API 文档:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
1、在使用本SDK前请先阅读对应的官方微信API文档:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
||||||
2、本 SDK 部分接口文档:https://silenceper.com/wechat/
|
2、本SDK部分接口文档: https://silenceper.com/wechat/
|
||||||
-->
|
-->
|
||||||
**请描述您的问题**
|
**请描述您的问题**
|
||||||
|
|||||||
16
.github/workflows/go.yml
vendored
16
.github/workflows/go.yml
vendored
@@ -2,9 +2,9 @@ name: Go
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master,release-*,v2,feature/**,fix/** ]
|
branches: [ master,release-*,v2,feature/** ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master,release-*,v2,feature/**,fix/** ]
|
branches: [ master,release-*,v2,feature/** ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
golangci:
|
golangci:
|
||||||
@@ -15,13 +15,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Golang ${{ matrix.go-version }}
|
- name: Setup Golang ${{ matrix.go-version }}
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v4
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
version: v1.52.2
|
version: v1.52.2
|
||||||
@@ -42,12 +42,12 @@ jobs:
|
|||||||
# strategy set
|
# strategy set
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [ '1.16','1.17','1.18','1.19','1.20','1.21','1.22' ]
|
go: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
id: go
|
id: go
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ type PushDataSecVodUpload struct {
|
|||||||
|
|
||||||
// SecVodUploadEvent 短剧媒资上传完成事件
|
// SecVodUploadEvent 短剧媒资上传完成事件
|
||||||
type SecVodUploadEvent struct {
|
type SecVodUploadEvent struct {
|
||||||
MediaID int64 `json:"media_id" xml:"media_id"` // 媒资 id
|
MediaID string `json:"media_id" xml:"media_id"` // 媒资 id
|
||||||
SourceContext string `json:"source_context" xml:"source_context"` // 透传上传接口中开发者设置的值。
|
SourceContext string `json:"source_context" xml:"source_context"` // 透传上传接口中开发者设置的值。
|
||||||
ErrCode int `json:"errcode" xml:"errcode"` // 错误码,上传失败时该值非
|
ErrCode int `json:"errcode" xml:"errcode"` // 错误码,上传失败时该值非
|
||||||
ErrMsg string `json:"errmsg" xml:"errmsg"` // 错误提示
|
ErrMsg string `json:"errmsg" xml:"errmsg"` // 错误提示
|
||||||
@@ -412,7 +412,7 @@ type PushDataSecVodAudit struct {
|
|||||||
|
|
||||||
// SecVodAuditEvent 短剧媒资审核状态事件
|
// SecVodAuditEvent 短剧媒资审核状态事件
|
||||||
type SecVodAuditEvent struct {
|
type SecVodAuditEvent struct {
|
||||||
DramaID int64 `json:"drama_id" xml:"drama_id"` // 剧目 id
|
DramaID string `json:"drama_id" xml:"drama_id"` // 剧目 id
|
||||||
SourceContext string `json:"source_context" xml:"source_context"` // 透传上传接口中开发者设置的值
|
SourceContext string `json:"source_context" xml:"source_context"` // 透传上传接口中开发者设置的值
|
||||||
AuditDetail DramaAuditDetail `json:"audit_detail" xml:"audit_detail"` // 剧目审核结果,单独每一集的审核结果可以根据 drama_id 查询剧集详情得到
|
AuditDetail DramaAuditDetail `json:"audit_detail" xml:"audit_detail"` // 剧目审核结果,单独每一集的审核结果可以根据 drama_id 查询剧集详情得到
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
package message
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/silenceper/wechat/v2/miniprogram/context"
|
|
||||||
"github.com/silenceper/wechat/v2/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// createActivityURL 创建activity_id
|
|
||||||
createActivityURL = "https://api.weixin.qq.com/cgi-bin/message/wxopen/activityid/create?access_token=%s"
|
|
||||||
// SendUpdatableMsgURL 修改动态消息
|
|
||||||
setUpdatableMsgURL = "https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token=%s"
|
|
||||||
)
|
|
||||||
|
|
||||||
// UpdatableTargetState 动态消息状态
|
|
||||||
type UpdatableTargetState int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// TargetStateNotStarted 未开始
|
|
||||||
TargetStateNotStarted UpdatableTargetState = 0
|
|
||||||
// TargetStateStarted 已开始
|
|
||||||
TargetStateStarted UpdatableTargetState = 1
|
|
||||||
// TargetStateFinished 已结束
|
|
||||||
TargetStateFinished UpdatableTargetState = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
// UpdatableMessage 动态消息
|
|
||||||
type UpdatableMessage struct {
|
|
||||||
*context.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewUpdatableMessage 实例化
|
|
||||||
func NewUpdatableMessage(ctx *context.Context) *UpdatableMessage {
|
|
||||||
return &UpdatableMessage{
|
|
||||||
Context: ctx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateActivityID 创建activity_id
|
|
||||||
func (updatableMessage *UpdatableMessage) CreateActivityID() (res CreateActivityIDResponse, err error) {
|
|
||||||
accessToken, err := updatableMessage.GetAccessToken()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
uri := fmt.Sprintf(createActivityURL, accessToken)
|
|
||||||
response, err := util.HTTPGet(uri)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = util.DecodeWithError(response, &res, "CreateActivityID")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUpdatableMsg 修改动态消息
|
|
||||||
func (updatableMessage *UpdatableMessage) SetUpdatableMsg(activityID string, targetState UpdatableTargetState, template UpdatableMsgTemplate) (err error) {
|
|
||||||
accessToken, err := updatableMessage.GetAccessToken()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
uri := fmt.Sprintf(setUpdatableMsgURL, accessToken)
|
|
||||||
data := SendUpdatableMsgReq{
|
|
||||||
ActivityID: activityID,
|
|
||||||
TargetState: targetState,
|
|
||||||
TemplateInfo: template,
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := util.PostJSON(uri, data)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return util.DecodeWithCommonError(response, "SendUpdatableMsg")
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateActivityIDResponse 创建activity_id 返回
|
|
||||||
type CreateActivityIDResponse struct {
|
|
||||||
util.CommonError
|
|
||||||
|
|
||||||
ActivityID string `json:"activity_id"`
|
|
||||||
ExpirationTime int64 `json:"expiration_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdatableMsgTemplate 动态消息模板
|
|
||||||
type UpdatableMsgTemplate struct {
|
|
||||||
ParameterList []UpdatableMsgParameter `json:"parameter_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdatableMsgParameter 动态消息参数
|
|
||||||
type UpdatableMsgParameter struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Value string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SendUpdatableMsgReq 修改动态消息参数
|
|
||||||
type SendUpdatableMsgReq struct {
|
|
||||||
ActivityID string `json:"activity_id"`
|
|
||||||
TemplateInfo UpdatableMsgTemplate `json:"template_info"`
|
|
||||||
TargetState UpdatableTargetState `json:"target_state"`
|
|
||||||
}
|
|
||||||
@@ -161,8 +161,3 @@ func (miniProgram *MiniProgram) GetMiniDrama() *minidrama.MiniDrama {
|
|||||||
func (miniProgram *MiniProgram) GetRedPacketCover() *redpacketcover.RedPacketCover {
|
func (miniProgram *MiniProgram) GetRedPacketCover() *redpacketcover.RedPacketCover {
|
||||||
return redpacketcover.NewRedPacketCover(miniProgram.ctx)
|
return redpacketcover.NewRedPacketCover(miniProgram.ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUpdatableMessage 小程序动态消息
|
|
||||||
func (miniProgram *MiniProgram) GetUpdatableMessage() *message.UpdatableMessage {
|
|
||||||
return message.NewUpdatableMessage(miniProgram.ctx)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -79,10 +79,6 @@ type sendRequest struct {
|
|||||||
Mpnews map[string]interface{} `json:"mpnews,omitempty"`
|
Mpnews map[string]interface{} `json:"mpnews,omitempty"`
|
||||||
// 发送语音
|
// 发送语音
|
||||||
Voice map[string]interface{} `json:"voice,omitempty"`
|
Voice map[string]interface{} `json:"voice,omitempty"`
|
||||||
// 发送视频
|
|
||||||
Mpvideo map[string]interface{} `json:"mpvideo,omitempty"`
|
|
||||||
// 发送图片-预览使用
|
|
||||||
Image map[string]interface{} `json:"image,omitempty"`
|
|
||||||
// 发送图片
|
// 发送图片
|
||||||
Images *Image `json:"images,omitempty"`
|
Images *Image `json:"images,omitempty"`
|
||||||
// 发送卡券
|
// 发送卡券
|
||||||
@@ -187,13 +183,7 @@ func (broadcast *Broadcast) SendImage(user *User, images *Image) (*Result, error
|
|||||||
ToUser: nil,
|
ToUser: nil,
|
||||||
MsgType: MsgTypeImage,
|
MsgType: MsgTypeImage,
|
||||||
}
|
}
|
||||||
if broadcast.preview {
|
req.Images = images
|
||||||
req.Image = map[string]interface{}{
|
|
||||||
"media_id": images.MediaIDs[0],
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
req.Images = images
|
|
||||||
}
|
|
||||||
req, sendURL := broadcast.chooseTagOrOpenID(user, req)
|
req, sendURL := broadcast.chooseTagOrOpenID(user, req)
|
||||||
url := fmt.Sprintf("%s?access_token=%s", sendURL, ak)
|
url := fmt.Sprintf("%s?access_token=%s", sendURL, ak)
|
||||||
data, err := util.PostJSON(url, req)
|
data, err := util.PostJSON(url, req)
|
||||||
@@ -215,7 +205,7 @@ func (broadcast *Broadcast) SendVideo(user *User, mediaID string, title, descrip
|
|||||||
ToUser: nil,
|
ToUser: nil,
|
||||||
MsgType: MsgTypeVideo,
|
MsgType: MsgTypeVideo,
|
||||||
}
|
}
|
||||||
req.Mpvideo = map[string]interface{}{
|
req.Voice = map[string]interface{}{
|
||||||
"media_id": mediaID,
|
"media_id": mediaID,
|
||||||
"title": title,
|
"title": title,
|
||||||
"description": description,
|
"description": description,
|
||||||
|
|||||||
Reference in New Issue
Block a user