1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00

feat: improve comment and upgrade golang version 1.16 (#604)

* feat: improve action config and code comment

* feat: improve comment and upgrade golang version 1.16

* feat: improve import
This commit is contained in:
houseme
2022-08-23 10:13:24 +08:00
committed by GitHub
parent df62164811
commit a8f7a24ff6
13 changed files with 84 additions and 64 deletions

View File

@@ -228,7 +228,7 @@ func (csm *Manager) UploadHeadImg(kfAccount, fileName string) (err error) {
return
}
//SendTypingStatus 下发客服输入状态给用户
// SendTypingStatus 下发客服输入状态给用户
func (csm *Manager) SendTypingStatus(openid string, cmd TypingStatus) (err error) {
var accessToken string
accessToken, err = csm.GetAccessToken()

View File

@@ -302,6 +302,7 @@ type reqBatchGetMaterial struct {
}
// BatchGetMaterial 批量获取永久素材
//
//reference:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Get_materials_list.html
func (material *Material) BatchGetMaterial(permanentMaterialType PermanentMaterialType, offset, count int64) (list ArticleList, err error) {
var accessToken string

View File

@@ -151,8 +151,8 @@ func (tpl *Subscribe) Delete(templateID string) (err error) {
// PublicTemplateCategory 公众号类目
type PublicTemplateCategory struct {
ID int `json:"id"` //类目ID
Name string `json:"name"` //类目的中文名
ID int `json:"id"` // 类目ID
Name string `json:"name"` // 类目的中文名
}
type resSubscribeCategoryList struct {
@@ -186,13 +186,13 @@ func (tpl *Subscribe) GetCategory() (categoryList []*PublicTemplateCategory, err
type PublicTemplateKeyWords struct {
KeyWordsID int `json:"kid"` // 关键词 id
Name string `json:"name"` // 关键词内容
Example string `json:"example"` //关键词内容对应的示例
Example string `json:"example"` // 关键词内容对应的示例
Rule string `json:"rule"` // 参数类型
}
type resPublicTemplateKeyWordsList struct {
util.CommonError
KeyWordsList []*PublicTemplateKeyWords `json:"data"` //关键词列表
KeyWordsList []*PublicTemplateKeyWords `json:"data"` // 关键词列表
}
// GetPubTplKeyWordsByID 获取模板中的关键词
@@ -227,8 +227,8 @@ type PublicTemplateTitle struct {
type resPublicTemplateTitleList struct {
util.CommonError
Count int `json:"count"` //公共模板列表总数
TemplateTitleList []*PublicTemplateTitle `json:"data"` //模板标题列表
Count int `json:"count"` // 公共模板列表总数
TemplateTitleList []*PublicTemplateTitle `json:"data"` // 模板标题列表
}
// GetPublicTemplateTitleList 获取类目下的公共模板

View File

@@ -5,7 +5,7 @@ import (
"encoding/xml"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"reflect"
"runtime/debug"
@@ -13,11 +13,11 @@ import (
"strings"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
"github.com/silenceper/wechat/v2/officialaccount/context"
"github.com/silenceper/wechat/v2/officialaccount/message"
"github.com/silenceper/wechat/v2/util"
"github.com/tidwall/gjson"
)
// Server struct
@@ -106,7 +106,7 @@ func (srv *Server) handleRequest() (reply *message.Reply, err error) {
srv.isSafeMode = true
}
//set request contentType
// set request contentType
contentType := srv.Request.Header.Get("Content-Type")
srv.isJSONContent = strings.Contains(contentType, "application/json")
@@ -162,7 +162,7 @@ func (srv *Server) getMessage() (interface{}, error) {
return nil, fmt.Errorf("消息解密失败, err=%v", err)
}
} else {
rawXMLMsgBytes, err = ioutil.ReadAll(srv.Request.Body)
rawXMLMsgBytes, err = io.ReadAll(srv.Request.Body)
if err != nil {
return nil, fmt.Errorf("从body中解析xml失败, err=%v", err)
}
@@ -193,7 +193,7 @@ func (srv *Server) parseRequestMessage(rawXMLMsgBytes []byte) (msg *message.MixM
err = xml.Unmarshal(rawXMLMsgBytes, msg)
return
}
//parse json
// parse json
err = json.Unmarshal(rawXMLMsgBytes, msg)
if err != nil {
return