Skip to content

Commit

Permalink
feat: Group support sending emoticon messages (#552)
Browse files Browse the repository at this point in the history
1. #501 添加了表情支持,relations.go 中遗漏了对应方法添加
2. 部分文档未对 表情、视频 api 文档进行维护
  • Loading branch information
Xavier9896 authored Dec 18, 2024
1 parent fba9c35 commit c8c73e0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
22 changes: 21 additions & 1 deletion docs/message.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions docs/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions relations.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,22 @@ func (g *Group) String() string {
return fmt.Sprintf("<Group:%s>", 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)
}
Expand Down
2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit c8c73e0

Please sign in to comment.