client

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

wechat-bot dll client

Index

Constants

View Source
const (
	// 心跳
	HEART_BEAT = 5005
	// 收到的文本消息
	RECV_TXT_MSG = 1
	// 收到的图片消息
	RECV_PIC_MSG = 3
	// 引用消息
	RECV_TXT_REFERENCE_MSG = 49
	// 用户和群组列表
	USER_LIST = 5000
	// 获取成功列表
	GET_USER_LIST_SUCCSESS = 5001
	// 获取失败列表
	GET_USER_LIST_FAIL = 5002
	// 文本消息
	TXT_MSG = 555
	// 图片消息
	PIC_MSG = 500
	// 艾特消息
	AT_MSG = 550
	// 群组成员
	CHATROOM_MEMBER = 5010
	// 群组成员别名
	CHATROOM_MEMBER_NICK = 5020
	// 个人资料
	PERSONAL_INFO = 6500
	// 调试模式, 默认关
	DEBUG_SWITCH = 6000
	// 个人资料详情
	PERSONAL_DETAIL = 6550
	//
	DESTROY_ALL = 9999
	// 微信好友请求消息
	NEW_FRIEND_REQUEST = 37
	// 添加好友,拍一拍
	AGREE_TO_FRIEND_REQUEST = 10000
	// 附件
	ATTATCH_FILE = 5003
)

Variables

View Source
var Handlers struct {
	Ready              ReadyHandler
	RecvTxtMsg         RecvTxtMsgHandler
	RecvPicMsg         RecvPicMsgHandler
	UserList           UserListHandler
	ChatRoomMember     ChatRoomMemberHandler
	ChatRoomMemberNick ChatRoomMemberNickHandler
	RecvAtMsg          RecvAtMsgHandler
	PersonalInfo       PersonalInfoHandler
	PersonalDetail     PersonalDetailHandler
	AgreeToFriend      AgreeToFriendHandler
	AddFriendRequest   AddFriendRequestHandler
	TxtMsg             TxtMsgHandler
	PicMsg             PicMsgHandler
	AtMsg              AtMsgHandler
}

处理事件函数

Functions

func GetID

func GetID() string

uuid

func GetRequestMsg

func GetRequestMsg(msg *MSG) (body string)

获取发送主体消息

Types

type APIPath

type APIPath string

Api路径

const (
	// at消息接口
	SEND_AT_MSG_API APIPath = "/api/sendatmsg"
	// 图片消息接口
	SEND_PIC_API APIPath = "/api/sendpic"
	// 发消息
	SEND_TXT_MSG_API APIPath = "/api/sendtxtmsg"
	// 发附件
	SEND_ATTATCH_API APIPath = "/api/sendattatch"
	// 获取别名
	GET_MEMBERNICK_API APIPath = "/api/getmembernick"
	// 获取成员ID
	GET_MEMBERID_API APIPath = "/api/getmemberid"
	// 获取通讯录
	GET_CONTACTLIST_API APIPath = "/api/getcontactlist"
	// 获取成员列表
	GET_CHATROOM_MEMBER_LIST_API APIPath = "/api/get_charroom_member_list"
	// 获取个人信息
	GET_PERSONAL_INFO_API APIPath = "/api/get_personal_info"
)

type AddFriendRequestHandler added in v1.0.0

type AddFriendRequestHandler func(wx *WxClient, event *Event)

AddFriendRequestHandler 获取添加好友事件

type AgreeToFriendHandler

type AgreeToFriendHandler func(wx *WxClient, event *Event)

AgreeToFriendHandler 同意好友成功事件

type AtMsgHandler

type AtMsgHandler func(wx *WxClient, event *Event)

AtMsgHandler At消息事件

type ChatRoomMemberHandler

type ChatRoomMemberHandler func(wx *WxClient, event *EventChatrooMmember)

ChatRoomMemberHandler 获取群成员事件

type ChatRoomMemberNickHandler

type ChatRoomMemberNickHandler func(wx *WxClient, event *EventChatrooMmemberNick)

ChatRoomMemberNickHandler 获取成员具体昵称事件

type Event

