From c8c73e0cbb603085a38e8b8d9c4debcac76aa1d4 Mon Sep 17 00:00:00 2001 From: Xavier <34981520+Xavier9896@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:28:58 +0800 Subject: [PATCH] feat: Group support sending emoticon messages (#552) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. #501 添加了表情支持,relations.go 中遗漏了对应方法添加 2. 部分文档未对 表情、视频 api 文档进行维护 --- docs/message.md | 22 +++++++++++++++++++++- docs/user.md | 27 +++++++++++++++++++++++++++ relations.go | 11 ++++++++--- user.go | 2 +- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/docs/message.md b/docs/message.md index f55b376..7523649 100644 --- a/docs/message.md +++ b/docs/message.md @@ -174,14 +174,34 @@ msg.IsSendByGroup() msg.ReplyText("hello") ``` +#### 回复表情信息 + +```go +// 如果你不知道表情 md5 值但你有原文件 +emoticon, _ := os.Open("your Emoticon path") +defer emoticon.Close() +msg.ReplyEmoticon("", emoticon) + +// 如果你有表情 md5,并且微信服务器包含该表情 +msg.ReplyEmoticon("md5 string", nil) +``` + #### 回复图片消息 ```go -img, _ := os.Open("your file path") +img, _ := os.Open("your img path") defer img.Close() msg.ReplyImage(img) ``` +#### 回复视频消息 + +```go +video, _ := os.Open("your video path") +defer video.Close() +msg.ReplyVideo(video) +``` + #### 回复文件消息 ```go diff --git a/docs/user.md b/docs/user.md index dbd3755..f4e0f54 100644 --- a/docs/user.md +++ b/docs/user.md @@ -606,6 +606,33 @@ group.SendImage(img) +#### 发送表情信息 + +```go +// 如果你不知道表情 md5 值但你有原文件 +emoticon, _ := os.Open("your Emoticon path") + +defer emoticon.Close() + +group.SendEmoticon("", emoticon) + +// 如果你有表情 md5,并且微信服务器包含该表情 +group.SendEmoticon("md5 string", nil) +``` + + +#### 发送视频信息 + +```go +video, _ := os.Open("your video path") + +defer video.Close() + +group.SendVideo(img) +``` + + + #### 发送文件消息 ```go diff --git a/relations.go b/relations.go index 30be153..3a399fe 100644 --- a/relations.go +++ b/relations.go @@ -181,17 +181,22 @@ func (g *Group) String() string { return fmt.Sprintf("", g.NickName) } -// SendText 发行文本消息给当前的群组 +// SendText 发送文本消息给当前的群组 func (g *Group) SendText(content string) (*SentMessage, error) { return g.Self().SendTextToGroup(g, content) } -// SendImage 发行图片消息给当前的群组 +// SendImage 发送图片消息给当前的群组 func (g *Group) SendImage(file io.Reader) (*SentMessage, error) { return g.Self().SendImageToGroup(g, file) } -// SendVideo 发行视频消息给当前的群组 +// SendEmoticon 发送表情消息给当前的群组 +func (g *Group) SendEmoticon(md5 string, file io.Reader) (*SentMessage, error) { + return g.Self().SendEmoticonToGroup(g, md5, file) +} + +// SendVideo 发送视频消息给当前的群组 func (g *Group) SendVideo(file io.Reader) (*SentMessage, error) { return g.Self().SendVideoToGroup(g, file) } diff --git a/user.go b/user.go index abf090a..d698e5c 100644 --- a/user.go +++ b/user.go @@ -601,7 +601,7 @@ func (s *Self) SendImageToGroup(group *Group, file io.Reader) (*SentMessage, err return s.sendImageToUser(group.User.UserName, file) } -// SendImageToGroup 发送图片消息给群组 +// SendEmoticonToGroup 发送图片消息给群组 func (s *Self) SendEmoticonToGroup(group *Group, md5 string, file io.Reader) (*SentMessage, error) { return s.sendEmoticonToUser(group.User.UserName, md5, file) }