Documentation ¶
Index ¶
- Variables
- func Respond(w http.ResponseWriter, data any) error
- func ToMessageType(t EventType) event.MessageType
- type AppData
- type BlobData
- type Chat
- type ChatType
- type Conn
- type ErrorResponse
- type Event
- type EventType
- type GroupInfo
- type LocationData
- type Message
- type MessageType
- type ReplyInfo
- type Request
- type RequestType
- type Response
- type ResponseType
- type User
- type UserInfo
- type WechatClient
- func (wc *WechatClient) Connect() error
- func (wc *WechatClient) Disconnect() error
- func (wc *WechatClient) GetFriendList() []*UserInfo
- func (wc *WechatClient) GetGroupInfo(wxid string) *GroupInfo
- func (wc *WechatClient) GetGroupList() []*GroupInfo
- func (wc *WechatClient) GetGroupMemberNickname(group, wxid string) string
- func (wc *WechatClient) GetGroupMembers(wxid string) []string
- func (wc *WechatClient) GetSelf() *UserInfo
- func (wc *WechatClient) GetUserInfo(wxid string) *UserInfo
- func (wc *WechatClient) IsLoggedIn() bool
- func (wc *WechatClient) LoginWithQRCode() []byte
- func (wc *WechatClient) SendEvent(event *Event) (*Event, error)
- func (wc *WechatClient) SetProcessFunc(f func(*Event))
- type WechatService
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWebsocketNotConnected = errors.New("websocket not connected") ErrWebsocketClosed = errors.New("websocket closed before response received") )
Functions ¶
func ToMessageType ¶
func ToMessageType(t EventType) event.MessageType
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { HTTPStatus int `json:"-"` Code string `json:"code"` Message string `json:"message"` }
func (*ErrorResponse) Error ¶
func (er *ErrorResponse) Error() string
func (ErrorResponse) Write ¶
func (er ErrorResponse) Write(w http.ResponseWriter)
type Event ¶
type Event struct { ID string `json:"id"` ThreadID string `json:"thread_id,omitempty"` Timestamp int64 `json:"timestamp"` From User `json:"from"` Chat Chat `json:"chat"` Type EventType `json:"type"` Content string `json:"content,omitempty"` Mentions []string `json:"mentions,omitempty"` Reply *ReplyInfo `json:"reply,omitempty"` Data any `json:"data,omitempty"` }
func (*Event) UnmarshalJSON ¶
type EventType ¶
type EventType int
func ToEventType ¶
func ToEventType(t event.MessageType) EventType
type LocationData ¶
type Message ¶
type Message struct { ID int64 `json:"id"` MXID string `json:"mxid"` Type MessageType `json:"type"` Data any `json:"data,omitempty"` }
func (*Message) UnmarshalJSON ¶
type MessageType ¶
type MessageType int
const ( MsgRequest MessageType = iota MsgResponse )
func (MessageType) String ¶
func (t MessageType) String() string
type Request ¶
type Request struct { Type RequestType `json:"type"` Data any `json:"data,omitempty"` }
func (*Request) UnmarshalJSON ¶
type RequestType ¶
type RequestType int
const ( ReqEvent RequestType = iota ReqConnect ReqDisconnect ReqLoginQR ReqIsLogin ReqGetSelf ReqGetUserInfo ReqGetGroupInfo ReqGetGroupMembers ReqGetGroupMemberNickname ReqGetFriendList ReqGetGroupList )
func (RequestType) String ¶
func (t RequestType) String() string
type Response ¶
type Response struct { Type ResponseType `json:"type"` Error *ErrorResponse `json:"error,omitempty"` Data any `json:"data,omitempty"` }
func (*Response) UnmarshalJSON ¶
type ResponseType ¶
type ResponseType int
const ( RespEvent ResponseType = iota RespConnect RespDisconnect RespLoginQR RespIsLogin RespGetSelf RespGetUserInfo RespGetGroupInfo RespGetGroupMembers RespGetGroupMemberNickname RespGetFriendList RespGetGroupList )
func (ResponseType) String ¶
func (t ResponseType) String() string
type WechatClient ¶
type WechatClient struct {
// contains filtered or unexported fields
}
func (*WechatClient) Connect ¶
func (wc *WechatClient) Connect() error
func (*WechatClient) Disconnect ¶
func (wc *WechatClient) Disconnect() error
func (*WechatClient) GetFriendList ¶
func (wc *WechatClient) GetFriendList() []*UserInfo
func (*WechatClient) GetGroupInfo ¶
func (wc *WechatClient) GetGroupInfo(wxid string) *GroupInfo
func (*WechatClient) GetGroupList ¶
func (wc *WechatClient) GetGroupList() []*GroupInfo
func (*WechatClient) GetGroupMemberNickname ¶
func (wc *WechatClient) GetGroupMemberNickname(group, wxid string) string
func (*WechatClient) GetGroupMembers ¶
func (wc *WechatClient) GetGroupMembers(wxid string) []string
func (*WechatClient) GetSelf ¶
func (wc *WechatClient) GetSelf() *UserInfo
func (*WechatClient) GetUserInfo ¶
func (wc *WechatClient) GetUserInfo(wxid string) *UserInfo
func (*WechatClient) IsLoggedIn ¶
func (wc *WechatClient) IsLoggedIn() bool
func (*WechatClient) LoginWithQRCode ¶
func (wc *WechatClient) LoginWithQRCode() []byte
func (*WechatClient) SetProcessFunc ¶
func (wc *WechatClient) SetProcessFunc(f func(*Event))
type WechatService ¶
type WechatService struct {
// contains filtered or unexported fields
}
func NewWechatService ¶
func NewWechatService(addr, secret string, log zerolog.Logger) *WechatService
func (*WechatService) NewClient ¶
func (ws *WechatService) NewClient(mxid string) *WechatClient
func (*WechatService) ServeHTTP ¶
func (ws *WechatService) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*WechatService) Start ¶
func (ws *WechatService) Start()
func (*WechatService) Stop ¶
func (ws *WechatService) Stop()
Click to show internal directories.
Click to hide internal directories.