type Event struct {
	ID       string `json:"id"`
	ID1      string `json:"id1"` // 发送人
	ID2      string `json:"id2"` //
	ID3      string `json:"id3"`
	Type     int32  `json:"type"`
	Content  string `json:"content"`
	Receiver string `json:"receiver"`
	Sender   string `json:"sender"`
	Srvid    int8   `json:"srvid"`
	Status   string `json:"status"`
	Time     string `json:"time"`
	Wxid     string `json:"wxid"` // 发送人 | 群ID
}

消息事件

type EventChatrooMmember

type EventChatrooMmember struct {
	ID      string `json:"id"`
	Type    int32  `json:"type"`
	Content []struct {
		Address string   `json:"address"`
		Member  []string `json:"member"`
		RoomID  string   `json:"room_id"`
	} `json:"content"`
}

chatroom member 5010

type EventChatrooMmemberNick

type EventChatrooMmemberNick struct {
	ID       string `json:"id"`
	Type     int32  `json:"type"`
	Content  Nick   `json:"content"`
	Receiver string `json:"receiver"`
	Sender   string `json:"sender"`
	Srvid    int8   `json:"srvid"`
	Status   string `json:"status"`
	Time     string `json:"time"`
}

chatroom member nickname 5020

type EventPaiyipai

type EventPaiyipai struct {
	ID      string `json:"id"`
	Type    int32  `json:"type"`
	Content struct {
		Content string `json:"content"`
		ID1     string `json:"id1"` // 发送人 | 群ID
	} `json:"content"`
	Receiver string `json:"receiver"`
	Sender   string `json:"sender"`
	Srvid    int8   `json:"srvid"`
	Status   string `json:"status"`
	Time     string `json:"time"`
}

拍一拍 || 添加好友

type EventPicConent

type EventPicConent struct {
	ID      string `json:"id"`
	Type    int32  `json:"type"`
	Content struct {
		Content string `json:"content"`
		Detail  string `json:"detail"` // 图片详情
		ID1     string `json:"id1"`    // 发送人 | 群ID
		ID2     string `json:"id2"`    //
		Thumb   string `json:"thumb"`  // 缩略图
	} `json:"content"`
	Receiver string `json:"receiver"`
	Sender   string `json:"sender"`
	Srvid    int8   `json:"srvid"`
	Status   string `json:"status"`
	Time     string `json:"time"`
}

图片消息事件 3

type EventReferenceConent

type EventReferenceConent struct {
	ID      string `json:"id"`
	Type    int32  `json:"type"`
	Content struct {
		Content string `json:"content"`
		ID1     string `json:"id1"` // 发送人
		ID2     string `json:"id2"` //
	} `json:"content"`
	Receiver string `json:"receiver"`
	Sender   string `json:"sender"`
	Srvid    int8   `json:"srvid"`
	Status   string `json:"status"`
	Time     string `json:"time"`
}

引用消息事件 49

type EventUserList

type EventUserList struct {
	ID      string `json:"id"`
	Type    int32  `json:"type"`
	Content []struct {
		Headimg string `json:"headimg"`
		Name    string `json:"name"`
		Node    int32  `json:"node"`
		Remarks string `json:"remarks"`
		Wxcode  string `json:"wxcode"` // 微信号
		Wxid    string `json:"wxid"`   // 微信id
	} `json:"content"`
}

user_list 5000

type MSG

type MSG struct {
	ID       string      `json:"id"`
	Type     int32       `json:"type"`
	Roomid   string      `json:"roomid"`
	Wxid     string      `json:"wxid"`
	Content  string      `json:"content"`
	Nickname string      `json:"nickname"`
	Ext      interface{} `json:"ext"`
}

消息主体

type Nick

type Nick struct {
	Nick   string `json:"nick"`
	Wxid   string `json:"wxid"`
	RoomID string `json:"roomid"`
}

type PersonalDetailHandler

type PersonalDetailHandler func(wx *WxClient, event *Event)

PersonalDetailHandler 获取个人详细资料事件

type PersonalInfo

type PersonalInfo struct {
	Code string `json:"wx_code"`
	Id   string `json:"wx_id"`
	Name string `json:"wx_name"`
}

个人资料

type PersonalInfoHandler

type PersonalInfoHandler func(wx *WxClient, event *Event)

PersonalInfoHandler 获取个人资料事件

type PicMsgHandler

type PicMsgHandler func(wx *WxClient, event *Event)

PicMsgHandler 图片消息事件

type ReadyHandler

type ReadyHandler func(wx *WxClient, event *Event)

