Versions in this module Expand all Collapse all v0 v0.8.4 Jun 5, 2026 Changes in this version + var ErrConfigNotFound = fmt.Errorf("配置文件不存在") + var ErrContactNotFound = fmt.Errorf("联系人不存在") + var ErrInvalidConfig = fmt.Errorf("无效的配置") + var ErrInvalidContactID = fmt.Errorf("无效的联系人ID") + var ErrLoginFailed = fmt.Errorf("微信登录失败") + var ErrMessageNotFound = fmt.Errorf("消息不存在") + var ErrMessageSendFailed = fmt.Errorf("消息发送失败") + var ErrMessageTooLong = fmt.Errorf("消息过长") + var ErrNeedPushConfirm = fmt.Errorf("需要在手机上确认登录") + var ErrNeedScanQRCode = fmt.Errorf("需要扫码登录") + var ErrNetworkError = fmt.Errorf("网络连接失败") + var ErrNoUnreadMessages = fmt.Errorf("没有未读消息") + var ErrNotLoggedIn = fmt.Errorf("微信未登录") + var ErrOperationNotAllowed = fmt.Errorf("操作不被允许") + var ErrPermissionDenied = fmt.Errorf("权限不足") + var ErrRateLimited = fmt.Errorf("操作频率过高,请稍后重试") + var ErrSessionExpired = fmt.Errorf("微信会话已过期") + var ErrStorageError = fmt.Errorf("存储错误") + var ErrWechatServerError = fmt.Errorf("微信服务器错误") + func ErrorCode(err error) string + func GetDefaultConfigPath() string + func IsRetryableError(err error) bool + func SaveConfig(config *Config, path string) error + func ShouldReLoginError(err error) bool + type Bot struct + func NewBot(config *Config) (*Bot, error) + func (b *Bot) Block(ctx context.Context) error + func (b *Bot) Close() error + func (b *Bot) GetCurrentUser(ctx context.Context) (*openwechat.Self, error) + func (b *Bot) GetFriends(ctx context.Context, refresh bool) (openwechat.Friends, error) + func (b *Bot) GetGroups(ctx context.Context, refresh bool) (openwechat.Groups, error) + func (b *Bot) GetMps(ctx context.Context, refresh bool) (openwechat.Mps, error) + func (b *Bot) IsLoggedIn() bool + func (b *Bot) Logout(ctx context.Context) error + func (b *Bot) SendText(ctx context.Context, to, content string) error + func (b *Bot) SmartLogin(ctx context.Context) error + type Client struct + func NewClient(config *Config) (*Client, error) + func NewClientFromConfig() (*Client, error) + func (c *Client) Close() error + func (c *Client) GetFriends(ctx context.Context) ([]map[string]string, error) + func (c *Client) GetGroups(ctx context.Context) ([]map[string]string, error) + func (c *Client) GetMessage(ctx context.Context, messageID string) (*Message, error) + func (c *Client) GetMessages(ctx context.Context, unread bool, limit int) ([]Message, error) + func (c *Client) Login(ctx context.Context) error + func (c *Client) Logout(ctx context.Context) error + func (c *Client) MarkAsRead(ctx context.Context, messageID string) error + func (c *Client) ReplyMessage(ctx context.Context, messageID, content string) error + func (c *Client) SendMessage(ctx context.Context, to, content string) error + func (c *Client) Status(ctx context.Context) (map[string]any, error) + type Config struct + Account string + AllowedFriends []string + AutoLogin bool + BlockedUsers []string + DBPath string + MaxMsgLength int + Mode string + PushLogin bool + ReplyDelay int + func DefaultConfig() *Config + func LoadConfig(path string) (*Config, error) + func (c *Config) Validate() error + type Message struct + Content string + CreatedAt time.Time + Direction string + From string + ID string + RepliedAt time.Time + Status string + To string + Type string + WxMsgID string + func ConvertOpenWechatMessage(ctx context.Context, wxMsg *openwechat.Message, direction string) (*Message, error) + type MessageFormatter struct + func NewMessageFormatter(format OutputFormat) *MessageFormatter + func (f *MessageFormatter) FormatMessageDetail(msg *Message) string + func (f *MessageFormatter) FormatMessages(messages []Message) string + type MessageManager struct + func NewMessageManager(db *sql.DB, bot *Bot) *MessageManager + func (m *MessageManager) GetMessageByID(ctx context.Context, messageID string) (*Message, error) + func (m *MessageManager) GetRecentMessages(ctx context.Context, limit int) ([]Message, error) + func (m *MessageManager) GetUnreadMessages(ctx context.Context, limit int) ([]Message, error) + func (m *MessageManager) MarkAsRead(ctx context.Context, messageID string) error + func (m *MessageManager) MarkAsReplied(ctx context.Context, messageID, replyContent string) error + func (m *MessageManager) SaveMessage(ctx context.Context, msg *Message) error + type OutputFormat string + const FormatMarkdown + const FormatOrg + const FormatSimple + const FormatTable + type SQLiteHotReloadStorage struct + func NewSQLiteHotReloadStorage(dbPath, account string) (*SQLiteHotReloadStorage, error) + func (s *SQLiteHotReloadStorage) Close() error + func (s *SQLiteHotReloadStorage) Read(p []byte) (n int, err error) + func (s *SQLiteHotReloadStorage) Write(p []byte) (n int, err error)