Documentation
¶
Index ¶
- Constants
- type Bot
- func (b *Bot) AuthenticateFromQR(qrCode string) error
- func (b *Bot) GetQRCodeURL() (string, string, error)
- func (b *Bot) Platform() string
- func (b *Bot) PollQRStatus(qrCode string) (string, error)
- func (b *Bot) SendMessage(channel, content string) error
- func (b *Bot) SetProxyURL(proxyURL string) error
- func (b *Bot) Start(handler core.MessageHandler) error
- func (b *Bot) Stop() error
- type QRCodeHandler
- type QRCodeHandlerASCII
- type QRCodeHandlerSave
Constants ¶
const ( APIBaseURL = "https://ilinkai.weixin.qq.com" QRCodeEndpoint = "/ilink/bot/get_bot_qrcode" QRStatusEndpoint = "/ilink/bot/get_qrcode_status" GetUpdatesEndpoint = "/ilink/bot/getupdates" SendMessageEndpoint = "/ilink/bot/sendmsg" GetConfigEndpoint = "/ilink/bot/getconfig" SendTypingEndpoint = "/ilink/bot/sendtyping" ChannelVersion = "1.0" QRCodePollInterval = 2 * time.Second APITimeout = 15 * time.Second MaxMessageLength = 2000 )
API endpoints
const ( MessageTypeText = 1 MessageTypeImage = 2 MessageTypeFile = 4 )
Message types
const ( MessageStateNew = 0 MessageStateFinish = 2 )
Message states
const ( QRStatusWait = "wait" QRStatusScaned = "scaned" QRStatusConfirmed = "confirmed" QRStatusExpired = "expired" )
QR Status
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot implements core.Bot interface for WeChat iLink using long polling + QR login
func NewBot ¶
func NewBot(qrCodeHandler QRCodeHandler, opts ...core.Option) (*Bot, error)
NewBot creates a new WeChat iLink bot instance qrCodeHandler is required - it handles QR code display during login Use QRCodeHandlerASCII{} or QRCodeHandlerSave{Path: "..."} or custom implementation Options like WithCredentialsPath, WithQRLoginTimeout can be passed
func (*Bot) AuthenticateFromQR ¶
AuthenticateFromQR completes the QR login flow
func (*Bot) GetQRCodeURL ¶
GetQRCodeURL returns the QR code URL for login
func (*Bot) PollQRStatus ¶
PollQRStatus polls for QR code scan status
func (*Bot) SendMessage ¶
SendMessage sends a message to a WeChat user
func (*Bot) SetProxyURL ¶
SetProxyURL implements core.WithProxy interface
type QRCodeHandler ¶
type QRCodeHandler interface {
// Handle displays or saves the QR code
Handle(qrCodeID, imageContent string) error
}
QRCodeHandler defines how to handle QR code display during login
type QRCodeHandlerASCII ¶
type QRCodeHandlerASCII struct{}
QRCodeHandlerASCII prints QR code as ASCII art to console
func (QRCodeHandlerASCII) Handle ¶
func (h QRCodeHandlerASCII) Handle(qrCodeID, imageContent string) error
Handle implements QRCodeHandler by printing ASCII art to stdout
type QRCodeHandlerSave ¶
type QRCodeHandlerSave struct {
Path string
}
QRCodeHandlerSave saves QR code image to file
func (QRCodeHandlerSave) Handle ¶
func (h QRCodeHandlerSave) Handle(qrCodeID, imageContent string) error
Handle implements QRCodeHandler by saving QR code to file