Documentation
¶
Index ¶
- Constants
- func PerformLoginInteractive(ctx context.Context, opts AuthFlowOpts) (botToken, userID, accountID, baseUrl string, err error)
- type APIStatus
- type ApiClient
- func (c *ApiClient) GetConfig(ctx context.Context, req GetConfigReq) (*GetConfigResp, error)
- func (c *ApiClient) GetQRCode(ctx context.Context, botType string) (*QRCodeResponse, error)
- func (c *ApiClient) GetQRCodeStatus(ctx context.Context, qrcode string) (*StatusResponse, error)
- func (c *ApiClient) GetUpdates(ctx context.Context, req GetUpdatesReq) (*GetUpdatesResp, error)
- func (c *ApiClient) GetUploadUrl(ctx context.Context, req GetUploadUrlReq) (*GetUploadUrlResp, error)
- func (c *ApiClient) SendMessage(ctx context.Context, req SendMessageReq) (*SendMessageResp, error)
- func (c *ApiClient) SendTyping(ctx context.Context, req SendTypingReq) (*SendTypingResp, error)
- type AuthFlowOpts
- type BaseInfo
- type CDNMedia
- type FileItem
- type GetConfigReq
- type GetConfigResp
- type GetUpdatesReq
- type GetUpdatesResp
- type GetUploadUrlReq
- type GetUploadUrlResp
- type ImageItem
- type MessageItem
- type QRCodeResponse
- type RefMessage
- type SendMessageReq
- type SendMessageResp
- type SendTypingReq
- type SendTypingResp
- type StatusResponse
- type TextItem
- type VideoItem
- type VoiceItem
- type WeixinChannel
- func (c *WeixinChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error)
- func (c *WeixinChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMessage) ([]string, error)
- func (c *WeixinChannel) Start(ctx context.Context) error
- func (c *WeixinChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
- func (c *WeixinChannel) Stop(ctx context.Context) error
- func (c *WeixinChannel) VoiceCapabilities() channels.VoiceCapabilities
- type WeixinMessage
Constants ¶
const ( UploadMediaTypeImage = 1 UploadMediaTypeVideo = 2 UploadMediaTypeFile = 3 UploadMediaTypeVoice = 4 )
UploadMediaType constants
const ( MessageTypeNone = 0 MessageTypeUser = 1 MessageTypeBot = 2 )
const ( MessageItemTypeNone = 0 MessageItemTypeText = 1 MessageItemTypeImage = 2 MessageItemTypeVoice = 3 MessageItemTypeFile = 4 MessageItemTypeVideo = 5 )
const ( MessageStateNew = 0 MessageStateGenerating = 1 MessageStateFinish = 2 )
const ( TypingStatusTyping = 1 TypingStatusCancel = 2 )
Variables ¶
This section is empty.
Functions ¶
func PerformLoginInteractive ¶
func PerformLoginInteractive( ctx context.Context, opts AuthFlowOpts, ) (botToken, userID, accountID, baseUrl string, err error)
PerformLoginInteractive starts the Weixin QR login flow and blocks until login is successful or times out. It prints a QR code to the terminal for the user to scan. Returns the BotToken, UserID, AccountID, and BaseUrl on success.
Types ¶
type ApiClient ¶
func (*ApiClient) GetConfig ¶
func (c *ApiClient) GetConfig(ctx context.Context, req GetConfigReq) (*GetConfigResp, error)
func (*ApiClient) GetQRCodeStatus ¶
func (*ApiClient) GetUpdates ¶
func (c *ApiClient) GetUpdates(ctx context.Context, req GetUpdatesReq) (*GetUpdatesResp, error)
func (*ApiClient) GetUploadUrl ¶
func (c *ApiClient) GetUploadUrl(ctx context.Context, req GetUploadUrlReq) (*GetUploadUrlResp, error)
func (*ApiClient) SendMessage ¶
func (c *ApiClient) SendMessage(ctx context.Context, req SendMessageReq) (*SendMessageResp, error)
func (*ApiClient) SendTyping ¶
func (c *ApiClient) SendTyping(ctx context.Context, req SendTypingReq) (*SendTypingResp, error)
type AuthFlowOpts ¶
AuthFlowOpts configures the interactive QR login flow.
type BaseInfo ¶
type BaseInfo struct {
ChannelVersion string `json:"channel_version,omitempty"`
}
BaseInfo is attached to every outgoing CGI request
type GetConfigReq ¶
type GetConfigResp ¶
type GetUpdatesReq ¶
type GetUpdatesResp ¶
type GetUpdatesResp struct {
APIStatus
Msgs []WeixinMessage `json:"msgs,omitempty"`
SyncBuf string `json:"sync_buf,omitempty"`
GetUpdatesBuf string `json:"get_updates_buf,omitempty"`
LongpollingTimeoutMs int `json:"longpolling_timeout_ms,omitempty"`
}
type GetUploadUrlReq ¶
type GetUploadUrlReq struct {
Filekey string `json:"filekey,omitempty"`
MediaType int `json:"media_type,omitempty"`
ToUserID string `json:"to_user_id,omitempty"`
Rawsize int64 `json:"rawsize,omitempty"`
RawfileMD5 string `json:"rawfilemd5,omitempty"`
Filesize int64 `json:"filesize,omitempty"`
ThumbRawsize int64 `json:"thumb_rawsize,omitempty"`
ThumbRawfileMD5 string `json:"thumb_rawfilemd5,omitempty"`
ThumbFilesize int64 `json:"thumb_filesize,omitempty"`
NoNeedThumb bool `json:"no_need_thumb,omitempty"`
Aeskey string `json:"aeskey,omitempty"` // hex-encoded 16-byte AES key
BaseInfo BaseInfo `json:"base_info,omitempty"`
}
type GetUploadUrlResp ¶
type ImageItem ¶
type ImageItem struct {
Media *CDNMedia `json:"media,omitempty"`
ThumbMedia *CDNMedia `json:"thumb_media,omitempty"`
Aeskey string `json:"aeskey,omitempty"`
Url string `json:"url,omitempty"`
MidSize int64 `json:"mid_size,omitempty"`
ThumbSize int64 `json:"thumb_size,omitempty"`
ThumbHeight int `json:"thumb_height,omitempty"`
ThumbWidth int `json:"thumb_width,omitempty"`
HDSize int64 `json:"hd_size,omitempty"`
}
type MessageItem ¶
type MessageItem struct {
Type int `json:"type,omitempty"`
CreateTimeMs int64 `json:"create_time_ms,omitempty"`
UpdateTimeMs int64 `json:"update_time_ms,omitempty"`
IsCompleted bool `json:"is_completed,omitempty"`
MsgID string `json:"msg_id,omitempty"`
RefMsg *RefMessage `json:"ref_msg,omitempty"`
TextItem *TextItem `json:"text_item,omitempty"`
ImageItem *ImageItem `json:"image_item,omitempty"`
VoiceItem *VoiceItem `json:"voice_item,omitempty"`
FileItem *FileItem `json:"file_item,omitempty"`
VideoItem *VideoItem `json:"video_item,omitempty"`
}
type QRCodeResponse ¶
type RefMessage ¶
type RefMessage struct {
MessageItem *MessageItem `json:"message_item,omitempty"`
Title string `json:"title,omitempty"`
}
type SendMessageReq ¶
type SendMessageReq struct {
Msg WeixinMessage `json:"msg,omitempty"`
BaseInfo BaseInfo `json:"base_info,omitempty"`
}
type SendMessageResp ¶
type SendMessageResp struct {
APIStatus
}
type SendTypingReq ¶
type SendTypingResp ¶
type SendTypingResp struct {
APIStatus
}
type StatusResponse ¶
type StatusResponse struct {
Status string `json:"status"` // "wait", "scaned", "confirmed", "expired", "scaned_but_redirect"
BotToken string `json:"bot_token,omitempty"`
IlinkBotID string `json:"ilink_bot_id,omitempty"`
Baseurl string `json:"baseurl,omitempty"`
IlinkUserID string `json:"ilink_user_id,omitempty"`
RedirectHost string `json:"redirect_host,omitempty"`
}
type VideoItem ¶
type VideoItem struct {
Media *CDNMedia `json:"media,omitempty"`
VideoSize int64 `json:"video_size,omitempty"`
PlayLength int `json:"play_length,omitempty"`
VideoMD5 string `json:"video_md5,omitempty"`
ThumbMedia *CDNMedia `json:"thumb_media,omitempty"`
ThumbSize int64 `json:"thumb_size,omitempty"`
ThumbHeight int `json:"thumb_height,omitempty"`
ThumbWidth int `json:"thumb_width,omitempty"`
}
type WeixinChannel ¶
type WeixinChannel struct {
*channels.BaseChannel
// contains filtered or unexported fields
}
WeixinChannel is the Weixin channel implementation over Tencent iLink REST API.
func NewWeixinChannel ¶
func NewWeixinChannel( bc *config.Channel, cfg *config.WeixinSettings, messageBus *bus.MessageBus, ) (*WeixinChannel, error)
NewWeixinChannel creates a new WeixinChannel from config.
func (*WeixinChannel) Send ¶
func (c *WeixinChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error)
Send implements channels.Channel by sending a text message to the WeChat user.
func (*WeixinChannel) SendMedia ¶
func (c *WeixinChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMessage) ([]string, error)
SendMedia implements channels.MediaSender.
func (*WeixinChannel) StartTyping ¶
func (c *WeixinChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
StartTyping implements channels.TypingCapable.
func (*WeixinChannel) VoiceCapabilities ¶
func (c *WeixinChannel) VoiceCapabilities() channels.VoiceCapabilities
VoiceCapabilities returns the voice capabilities of the channel.
type WeixinMessage ¶
type WeixinMessage struct {
Seq int `json:"seq,omitempty"`
MessageID int64 `json:"message_id,omitempty"`
FromUserID string `json:"from_user_id,omitempty"`
ToUserID string `json:"to_user_id,omitempty"`
ClientID string `json:"client_id,omitempty"`
CreateTimeMs int64 `json:"create_time_ms,omitempty"`
UpdateTimeMs int64 `json:"update_time_ms,omitempty"`
DeleteTimeMs int64 `json:"delete_time_ms,omitempty"`
SessionID string `json:"session_id,omitempty"`
GroupID string `json:"group_id,omitempty"`
MessageType int `json:"message_type,omitempty"`
MessageState int `json:"message_state,omitempty"`
ItemList []MessageItem `json:"item_list,omitempty"`
ContextToken string `json:"context_token,omitempty"`
}