ReadyHandler 可以处理所有的事件

type RecvAtMsgHandler

type RecvAtMsgHandler func(wx *WxClient, event *Event)

RecvAtMsgHandler 获取接收At消息事件

type RecvPicMsgHandler

type RecvPicMsgHandler func(wx *WxClient, event *Event)

RecvPicMsgHandler 获取接收图片消息事件

type RecvTxtMsgHandler

type RecvTxtMsgHandler func(wx *WxClient, event *Event)

RecvTxtMsgHandler 获取接收文本消息事件

type TxtMsgHandler

type TxtMsgHandler func(wx *WxClient, event *Event)

TxtMsgHandler 文本消息事件

type UserListHandler

type UserListHandler func(wx *WxClient, event *EventUserList)

UserListHandler 获取用户列表消息事件

type WxClient

type WxClient struct {
	RecvWxid string
	// contains filtered or unexported fields
}

func NewConnect

func NewConnect(host string) (wx *WxClient)

初始化机器人,以及建立基础连接

func (*WxClient) ApiGetChatRoomList added in v1.0.0

func (wx *WxClient) ApiGetChatRoomList() (member *EventChatrooMmember, err error)

获取群列表

func (*WxClient) ApiGetMembernick

func (wx *WxClient) ApiGetMembernick(wxid, roomid string) (nick *Nick, err error)

获取群成员昵称

func (*WxClient) ApiGetPersonalInfo added in v1.0.0

func (wx *WxClient) ApiGetPersonalInfo() (info *PersonalInfo, err error)

获取个人资料

func (*WxClient) ApiGetUserList added in v1.0.0

func (wx *WxClient) ApiGetUserList() (event *EventUserList, err error)

获取好友列表

func (*WxClient) ApiSendAtMsg added in v1.0.0

func (wx *WxClient) ApiSendAtMsg(wxid, content, roomid string) (event *Event, err error)

群里发at消息

func (*WxClient) ApiSendPicMsg added in v1.0.0

func (wx *WxClient) ApiSendPicMsg(wxid, content string) (event *Event, err error)

发送图片消息

func (*WxClient) ApiSendTxtMsg added in v1.0.0

func (wx *WxClient) ApiSendTxtMsg(wxid, content string) (event *Event, err error)

发送文本消息

func (*WxClient) BoolGroup

func (wx *WxClient) BoolGroup(wxid string) bool

判断是否为群

func (*WxClient) BoolOfficialAccount added in v1.0.1

func (wx *WxClient) BoolOfficialAccount(wxid string) bool

判断是否为公众号

func (*WxClient) GetChatRoomMemberList

func (wx *WxClient) GetChatRoomMemberList() (i int, err error)

获取群列表

func (*WxClient) GetGroupUserNick

func (wx *WxClient) GetGroupUserNick(wxid, roomid string) (i int, err error)

获取群成员昵称

func (*WxClient) GetHttpUrl

func (wx *WxClient) GetHttpUrl(path APIPath) string

获取http地址 + path

func (*WxClient) GetPersonalDetail

func (wx *WxClient) GetPersonalDetail(wxid string) (i int, err error)

获取详细资料

func (*WxClient) GetPersonalInfo

func (wx *WxClient) GetPersonalInfo(wxid string) (i int, err error)

获取个人信息

func (*WxClient) GetUserList

func (wx *WxClient) GetUserList() (i int, err error)

获取微信好友列表

func (*WxClient) GetWsUrl

func (wx *WxClient) GetWsUrl() string

获取ws地址

func (*WxClient) RegisterHandlers

func (wx *WxClient) RegisterHandlers(handlers ...interface{})

RegisterHandlers 注册事件回调

func (*WxClient) Send

func (wx *WxClient) Send(msg *MSG) (i int, err error)

ws通讯通用方法

func (*WxClient) SendAtMsg

func (wx *WxClient) SendAtMsg(wxid, content, roomid string) (i int, err error)

发送艾特消息

func (*WxClient) SendPicMsg

func (wx *WxClient) SendPicMsg(wxid, content string) (i int, err error)

发图片消息

func (*WxClient) SendTxtMsg

func (wx *WxClient) SendTxtMsg(wxid, content string) (i int, err error)

发文本消息

func (*WxClient) Start

func (wx *WxClient) Start()

启动监听消息

Jump to

Keyboard shortcuts

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