wechat_bot

package module
v0.0.0-...-a0f6c5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2020 License: MIT Imports: 6 Imported by: 0

README

Table of Contents generated with DocToc

wechat-bot-go

wechat bot golang client

接收消息类型

  • 群文本消息
{
  "content":"高速老是在修路",
  "id":"20201211160304",
  "receiver":"xxxx@chatroom", 
  "sender":"wxid_xxxxxx",
  "srvid":1,
  "time":"2020-12-11 16:03:04",
  "type":1
}

注意到 receiver 为群聊 roomid, sender 为发送的人

  • 个人文本消息
{
  "content":"?",
  "id":"20201211160346",
  "receiver":"self",
  "sender":"wxid_xxxx",
  "srvid":1,
  "time":"2020-12-11 16:03:46",
  "type":1
}

注意到 receiver 为 self,也就是说接收个人消息的话可以通过这个 key 来进行判断

acknowledgement

Documentation

Index

Constants

View Source
const (
	HeartBeat           = 5005
	RecvTxtMsg          = 1 //接收文本消息
	RecvPicMsg          = 3 //接收图片消息
	UserList            = 5000
	GetUserListSuccsess = 5001
	GetUserListFail     = 5002
	TxtMsg              = 555
	PicMsg              = 500
	AtMsg               = 550
	//const CHATROOM_MEMBER = 5010;//废弃
	ChatroomMemberNick   = 5020
	PersonalInfo         = 6500
	DebugSwitch          = 6000
	PersonalDetail       = 6550
	DestroyAll           = 9999
	NewFriendRequest     = 37
	AgreeToFriendRequest = 10000 //同意微信好友请求消息
)

Variables

This section is empty.

Functions

func NewHTTPBot

func NewHTTPBot(prefix string) *httpBot

func NewWebsocketBot

func NewWebsocketBot(url string) *websocketBot

Types

type Bot

type Bot interface {
	//群聊发送 @member 消息
	SendAtMsg(content, roomId, atWxId, nick string) error
	//发送文本消息
	SendTxtMsg(content, wxId string) error
	//发送图片
	SendPic(wxId, filePath string) error
	//发送附件
	SendAttach(wxId, filePath string) error
	//获取群成员昵称
	GetMemberNick(roomId string) (res []*Member, err error)
	//获取群成员 id
	GetMemberId() (resp interface{}, err error)
	//获取微信通讯录好友和群列表
	GetContactList() (res []*Friend, err error)
	//刷新好友列表
	RefreshMemberList() error
	//动态卸载 ddl
	SendDestroy() error
}

type Friend

type Friend struct {
	Name string `json:"name"`
	WxId string `json:"wxid"`
}

type GetContactList

type GetContactList struct {
	Content []*Friend `json:"content"`
	Type    int64     `json:"type"`
}

type GetMemberList

type GetMemberList struct {
	Content []*Member `json:"content"`
	Type    int64     `json:"type"`
}

type Member

type Member struct {
	NickName string `json:"nickname"`
	RoomId   string `json:"roomid"`
	WxId     string `json:"wxid"`
}

type WrapperAtMsg

type WrapperAtMsg struct {
	WrapperMsg
	RoomId   string `json:"roomid"`
	NickName string `json:"nickname"`
}

func NewWrapperAtMsg

func NewWrapperAtMsg(wrapperMsg WrapperMsg, roomId string, nickName string) *WrapperAtMsg

type WrapperMsg

type WrapperMsg struct {
	Id      string `json:"id"`
	MsgType int64  `json:"type"`
	Content string `json:"content"`
	WxId    string `json:"wxid"`
}

func NewWrapperMsg

func NewWrapperMsg(msgType int64, content string, wxId string) *WrapperMsg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL