Documentation
¶
Index ¶
- Variables
- func ApplyValidityWriteback(resource *entity.Resource, result ResourceCheckResult, ...)
- func NormalizeURL(raw string) string
- func SetDefaultStatsService(s *StatsService)
- func SetMeilisearchManager(manager *MeilisearchManager)
- func SetRepositoryManager(manager *repo.RepositoryManager)
- func URLHash(normalized string) string
- func UnifiedSearchResources(keyword string, limit int, systemConfigRepo repo.SystemConfigRepository, ...) ([]entity.Resource, error)
- type CleanupService
- type LinkCheckOutcome
- type LinkCheckService
- type LinkCheckStatus
- type LinkResolution
- type MeilisearchDocument
- type MeilisearchManager
- func (m *MeilisearchManager) ClearIndex() error
- func (m *MeilisearchManager) DebugGetAllDocuments() error
- func (m *MeilisearchManager) GetAllResources(page, pageSize int) ([]entity.Resource, int64, error)
- func (m *MeilisearchManager) GetService() *MeilisearchService
- func (m *MeilisearchManager) GetStatus() (MeilisearchStatus, error)
- func (m *MeilisearchManager) GetStatusWithHealthCheck() (MeilisearchStatus, error)
- func (m *MeilisearchManager) GetSyncProgress() SyncProgress
- func (m *MeilisearchManager) GetSyncedResources(page, pageSize int) ([]entity.Resource, int64, error)
- func (m *MeilisearchManager) GetUnsyncedCount() (int64, error)
- func (m *MeilisearchManager) GetUnsyncedResources(page, pageSize int) ([]entity.Resource, int64, error)
- func (m *MeilisearchManager) Initialize() error
- func (m *MeilisearchManager) IsEnabled() bool
- func (m *MeilisearchManager) ReloadConfig() error
- func (m *MeilisearchManager) Stop()
- func (m *MeilisearchManager) StopSync()
- func (m *MeilisearchManager) SyncAllResources() (int, error)
- func (m *MeilisearchManager) SyncResourceToMeilisearch(resource *entity.Resource) error
- type MeilisearchService
- func (m *MeilisearchService) BatchAddDocuments(docs []MeilisearchDocument) error
- func (m *MeilisearchService) ClearIndex() error
- func (m *MeilisearchService) CreateIndex() error
- func (m *MeilisearchService) DeleteDocument(documentID uint) error
- func (m *MeilisearchService) GetAllDocuments() ([]MeilisearchDocument, error)
- func (m *MeilisearchService) GetIndexStats() (map[string]interface{}, error)
- func (m *MeilisearchService) HealthCheck() error
- func (m *MeilisearchService) IsEnabled() bool
- func (m *MeilisearchService) Search(query string, filters map[string]interface{}, page, pageSize int) ([]MeilisearchDocument, int64, error)
- func (m *MeilisearchService) UpdateIndexSettings() error
- func (m *MeilisearchService) UpdateResourceValidity(resourceID uint, isValid bool) error
- type MeilisearchStatus
- type PanCheckClient
- type ResourceCheckResult
- type ResourceLinkService
- type ResourcesStats
- type SearchSession
- type SearchSessionManager
- func (m *SearchSessionManager) CreateSession(userID, keyword string, resources []entity.Resource, pageSize int) *SearchSession
- func (m *SearchSessionManager) GetCurrentPageResources(userID string) []entity.Resource
- func (m *SearchSessionManager) GetPageInfo(userID string) (currentPage, totalPages int, hasPrev, hasNext bool)
- func (m *SearchSessionManager) GetPageResources(userID string, page int) []entity.Resource
- func (m *SearchSessionManager) GetSession(userID string) *SearchSession
- func (m *SearchSessionManager) HasNextPage(userID string) bool
- func (m *SearchSessionManager) HasPrevPage(userID string) bool
- func (m *SearchSessionManager) NextPage(userID string) []entity.Resource
- func (m *SearchSessionManager) PrevPage(userID string) []entity.Resource
- func (m *SearchSessionManager) SetCurrentPage(userID string, page int) bool
- type SearchesStats
- type StatsService
- type StatsSummary
- type SyncProgress
- type TelegramBotConfig
- type TelegramBotService
- type TelegramBotServiceImpl
- func (s *TelegramBotServiceImpl) CleanupDuplicateChannels() error
- func (s *TelegramBotServiceImpl) DeleteMessage(chatID int64, messageID int) error
- func (s *TelegramBotServiceImpl) GetBotUsername() string
- func (s *TelegramBotServiceImpl) GetImgUrl(fid string) string
- func (s *TelegramBotServiceImpl) GetRuntimeStatus() map[string]interface{}
- func (s *TelegramBotServiceImpl) HandleWebhookUpdate(c interface{})
- func (s *TelegramBotServiceImpl) IsChannelRegistered(chatID int64) bool
- func (s *TelegramBotServiceImpl) IsRunning() bool
- func (s *TelegramBotServiceImpl) ManualPushToChannel(channelID uint) error
- func (s *TelegramBotServiceImpl) RegisterChannel(chatID int64, chatName, chatType string) error
- func (s *TelegramBotServiceImpl) ReloadConfig() error
- func (s *TelegramBotServiceImpl) SendMessage(chatID int64, text string, img string) error
- func (s *TelegramBotServiceImpl) Start() error
- func (s *TelegramBotServiceImpl) Stop() error
- func (s *TelegramBotServiceImpl) ValidateApiKey(apiKey string) (bool, map[string]interface{}, error)
- func (s *TelegramBotServiceImpl) ValidateApiKeyWithProxy(apiKey string, proxyEnabled bool, proxyType, proxyHost string, proxyPort int, ...) (bool, map[string]interface{}, error)
- type TgSearchSession
- type TgSearchSessionStore
- type TodosStats
- type TransferResult
- type UnifiedLinkResult
- type ViewDistributionItem
- type ViewsStats
- type WechatBotConfig
- type WechatBotService
- type WechatBotServiceImpl
- func (s *WechatBotServiceImpl) GetConfig() *WechatBotConfig
- func (s *WechatBotServiceImpl) GetRuntimeStatus() map[string]interface{}
- func (s *WechatBotServiceImpl) HandleMessage(msg *message.MixMessage) (interface{}, error)
- func (s *WechatBotServiceImpl) IsRunning() bool
- func (s *WechatBotServiceImpl) ReloadConfig() error
- func (s *WechatBotServiceImpl) SearchResources(keyword string) ([]entity.Resource, error)
- func (s *WechatBotServiceImpl) SendWelcomeMessage(openID string) error
- func (s *WechatBotServiceImpl) Start() error
- func (s *WechatBotServiceImpl) Stop() error
Constants ¶
This section is empty.
Variables ¶
var GlobalSearchSessionManager = NewSearchSessionManager()
GlobalSearchSessionManager 全局搜索会话管理器
Functions ¶
func ApplyValidityWriteback ¶ added in v1.4.0
func ApplyValidityWriteback( resource *entity.Resource, result ResourceCheckResult, resourceRepo repo.ResourceRepository, meiliManager *MeilisearchManager, )
ApplyValidityWriteback 仅在 is_valid 实际翻转时写回 DB + 同步 Meilisearch。 聚合规则:单资源多 URL 时任一 URL 失效即整体失效。
func NormalizeURL ¶ added in v1.4.0
NormalizeURL 规范化 URL(对齐 tg_tool normalize_url): 1. TrimSpace 2. 去掉 fragment(#...) 3. scheme + host 转小写(保留 path/query 原始大小写) 4. 去掉末尾 /
func SetDefaultStatsService ¶ added in v1.4.0
func SetDefaultStatsService(s *StatsService)
SetDefaultStatsService 设置默认统计服务实例(由 main.go 在初始化阶段调用)
func SetMeilisearchManager ¶ added in v1.3.3
func SetMeilisearchManager(manager *MeilisearchManager)
SetMeilisearchManager 设置Meilisearch管理器
func SetRepositoryManager ¶ added in v1.3.3
func SetRepositoryManager(manager *repo.RepositoryManager)
SetRepositoryManager 设置Repository管理器
func UnifiedSearchResources ¶ added in v1.3.3
func UnifiedSearchResources(keyword string, limit int, systemConfigRepo repo.SystemConfigRepository, resourceRepo repo.ResourceRepository) ([]entity.Resource, error)
UnifiedSearchResources 执行统一搜索(优先使用Meilisearch,否则使用数据库搜索)并处理违禁词
Types ¶
type CleanupService ¶ added in v1.4.0
type CleanupService struct {
// contains filtered or unexported fields
}
CleanupService 转存文件自动清理服务 周期性扫描已转存且超过保留期的资源,调用网盘 API 删除文件并清空转存字段
func NewCleanupService ¶ added in v1.4.0
func NewCleanupService( resourceRepo repo.ResourceRepository, configRepo repo.SystemConfigRepository, cksRepo repo.CksRepository, panRepo repo.PanRepository, ) *CleanupService
NewCleanupService 创建清理服务
type LinkCheckOutcome ¶ added in v1.4.0
type LinkCheckOutcome struct {
NormalizedURL string
Status LinkCheckStatus
Platform string
FailReason string
}
LinkCheckOutcome 单个 URL 的检测结论
type LinkCheckService ¶ added in v1.4.0
type LinkCheckService interface {
// CheckURL 检测单个 URL(scheduler 用)
CheckURL(ctx context.Context, rawURL string, ignoreCache bool) ResourceCheckResult
// CheckResources 批量检测资源(详情页用),返回 map[resourceID] -> 结论
CheckResources(ctx context.Context, resources []*entity.Resource, ignoreCache bool) map[uint]ResourceCheckResult
// CheckURLs 按 URL 批量检测(按 url 键返回)。供统一取链服务一次校验「原始链接 + saveUrl」(FR-013)。
CheckURLs(ctx context.Context, urls []string, ignoreCache bool) map[string]ResourceCheckResult
}
LinkCheckService 链接检测共享服务(两处检测点的唯一入口) 注:客户端不再维护本地缓存,缓存由 PanCheck 服务端自行管理。
func NewLinkCheckService ¶ added in v1.4.0
func NewLinkCheckService( client *PanCheckClient, systemConfigRepo repo.SystemConfigRepository, resourceRepo repo.ResourceRepository, meiliManager *MeilisearchManager, ) LinkCheckService
NewLinkCheckService 创建链接检测服务
type LinkCheckStatus ¶ added in v1.4.0
type LinkCheckStatus string
LinkCheckStatus 链接检测结果状态(二态:有效/失效)
const ( StatusValid LinkCheckStatus = "valid" StatusInvalid LinkCheckStatus = "invalid" )
type LinkResolution ¶ added in v1.5.3
type LinkResolution struct {
URL string
Type string // "transferred" | "original"
Platform string // pan.Remark(展示用)
Transferred bool
Note string // 可选提示(如易和谐提醒)
}
LinkResolution 取链结果
type MeilisearchDocument ¶
type MeilisearchDocument struct {
ID uint `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
SaveURL string `json:"save_url"`
FileSize string `json:"file_size"`
Key string `json:"key"`
Category string `json:"category"`
Tags []string `json:"tags"`
PanName string `json:"pan_name"`
PanID *uint `json:"pan_id"`
Author string `json:"author"`
Cover string `json:"cover"`
IsValid bool `json:"is_valid"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 高亮字段
TitleHighlight string `json:"_title_highlight,omitempty"`
DescriptionHighlight string `json:"_description_highlight,omitempty"`
CategoryHighlight string `json:"_category_highlight,omitempty"`
TagsHighlight []string `json:"_tags_highlight,omitempty"`
}
MeilisearchDocument 搜索文档结构
type MeilisearchManager ¶
type MeilisearchManager struct {
// contains filtered or unexported fields
}
MeilisearchManager Meilisearch管理器
func NewMeilisearchManager ¶
func NewMeilisearchManager(repoMgr *repo.RepositoryManager) *MeilisearchManager
NewMeilisearchManager 创建Meilisearch管理器
func (*MeilisearchManager) ClearIndex ¶
func (m *MeilisearchManager) ClearIndex() error
ClearIndex 清空索引
func (*MeilisearchManager) DebugGetAllDocuments ¶
func (m *MeilisearchManager) DebugGetAllDocuments() error
DebugGetAllDocuments 调试:获取所有文档
func (*MeilisearchManager) GetAllResources ¶
GetAllResources 获取所有资源
func (*MeilisearchManager) GetService ¶
func (m *MeilisearchManager) GetService() *MeilisearchService
GetService 获取Meilisearch服务
func (*MeilisearchManager) GetStatus ¶
func (m *MeilisearchManager) GetStatus() (MeilisearchStatus, error)
GetStatus 获取状态
func (*MeilisearchManager) GetStatusWithHealthCheck ¶
func (m *MeilisearchManager) GetStatusWithHealthCheck() (MeilisearchStatus, error)
GetStatusWithHealthCheck 获取状态并同时进行健康检查
func (*MeilisearchManager) GetSyncProgress ¶
func (m *MeilisearchManager) GetSyncProgress() SyncProgress
GetSyncProgress 获取同步进度
func (*MeilisearchManager) GetSyncedResources ¶
func (m *MeilisearchManager) GetSyncedResources(page, pageSize int) ([]entity.Resource, int64, error)
GetSyncedResources 获取已同步的资源
func (*MeilisearchManager) GetUnsyncedCount ¶
func (m *MeilisearchManager) GetUnsyncedCount() (int64, error)
GetUnsyncedCount 获取未同步资源数量
func (*MeilisearchManager) GetUnsyncedResources ¶
func (m *MeilisearchManager) GetUnsyncedResources(page, pageSize int) ([]entity.Resource, int64, error)
GetUnsyncedResources 获取未同步的资源
func (*MeilisearchManager) Initialize ¶
func (m *MeilisearchManager) Initialize() error
Initialize 初始化Meilisearch服务
func (*MeilisearchManager) IsEnabled ¶
func (m *MeilisearchManager) IsEnabled() bool
IsEnabled 检查是否启用
func (*MeilisearchManager) ReloadConfig ¶
func (m *MeilisearchManager) ReloadConfig() error
ReloadConfig 重新加载配置
func (*MeilisearchManager) SyncAllResources ¶
func (m *MeilisearchManager) SyncAllResources() (int, error)
SyncAllResources 同步所有资源
func (*MeilisearchManager) SyncResourceToMeilisearch ¶
func (m *MeilisearchManager) SyncResourceToMeilisearch(resource *entity.Resource) error
SyncResourceToMeilisearch 同步资源到Meilisearch
type MeilisearchService ¶
type MeilisearchService struct {
// contains filtered or unexported fields
}
MeilisearchService Meilisearch服务
func NewMeilisearchService ¶
func NewMeilisearchService(host, port, masterKey, indexName string, enabled bool) *MeilisearchService
NewMeilisearchService 创建Meilisearch服务
func (*MeilisearchService) BatchAddDocuments ¶
func (m *MeilisearchService) BatchAddDocuments(docs []MeilisearchDocument) error
BatchAddDocuments 批量添加文档
func (*MeilisearchService) ClearIndex ¶
func (m *MeilisearchService) ClearIndex() error
ClearIndex 清空索引
func (*MeilisearchService) CreateIndex ¶
func (m *MeilisearchService) CreateIndex() error
CreateIndex 创建索引
func (*MeilisearchService) DeleteDocument ¶ added in v1.3.1
func (m *MeilisearchService) DeleteDocument(documentID uint) error
DeleteDocument 删除单个文档
func (*MeilisearchService) GetAllDocuments ¶
func (m *MeilisearchService) GetAllDocuments() ([]MeilisearchDocument, error)
GetAllDocuments 获取所有文档(用于调试)
func (*MeilisearchService) GetIndexStats ¶
func (m *MeilisearchService) GetIndexStats() (map[string]interface{}, error)
GetIndexStats 获取索引统计信息
func (*MeilisearchService) HealthCheck ¶
func (m *MeilisearchService) HealthCheck() error
HealthCheck 健康检查
func (*MeilisearchService) IsEnabled ¶
func (m *MeilisearchService) IsEnabled() bool
IsEnabled 检查是否启用
func (*MeilisearchService) Search ¶
func (m *MeilisearchService) Search(query string, filters map[string]interface{}, page, pageSize int) ([]MeilisearchDocument, int64, error)
Search 搜索文档
func (*MeilisearchService) UpdateIndexSettings ¶
func (m *MeilisearchService) UpdateIndexSettings() error
UpdateIndexSettings 更新索引设置
func (*MeilisearchService) UpdateResourceValidity ¶ added in v1.3.7
func (m *MeilisearchService) UpdateResourceValidity(resourceID uint, isValid bool) error
UpdateResourceValidity 更新资源有效性状态
type MeilisearchStatus ¶
type MeilisearchStatus struct {
Enabled bool `json:"enabled"`
Healthy bool `json:"healthy"`
LastCheck time.Time `json:"last_check"`
ErrorCount int `json:"error_count"`
LastError string `json:"last_error"`
DocumentCount int64 `json:"document_count"`
}
MeilisearchStatus Meilisearch状态
type PanCheckClient ¶ added in v1.4.0
type PanCheckClient struct {
// contains filtered or unexported fields
}
PanCheckClient PanCheck HTTP 客户端
func NewPanCheckClient ¶ added in v1.4.0
func NewPanCheckClient() *PanCheckClient
NewPanCheckClient 创建 PanCheck 客户端
func (*PanCheckClient) Check ¶ added in v1.4.0
func (c *PanCheckClient) Check(ctx context.Context, host string, timeoutSeconds int, urls []string) (map[string]LinkCheckOutcome, error)
Check 调用 PanCheck 服务检测一批 URL。 返回的 map 以规范化 URL 为键,仅包含得出有效/失效结论的链接; 未得出结论(pending/既不在 valid 也不在 invalid)的链接不出现在 map 中。 当发生网络超时、非 2xx 响应、JSON 解析失败时返回 error,调用方应将整批视为未得出结论。
type ResourceCheckResult ¶ added in v1.4.0
type ResourceCheckResult struct {
// Status: "valid" / "invalid" / "undetermined"(未得出结论或未启用检测)
Status string
// FailReason 失效原因(仅 status=invalid 时有值)
FailReason string
// Platform 识别到的平台
Platform string
// DetectionMethod: "pancheck"(启用并得出结论或启用但未得出结论)/ "disabled"(未启用)
DetectionMethod string
}
ResourceCheckResult 资源维度的检测结论
type ResourceLinkService ¶ added in v1.5.3
type ResourceLinkService interface {
Resolve(ctx context.Context, resource *entity.Resource) (LinkResolution, error)
// ResolveWithCheck 统一取链决策树(FR-013~FR-017):双链接批量校验 → 仅原始驱动回写 →
// saveUrl 有效直返 / saveUrl 失效先分享 / 原始失效判失效 / 原始有效转存。
ResolveWithCheck(ctx context.Context, resource *entity.Resource) (UnifiedLinkResult, error)
}
ResourceLinkService 资源取链服务:网页端 GetResourceLink 与电报机器人共用,避免逻辑漂移。 访问计数 / 来源归因由调用方各自处理(网页=web,机器人=telegram)。 Feature: 011-telegram-bot-enhance
func NewResourceLinkService ¶ added in v1.5.3
func NewResourceLinkService(cksRepo repo.CksRepository, panRepo repo.PanRepository, configRepo repo.SystemConfigRepository, resourceRepo repo.ResourceRepository, linkCheckService LinkCheckService, meiliManager *MeilisearchManager) ResourceLinkService
NewResourceLinkService 创建取链服务
type ResourcesStats ¶ added in v1.4.0
type ResourcesStats struct {
Today int64 `json:"today"`
Yesterday int64 `json:"yesterday"`
Total int64 `json:"total"`
InvalidTotal int64 `json:"invalid_total"` // 009: 失效资源总数(is_valid=false)
SyncedTotal int64 `json:"synced_total"` // 009: 已同步搜索索引资源数
TodayInvalid int64 `json:"today_invalid"` // 009: 今日失效资源数
TodaySynced int64 `json:"today_synced"` // 009: 今日新同步资源数
}
ResourcesStats 资源指标(今日/昨日/总量 + 失效/同步)
type SearchSession ¶ added in v1.3.3
type SearchSession struct {
UserID string // 用户ID
Keyword string // 搜索关键字
Resources []entity.Resource // 搜索结果
PageSize int // 每页数量
CurrentPage int // 当前页码
TotalPages int // 总页数
LastAccess time.Time // 最后访问时间
}
SearchSession 搜索会话
type SearchSessionManager ¶ added in v1.3.3
type SearchSessionManager struct {
// contains filtered or unexported fields
}
SearchSessionManager 搜索会话管理器
func NewSearchSessionManager ¶ added in v1.3.3
func NewSearchSessionManager() *SearchSessionManager
NewSearchSessionManager 创建搜索会话管理器
func (*SearchSessionManager) CreateSession ¶ added in v1.3.3
func (m *SearchSessionManager) CreateSession(userID, keyword string, resources []entity.Resource, pageSize int) *SearchSession
CreateSession 创建或更新搜索会话
func (*SearchSessionManager) GetCurrentPageResources ¶ added in v1.3.3
func (m *SearchSessionManager) GetCurrentPageResources(userID string) []entity.Resource
GetCurrentPageResources 获取当前页的资源
func (*SearchSessionManager) GetPageInfo ¶ added in v1.3.3
func (m *SearchSessionManager) GetPageInfo(userID string) (currentPage, totalPages int, hasPrev, hasNext bool)
GetPageInfo 获取分页信息
func (*SearchSessionManager) GetPageResources ¶ added in v1.3.3
func (m *SearchSessionManager) GetPageResources(userID string, page int) []entity.Resource
GetPageResources 获取指定页的资源
func (*SearchSessionManager) GetSession ¶ added in v1.3.3
func (m *SearchSessionManager) GetSession(userID string) *SearchSession
GetSession 获取搜索会话
func (*SearchSessionManager) HasNextPage ¶ added in v1.3.3
func (m *SearchSessionManager) HasNextPage(userID string) bool
HasNextPage 是否有下一页
func (*SearchSessionManager) HasPrevPage ¶ added in v1.3.3
func (m *SearchSessionManager) HasPrevPage(userID string) bool
HasPrevPage 是否有上一页
func (*SearchSessionManager) NextPage ¶ added in v1.3.3
func (m *SearchSessionManager) NextPage(userID string) []entity.Resource
NextPage 下一页
func (*SearchSessionManager) PrevPage ¶ added in v1.3.3
func (m *SearchSessionManager) PrevPage(userID string) []entity.Resource
PrevPage 上一页
func (*SearchSessionManager) SetCurrentPage ¶ added in v1.3.3
func (m *SearchSessionManager) SetCurrentPage(userID string, page int) bool
SetCurrentPage 设置当前页
type SearchesStats ¶ added in v1.4.0
SearchesStats 搜索量指标
type StatsService ¶ added in v1.4.0
type StatsService struct {
// contains filtered or unexported fields
}
StatsService 统计聚合服务
设计说明:
- 独立于 HTTP 层,便于集成测试直接调用 GetSummary()
- 通过构造函数注入 db 与 repoManager,避免对 package-level 全局状态的依赖
- 保持与现有 GetStats handler 直接操作 DB 的模式一致(无额外抽象层)
func GetDefaultStatsService ¶ added in v1.4.0
func GetDefaultStatsService() *StatsService
GetDefaultStatsService 获取默认统计服务实例(handler 与测试共用)
func NewStatsService ¶ added in v1.4.0
func NewStatsService(database *gorm.DB, repoMgr *repo.RepositoryManager) *StatsService
NewStatsService 创建统计聚合服务实例
func (*StatsService) GetSummary ¶ added in v1.4.0
func (s *StatsService) GetSummary() (*StatsSummary, error)
GetSummary 仪表盘首屏聚合统计(含环比昨日与待办)
时区:按 Asia/Shanghai (UTC+8) 计算日期边界(00:00:00) 错误降级:浏览量查询失败时记 warning 并归零(与现有 GetStats 一致) 负值防护:理论不会出现负 COUNT,防御性 clamp 至 0
type StatsSummary ¶ added in v1.4.0
type StatsSummary struct {
Resources ResourcesStats `json:"resources"`
Views ViewsStats `json:"views"`
Searches SearchesStats `json:"searches"`
Todos TodosStats `json:"todos"`
ViewPanDistribution []ViewDistributionItem `json:"view_pan_distribution"`
ViewSourceDistribution []ViewDistributionItem `json:"view_source_distribution"`
}
StatsSummary 仪表盘首屏聚合数据 契约: specs/004-admin-ui-optimization/contracts/stats-summary-api.md 该结构序列化后与原 handlers.GetSummary 的 gin.H 嵌套结构等价
type SyncProgress ¶
type SyncProgress struct {
IsRunning bool `json:"is_running"`
TotalCount int64 `json:"total_count"`
ProcessedCount int64 `json:"processed_count"`
SyncedCount int64 `json:"synced_count"`
FailedCount int64 `json:"failed_count"`
StartTime time.Time `json:"start_time"`
EstimatedTime string `json:"estimated_time"`
CurrentBatch int `json:"current_batch"`
TotalBatches int `json:"total_batches"`
ErrorMessage string `json:"error_message"`
}
SyncProgress 同步进度
type TelegramBotConfig ¶ added in v1.3.0
type TelegramBotConfig struct {
Enabled bool
ApiKey string
AutoReplyEnabled bool
AutoReplyTemplate string
AutoDeleteEnabled bool
AutoDeleteInterval int // 分钟
SearchPageSize int // 011:搜索每页条数(钳制 3–8)
ProxyEnabled bool
ProxyType string // http, https, socks5
ProxyHost string
ProxyPort int
ProxyUsername string
ProxyPassword string
WelcomeEnabled bool // 入群欢迎开关
WelcomeMessage string // 入群欢迎模板(支持 {{username}} {{chatname}} 占位符)
}
type TelegramBotService ¶ added in v1.3.0
type TelegramBotService interface {
Start() error
Stop() error
IsRunning() bool
ReloadConfig() error
GetRuntimeStatus() map[string]interface{}
ValidateApiKey(apiKey string) (bool, map[string]interface{}, error)
ValidateApiKeyWithProxy(apiKey string, proxyEnabled bool, proxyType, proxyHost string, proxyPort int, proxyUsername, proxyPassword string) (bool, map[string]interface{}, error)
GetBotUsername() string
SendMessage(chatID int64, text string, img string) error
DeleteMessage(chatID int64, messageID int) error
RegisterChannel(chatID int64, chatName, chatType string) error
IsChannelRegistered(chatID int64) bool
HandleWebhookUpdate(c interface{})
CleanupDuplicateChannels() error
ManualPushToChannel(channelID uint) error
}
func NewTelegramBotService ¶ added in v1.3.0
func NewTelegramBotService( systemConfigRepo repo.SystemConfigRepository, channelRepo repo.TelegramChannelRepository, resourceRepo repo.ResourceRepository, readyResourceRepo repo.ReadyResourceRepository, meilisearchManager *MeilisearchManager, sessions TgSearchSessionStore, linkCheckService LinkCheckService, linkService ResourceLinkService, searchStatRepo repo.SearchStatRepository, resourceViewRepo repo.ResourceViewRepository, ) TelegramBotService
type TelegramBotServiceImpl ¶ added in v1.3.0
type TelegramBotServiceImpl struct {
// contains filtered or unexported fields
}
func (*TelegramBotServiceImpl) CleanupDuplicateChannels ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) CleanupDuplicateChannels() error
CleanupDuplicateChannels 清理数据库中的重复频道记录
func (*TelegramBotServiceImpl) DeleteMessage ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) DeleteMessage(chatID int64, messageID int) error
DeleteMessage 删除消息
func (*TelegramBotServiceImpl) GetBotUsername ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) GetBotUsername() string
GetBotUsername 获取机器人用户名
func (*TelegramBotServiceImpl) GetImgUrl ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) GetImgUrl(fid string) string
func (*TelegramBotServiceImpl) GetRuntimeStatus ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) GetRuntimeStatus() map[string]interface{}
GetRuntimeStatus 获取机器人运行时状态
func (*TelegramBotServiceImpl) HandleWebhookUpdate ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) HandleWebhookUpdate(c interface{})
HandleWebhookUpdate 处理 Webhook 更新(预留接口,目前使用长轮询)
func (*TelegramBotServiceImpl) IsChannelRegistered ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) IsChannelRegistered(chatID int64) bool
IsChannelRegistered 检查频道是否已注册
func (*TelegramBotServiceImpl) IsRunning ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) IsRunning() bool
IsRunning 检查机器人服务是否正在运行
func (*TelegramBotServiceImpl) ManualPushToChannel ¶ added in v1.3.5
func (s *TelegramBotServiceImpl) ManualPushToChannel(channelID uint) error
ManualPushToChannel 手动推送内容到指定频道
func (*TelegramBotServiceImpl) RegisterChannel ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) RegisterChannel(chatID int64, chatName, chatType string) error
RegisterChannel 注册频道
func (*TelegramBotServiceImpl) ReloadConfig ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) ReloadConfig() error
ReloadConfig 重新加载机器人配置
func (*TelegramBotServiceImpl) SendMessage ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) SendMessage(chatID int64, text string, img string) error
SendMessage 发送消息(默认使用 HTML 格式)
func (*TelegramBotServiceImpl) Start ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) Start() error
Start 启动机器人服务
func (*TelegramBotServiceImpl) Stop ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) Stop() error
Stop 停止机器人服务
func (*TelegramBotServiceImpl) ValidateApiKey ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) ValidateApiKey(apiKey string) (bool, map[string]interface{}, error)
ValidateApiKey 验证 API Key
func (*TelegramBotServiceImpl) ValidateApiKeyWithProxy ¶ added in v1.3.0
func (s *TelegramBotServiceImpl) ValidateApiKeyWithProxy(apiKey string, proxyEnabled bool, proxyType, proxyHost string, proxyPort int, proxyUsername, proxyPassword string) (bool, map[string]interface{}, error)
ValidateApiKeyWithProxy 使用代理配置验证 API Key
type TgSearchSession ¶ added in v1.5.3
type TgSearchSession struct {
SessionID string
ChatID int64
UserID int64
Keyword string
PageSize int
Total int64
CreatedAt time.Time
}
TgSearchSession 一次 Telegram 搜索的分页状态(进程内、非持久化)。 用于在 Telegram callback_data 的 64 字节限制下,承载关键字/页大小等翻页所需上下文。 与 SearchSession(wechat 用)语义不同,故独立命名。 Feature: 011-telegram-bot-enhance
type TgSearchSessionStore ¶ added in v1.5.3
type TgSearchSessionStore interface {
Create(chatID, userID int64, keyword string, pageSize int, total int64) *TgSearchSession
Get(sessionID string) (*TgSearchSession, bool)
Delete(sessionID string)
}
TgSearchSessionStore Telegram 分页 session 存储抽象
func NewInMemoryTgSearchSessionStore ¶ added in v1.5.3
func NewInMemoryTgSearchSessionStore(maxSize int, ttl time.Duration) TgSearchSessionStore
NewInMemoryTgSearchSessionStore 创建进程内分页 session 存储
type TodosStats ¶ added in v1.4.0
type TodosStats struct {
ReadyResources int64 `json:"ready_resources"`
FailedTasks int64 `json:"failed_tasks"`
PendingReports int64 `json:"pending_reports"`
}
TodosStats 待办事项聚合
type TransferResult ¶ added in v1.5.3
type TransferResult struct {
Success bool `json:"success"`
Fid string `json:"fid"`
SaveURL string `json:"save_url"`
ErrorMsg string `json:"error_msg"`
}
TransferResult 转存结果(由 handlers 迁移至 services,供网页端与电报机器人共用)
func PerformAutoTransfer ¶ added in v1.5.3
func PerformAutoTransfer(cksRepo repo.CksRepository, configRepo repo.SystemConfigRepository, resourceRepo repo.ResourceRepository, resource *entity.Resource) TransferResult
PerformAutoTransfer 执行自动转存(由 handlers 迁移,逻辑保持一致)。 传入所需仓库,避免依赖包级 repoManager,便于网页端与机器人共用。
func PerformShare ¶ added in v1.5.4
func PerformShare(cksRepo repo.CksRepository, resourceRepo repo.ResourceRepository, resource *entity.Resource) TransferResult
PerformShare 对系统已存文件按 fid 重新生成分享链接(saveUrl 失效时的恢复操作,FR-015)。 镜像 PerformAutoTransfer 的结构:按 resource.CkID 取持有账号 → 创建网盘服务 → 类型断言 Sharer → Share(fid)。 仅回写 save_url(刷新链接);不改 fid/ck_id/transferred_at(文件未变,自动清理计时不重置)。 失败时调用方(决策树 ResolveWithCheck)会回退到「判原始→转存」,故此处失败是安全的降级。
type UnifiedLinkResult ¶ added in v1.5.4
type UnifiedLinkResult struct {
URL string // 最终交付链接(Invalid=true 时为空)
Type string // "transferred" | "reshared" | "original" | "invalid"
Invalid bool // 资源判定失效(原始链接失效)→ 调用方给失效提示、不交付链接
Platform string // 展示用平台名
Note string // 可选提示(如易和谐提醒)
Refreshed bool // 是否刷新了 saveUrl(分享/转存成功并回写)
}
UnifiedLinkResult 统一取链决策输出(决策树 FR-013~FR-017,Telegram/公众号/QQ 共用)
type ViewDistributionItem ¶ added in v1.5.1
type ViewDistributionItem struct {
Key string `json:"key"`
Name string `json:"name"`
Count int64 `json:"count"`
Percent int `json:"percent"`
}
ViewDistributionItem 访问分布项(网盘 / 来源通用)。009-statistics-enhancement
type ViewsStats ¶ added in v1.4.0
type ViewsStats struct {
Today int64 `json:"today"`
Yesterday int64 `json:"yesterday"`
Total int64 `json:"total"` // 009: 访问(获取资源)总次数
}
ViewsStats 浏览量指标
type WechatBotConfig ¶ added in v1.3.3
type WechatBotConfig struct {
Enabled bool
AppID string
AppSecret string
Token string
EncodingAesKey string
WelcomeMessage string
AutoReplyEnabled bool
SearchLimit int
}
WechatBotConfig 微信公众号机器人配置
type WechatBotService ¶ added in v1.3.3
type WechatBotService interface {
Start() error
Stop() error
IsRunning() bool
ReloadConfig() error
HandleMessage(msg *message.MixMessage) (interface{}, error)
SendWelcomeMessage(openID string) error
GetRuntimeStatus() map[string]interface{}
GetConfig() *WechatBotConfig
}
WechatBotService 微信公众号机器人服务接口
func NewWechatBotService ¶ added in v1.3.3
func NewWechatBotService( systemConfigRepo repo.SystemConfigRepository, resourceRepo repo.ResourceRepository, readyResourceRepo repo.ReadyResourceRepository, linkService ResourceLinkService, ) WechatBotService
NewWechatBotService 创建微信公众号机器人服务
type WechatBotServiceImpl ¶ added in v1.3.3
type WechatBotServiceImpl struct {
// contains filtered or unexported fields
}
WechatBotServiceImpl 微信公众号机器人服务实现
func (*WechatBotServiceImpl) GetConfig ¶ added in v1.3.3
func (s *WechatBotServiceImpl) GetConfig() *WechatBotConfig
GetConfig 获取当前配置
func (*WechatBotServiceImpl) GetRuntimeStatus ¶ added in v1.3.3
func (s *WechatBotServiceImpl) GetRuntimeStatus() map[string]interface{}
GetRuntimeStatus 获取微信公众号机器人运行时状态
func (*WechatBotServiceImpl) HandleMessage ¶ added in v1.3.3
func (s *WechatBotServiceImpl) HandleMessage(msg *message.MixMessage) (interface{}, error)
HandleMessage 处理微信消息
func (*WechatBotServiceImpl) IsRunning ¶ added in v1.3.3
func (s *WechatBotServiceImpl) IsRunning() bool
IsRunning 检查微信公众号机器人服务是否正在运行
func (*WechatBotServiceImpl) ReloadConfig ¶ added in v1.3.3
func (s *WechatBotServiceImpl) ReloadConfig() error
ReloadConfig 重新加载微信公众号机器人配置
func (*WechatBotServiceImpl) SearchResources ¶ added in v1.3.3
func (s *WechatBotServiceImpl) SearchResources(keyword string) ([]entity.Resource, error)
SearchResources 搜索资源
func (*WechatBotServiceImpl) SendWelcomeMessage ¶ added in v1.3.3
func (s *WechatBotServiceImpl) SendWelcomeMessage(openID string) error
SendWelcomeMessage 发送欢迎消息(预留接口,实际通过事件处理)
func (*WechatBotServiceImpl) Start ¶ added in v1.3.3
func (s *WechatBotServiceImpl) Start() error
Start 启动微信公众号机器人服务
func (*WechatBotServiceImpl) Stop ¶ added in v1.3.3
func (s *WechatBotServiceImpl) Stop() error
Stop 停止微信公众号机器人服务