client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

wecaht bot client

Index

Constants

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

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
	TxtMsg             TxtMsgHandler
	PicMsg             PicMsgHandler
	AtMsg              AtMsgHandler
}

Functions

func GetID

func GetID() string

func GetRequestMsg

func GetRequestMsg(msg *MSG) (body string)

获取发送主体消息

Types

type APIPath

type APIPath string
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_CHARROOM_MEMBER_LIST_API APIPath = "/api/get_charroom_member_list"
	// 获取个人信息
	GET_PERSONAL_INFO_API APIPath = "/api/get_personal_info"
)

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"`
		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 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 RequetBody

type RequetBody struct {
	Para MSG `json:"para"`
}

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) ApiGetMembernick

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

Tip: API接口与ws重复,暂时不考虑实现,需要的参考下面实现即可

func (*WxClient) BoolGroup

func (wx *WxClient) BoolGroup(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