wxBot4g
1.0.0
wxBot4g is a WeChat robot based on go
24 lines of code realize the message monitoring function of WeChat robot
package main
import (
"wxBot4g/models"
"wxBot4g/pkg/define"
"wxBot4g/wcbot"
"github.com/sirupsen/logrus"
)
func HandleMsg(msg models.RealRecvMsg) {
logrus.Debug("MsgType: ", msg.MsgType, " ", " MsgTypeId: ", msg.MsgTypeId)
logrus.Info(
"消息类型:", define.MsgIdString(msg.MsgType), " ",
"数据类型:", define.MsgTypeIdString(msg.MsgTypeId), " ",
"发送人:", msg.SendMsgUSer.Name, " ",
"内容:", msg.Content.Data)
}
func main() {
bot := wcbot.New(HandleMsg)
bot.Debug = true
bot.Run()
}
Data type number | data type | illustrate |
---|---|---|
0 | Init | Initialization message, internal data |
1 | Self | Messages sent by yourself |
2 | FileHelper | file message |
3 | Group | Group message |
4 | Contact | Contact information |
5 | Public | Official account news |
6 | Special | Special account message |
51 | Get wxid | Get wxid message |
99 | Unknown | Unknown account message |
Data type number | data type | illustrate |
---|---|---|
0 | Text | The specific content of the text message |
1 | Location | geographical location |
3 | Image | The url of the image data. HTTP POST request this url to obtain data in jpg file format. |
4 | Voice | The url of the voice data. HTTP POST request this url to get the data in mp3 file format. |
5 | Recommend | Contains nickname (nickname), alias (alias), province (province), city (city), gender (gender) fields |
6 | Animation | Animation url, HTTP POST request this url to get data in gif file format |
7 | Share | Dictionary, including type (type), title (title), desc (description), url (link), from (source website) fields |
8 | Video | Video, not supported |
9 | VideoCall | Video calling, not supported |
10 | Redraw | Withdraw message |
11 | Empty | Content, not supported |
99 | Unknown | Not supported |
http://127.0.0.1:7788/v1/msg/text?to=测试群&word=你好, 测试一下&appKey=khr1244o1oh
Please refer to wxBot4g/wcbot/imageHandle_test.go
v1.1