Skip to content

Commit

Permalink
添加Message.Raw 字段存储消息原始信息
Browse files Browse the repository at this point in the history
  • Loading branch information
eatmoreapple committed Dec 17, 2021
1 parent 3e16717 commit 26473a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion message.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package openwechat

import (
"context"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
Expand Down Expand Up @@ -52,6 +53,7 @@ type Message struct {
mu sync.RWMutex
Context context.Context `json:"-"`
item map[string]interface{}
Raw []byte `json:"-"`
}

// Sender 获取消息的发送者
Expand Down Expand Up @@ -382,7 +384,8 @@ func (m *Message) Get(key string) (value interface{}, exist bool) {
// 消息初始化,根据不同的消息作出不同的处理
func (m *Message) init(bot *Bot) {
m.Bot = bot

raw, _ := json.Marshal(m)
m.Raw = raw
// 如果是群消息
if m.IsSendByGroup() {
// 将Username和正文分开
Expand Down

0 comments on commit 26473a5

Please sign in to comment.