weixin

package
v0.0.0-...-bcb9701 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
const (
	MessageTypeText  = 1
	MessageTypeImage = 2
	MessageTypeFile  = 4
)

Message types

View Source
const (
	MessageStateNew    = 0
	MessageStateFinish = 2
)

Message states

View Source
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

func (b *Bot) AuthenticateFromQR(qrCode string) error

AuthenticateFromQR completes the QR login flow

func (*Bot) GetQRCodeURL

func (b *Bot) GetQRCodeURL() (string, string, error)

GetQRCodeURL returns the QR code URL for login

func (*Bot) Platform

func (b *Bot) Platform() string

Platform returns the platform name

func (*Bot) PollQRStatus

func (b *Bot) PollQRStatus(qrCode string) (string, error)

PollQRStatus polls for QR code scan status

func (*Bot) SendMessage

func (b *Bot) SendMessage(channel, content string) error

SendMessage sends a message to a WeChat user

func (*Bot) SetProxyURL

func (b *Bot) SetProxyURL(proxyURL string) error

SetProxyURL implements core.WithProxy interface

func (*Bot) Start

func (b *Bot) Start(handler core.MessageHandler) error

Start initiates the QR login flow (if needed) and starts long polling for messages

func (*Bot) Stop

func (b *Bot) Stop() error

Stop stops the long polling and cleans up

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

Jump to

Keyboard shortcuts

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