Documentation
¶
Index ¶
- Constants
- Variables
- func CheckContainsForbiddenWords(text string, forbiddenWords []string) (bool, []string)
- func CleanAllExpiredCaches(ttl time.Duration)
- func ClearAllCaches()
- func ClearOldTelegramLogs(daysToKeep int) error
- func Debug(format string, args ...interface{})
- func DebugWithFields(fields map[string]interface{}, format string, args ...interface{})
- func Error(format string, args ...interface{})
- func ErrorWithFields(fields map[string]interface{}, format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func FormatTime(t time.Time, layout string) string
- func GetCurrentTime() time.Time
- func GetCurrentTimeRFC3339() string
- func GetCurrentTimeString() string
- func GetCurrentTimestamp() int64
- func GetCurrentTimestampNano() int64
- func GetErrorSummary(err error) string
- func GetFileInfo(filepath string) (os.FileInfo, error)
- func GetForbiddenWordsFromConfig(getConfigFunc func() (string, error)) ([]string, error)
- func GetFullVersionInfo() string
- func GetTelegramLogStats(hours int) (map[string]interface{}, error)
- func GetTodayString() string
- func GetVersionComponents(version string) (major, minor, patch int, err error)
- func GetVersionString() string
- func Info(format string, args ...interface{})
- func InfoWithFields(fields map[string]interface{}, format string, args ...interface{})
- func InitLogger() error
- func InitTimezone()
- func IsResourceError(err error) bool
- func IsRetryableError(err error) bool
- func IsVersionNewer(version1, version2 string) bool
- func Min(a, b int) int
- func ParseForbiddenWordsConfig(config string) []string
- func ParseTime(timeStr string) (time.Time, error)
- func ProcessForbiddenWords(text string, forbiddenWords []string) (bool, []string, string)
- func ProcessResourcesForbiddenWords(resources []entity.Resource, forbiddenWords []string) []entity.Resource
- func RemoveDuplicates(slice []string) []string
- func ReplaceForbiddenWords(text string, forbiddenWords []string) string
- func ReplaceForbiddenWordsWithHighlight(text string, forbiddenWords []string) string
- func SaveVersionToFile(filename string, info *VersionInfo) error
- func SortLogEntriesByTime(entries []LogEntry, ascending bool)
- func TelegramDebug(format string, args ...interface{})
- func TelegramError(format string, args ...interface{})
- func TelegramInfo(format string, args ...interface{})
- func TelegramWarn(format string, args ...interface{})
- func Warn(format string, args ...interface{})
- type CacheData
- type CacheManager
- func (cm *CacheManager) CleanExpired(ttl time.Duration) int
- func (cm *CacheManager) Clear()
- func (cm *CacheManager) Delete(key string)
- func (cm *CacheManager) DeletePattern(pattern string)
- func (cm *CacheManager) Get(key string, ttl time.Duration) (interface{}, bool)
- func (cm *CacheManager) GetKeys() []string
- func (cm *CacheManager) GetWithTTL(key string, ttl time.Duration) (interface{}, bool, time.Duration)
- func (cm *CacheManager) Set(key string, data interface{})
- func (cm *CacheManager) Size() int
- type DoubanCategory
- type DoubanItem
- type DoubanResponse
- type DoubanResult
- type DoubanService
- func (ds *DoubanService) GetRank(url string) ([]DoubanItem, error)
- func (ds *DoubanService) GetRecentHotMovies() ([]DoubanItem, error)
- func (ds *DoubanService) GetRecentHotShows() ([]DoubanItem, error)
- func (ds *DoubanService) GetRecentHotTVs() ([]DoubanItem, error)
- func (ds *DoubanService) GetTop250Movies() ([]DoubanItem, error)
- type ErrorType
- type ForbiddenWordsProcessor
- func (p *ForbiddenWordsProcessor) CheckContainsForbiddenWords(text string, forbiddenWords []string) (bool, []string)
- func (p *ForbiddenWordsProcessor) ParseForbiddenWordsConfig(config string) []string
- func (p *ForbiddenWordsProcessor) ProcessForbiddenWords(text string, forbiddenWords []string) (bool, []string, string)
- func (p *ForbiddenWordsProcessor) ReplaceForbiddenWords(text string, forbiddenWords []string) string
- func (p *ForbiddenWordsProcessor) ReplaceForbiddenWordsWithHighlight(text string, forbiddenWords []string) string
- type LogEntry
- type LogLevel
- type LogViewer
- func (lv *LogViewer) CleanOldLogs(days int) error
- func (lv *LogViewer) GetLogFiles() ([]string, error)
- func (lv *LogViewer) GetLogStats(files []string) (map[string]int, error)
- func (lv *LogViewer) ParseLogEntriesFromFile(filename string, levelFilter string, searchFilter string) ([]LogEntry, error)
- func (lv *LogViewer) ReadLogFile(filename string, lines int) ([]string, error)
- func (lv *LogViewer) SearchLogs(pattern string, files []string) ([]LogEntry, error)
- func (lv *LogViewer) TailLog(filename string, callback func(string)) error
- type Logger
- func (l *Logger) Close()
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) DebugWithFields(fields map[string]interface{}, format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) ErrorWithFields(fields map[string]interface{}, format string, args ...interface{})
- func (l *Logger) Fatal(format string, args ...interface{})
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) InfoWithFields(fields map[string]interface{}, format string, args ...interface{})
- func (l *Logger) TelegramDebug(format string, args ...interface{})
- func (l *Logger) TelegramError(format string, args ...interface{})
- func (l *Logger) TelegramInfo(format string, args ...interface{})
- func (l *Logger) TelegramWarn(format string, args ...interface{})
- func (l *Logger) Warn(format string, args ...interface{})
- type PicInfo
- type Rating
- type ResourceError
- func GetResourceError(err error) *ResourceError
- func NewCategoryProcessingError(details string) *ResourceError
- func NewInvalidLinkError(url string, details string) *ResourceError
- func NewLinkCheckError(url string, details string) *ResourceError
- func NewNoAccountError(platform string) *ResourceError
- func NewNoValidAccountError(platform string) *ResourceError
- func NewPlatformNotFoundError(platform string) *ResourceError
- func NewResourceError(errorType ErrorType, message string, url string, details string) *ResourceError
- func NewResourceSaveError(url string, details string) *ResourceError
- func NewServiceCreationError(url string, details string) *ResourceError
- func NewTagProcessingError(details string) *ResourceError
- func NewTransferFailedError(url string, details string) *ResourceError
- func NewUnsupportedLinkError(url string) *ResourceError
- type ResourceForbiddenInfo
- type TelegramLogEntry
- type VersionInfo
Constants ¶
const ( TimeFormatDate = "2006-01-02" TimeFormatDateTime = "2006-01-02 15:04:05" TimeFormatRFC3339 = time.RFC3339 )
时间格式常量
Variables ¶
var ( // 热门资源缓存 HotResourcesCache = NewCacheManager() // 相关资源缓存 RelatedResourcesCache = NewCacheManager() // 系统配置缓存 SystemConfigCache = NewCacheManager() // 分类缓存 CategoriesCache = NewCacheManager() // 标签缓存 TagsCache = NewCacheManager() // 资源有效性检测缓存 ResourceValidityCache = NewCacheManager() )
全局缓存管理器实例
var ( // 这些变量将在编译时通过 ldflags 注入 Version = "unknown" // 默认版本,编译时会被覆盖 BuildTime = GetCurrentTimeString() GitCommit = "unknown" GitBranch = "unknown" )
编译时注入的版本信息
var DefaultForbiddenWordsProcessor = NewForbiddenWordsProcessor()
全局实例,方便直接调用
Functions ¶
func CheckContainsForbiddenWords ¶ added in v1.2.5
CheckContainsForbiddenWords 检查字符串是否包含违禁词(便捷函数)
func CleanAllExpiredCaches ¶ added in v1.3.5
CleanAllExpiredCaches 清理所有过期缓存
func ClearOldTelegramLogs ¶ added in v1.3.0
ClearOldTelegramLogs 清理旧的Telegram日志(保留最近N天的日志)
func DebugWithFields ¶ added in v1.3.2
func ErrorWithFields ¶ added in v1.3.2
func FormatTime ¶ added in v1.0.10
FormatTime 格式化时间(使用配置的时区)
func GetCurrentTime ¶ added in v1.0.10
GetCurrentTime 获取当前时间(使用配置的时区)
func GetCurrentTimeRFC3339 ¶ added in v1.0.10
func GetCurrentTimeRFC3339() string
GetCurrentTimeRFC3339 获取当前时间RFC3339格式(使用配置的时区)
func GetCurrentTimeString ¶ added in v1.0.10
func GetCurrentTimeString() string
GetCurrentTimeString 获取当前时间字符串(使用配置的时区)
func GetCurrentTimestamp ¶ added in v1.2.0
func GetCurrentTimestamp() int64
GetCurrentTimestamp 获取当前时间戳
func GetCurrentTimestampNano ¶ added in v1.2.0
func GetCurrentTimestampNano() int64
GetCurrentTimestampNano 获取当前纳秒时间戳
func GetErrorSummary ¶ added in v1.0.10
GetErrorSummary 获取错误摘要
func GetFileInfo ¶ added in v1.3.2
GetFileInfo 获取文件信息
func GetForbiddenWordsFromConfig ¶ added in v1.2.5
GetForbiddenWordsFromConfig 从系统配置获取违禁词列表 参数:
- getConfigFunc: 获取配置的函数
返回:
- []string: 解析后的违禁词列表
- error: 获取配置时的错误
func GetTelegramLogStats ¶ added in v1.3.0
GetTelegramLogStats 获取Telegram日志统计
func GetVersionComponents ¶
GetVersionComponents 获取版本号组件
func InfoWithFields ¶ added in v1.3.2
func IsResourceError ¶ added in v1.0.10
IsResourceError 检查是否为资源错误
func IsRetryableError ¶ added in v1.0.10
IsRetryableError 检查是否为可重试的错误
func ParseForbiddenWordsConfig ¶ added in v1.2.5
ParseForbiddenWordsConfig 解析违禁词配置字符串(便捷函数)
func ProcessForbiddenWords ¶ added in v1.2.5
ProcessForbiddenWords 处理违禁词:检查并替换(便捷函数)
func ProcessResourcesForbiddenWords ¶ added in v1.2.5
func ProcessResourcesForbiddenWords(resources []entity.Resource, forbiddenWords []string) []entity.Resource
ProcessResourcesForbiddenWords 批量处理资源的违禁词 参数:
- resources: 资源切片
- forbiddenWords: 违禁词列表
返回:
- 处理后的资源切片
func RemoveDuplicates ¶ added in v1.2.5
RemoveDuplicates 去除字符串切片中的重复项
func ReplaceForbiddenWords ¶ added in v1.2.5
ReplaceForbiddenWords 替换字符串中的违禁词为 *(便捷函数)
func ReplaceForbiddenWordsWithHighlight ¶ added in v1.2.5
ReplaceForbiddenWordsWithHighlight 替换字符串中的违禁词为 *(处理高亮标记,便捷函数)
func SaveVersionToFile ¶
func SaveVersionToFile(filename string, info *VersionInfo) error
SaveVersionToFile 保存版本信息到文件
func SortLogEntriesByTime ¶ added in v1.3.2
SortLogEntriesByTime 按时间对日志条目进行排序
func TelegramDebug ¶ added in v1.3.5
func TelegramDebug(format string, args ...interface{})
func TelegramError ¶ added in v1.3.5
func TelegramError(format string, args ...interface{})
func TelegramInfo ¶ added in v1.3.5
func TelegramInfo(format string, args ...interface{})
func TelegramWarn ¶ added in v1.3.5
func TelegramWarn(format string, args ...interface{})
Types ¶
type CacheManager ¶ added in v1.3.5
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager 通用缓存管理器
func GetCategoriesCache ¶ added in v1.3.5
func GetCategoriesCache() *CacheManager
GetCategoriesCache 获取分类缓存管理器
func GetHotResourcesCache ¶ added in v1.3.5
func GetHotResourcesCache() *CacheManager
GetHotResourcesCache 获取热门资源缓存管理器
func GetRelatedResourcesCache ¶ added in v1.3.5
func GetRelatedResourcesCache() *CacheManager
GetRelatedResourcesCache 获取相关资源缓存管理器
func GetResourceValidityCache ¶ added in v1.3.5
func GetResourceValidityCache() *CacheManager
GetResourceValidityCache 获取资源有效性检测缓存管理器
func GetSystemConfigCache ¶ added in v1.3.5
func GetSystemConfigCache() *CacheManager
GetSystemConfigCache 获取系统配置缓存管理器
func (*CacheManager) CleanExpired ¶ added in v1.3.5
func (cm *CacheManager) CleanExpired(ttl time.Duration) int
CleanExpired 清理过期缓存
func (*CacheManager) Delete ¶ added in v1.3.5
func (cm *CacheManager) Delete(key string)
Delete 删除缓存
func (*CacheManager) DeletePattern ¶ added in v1.3.5
func (cm *CacheManager) DeletePattern(pattern string)
DeletePattern 删除匹配模式的缓存
func (*CacheManager) Get ¶ added in v1.3.5
func (cm *CacheManager) Get(key string, ttl time.Duration) (interface{}, bool)
Get 获取缓存
func (*CacheManager) GetKeys ¶ added in v1.3.5
func (cm *CacheManager) GetKeys() []string
GetKeys 获取所有缓存键
func (*CacheManager) GetWithTTL ¶ added in v1.3.5
func (cm *CacheManager) GetWithTTL(key string, ttl time.Duration) (interface{}, bool, time.Duration)
GetWithTTL 获取缓存并返回剩余TTL
func (*CacheManager) Set ¶ added in v1.3.5
func (cm *CacheManager) Set(key string, data interface{})
Set 设置缓存
type DoubanCategory ¶
type DoubanCategory struct {
Category string `json:"category"`
Selected bool `json:"selected"`
Type string `json:"type"`
Title string `json:"title"`
}
DoubanCategory 豆瓣分类
type DoubanItem ¶
type DoubanItem struct {
ID string `json:"id"`
Title string `json:"title"`
CardSubtitle string `json:"card_subtitle"`
EpisodesInfo string `json:"episodes_info"`
IsNew bool `json:"is_new"`
Pic PicInfo `json:"pic"`
Rating Rating `json:"rating"`
Type string `json:"type"`
URI string `json:"uri"`
Year string `json:"year"`
Directors []string `json:"directors"`
Actors []string `json:"actors"`
Region string `json:"region"`
Genres []string `json:"genres"`
}
DoubanItem 豆瓣项目
type DoubanResponse ¶
type DoubanResponse struct {
Items []DoubanItem `json:"items"`
Categories []DoubanCategory `json:"categories"`
Total int `json:"total"`
IsMockData bool `json:"is_mock_data,omitempty"`
MockReason string `json:"mock_reason,omitempty"`
Notice string `json:"notice,omitempty"`
}
DoubanResponse 豆瓣响应
type DoubanResult ¶
type DoubanResult struct {
Success bool `json:"success"`
Data *DoubanResponse `json:"data,omitempty"`
Message string `json:"message,omitempty"`
}
DoubanResult 豆瓣结果
type DoubanService ¶
type DoubanService struct {
// 电影榜单配置 - 4个大类,每个大类下有5个小类
MovieCategories map[string]map[string]map[string]string
// 剧集榜单配置 - 2个大类
TvCategories map[string]map[string]map[string]string
// contains filtered or unexported fields
}
DoubanService 豆瓣服务
func (*DoubanService) GetRank ¶ added in v1.3.0
func (ds *DoubanService) GetRank(url string) ([]DoubanItem, error)
GetRank fetches recent rank info
func (*DoubanService) GetRecentHotMovies ¶ added in v1.3.0
func (ds *DoubanService) GetRecentHotMovies() ([]DoubanItem, error)
GetRecentHotMovies fetches recent hot movies
func (*DoubanService) GetRecentHotShows ¶ added in v1.3.0
func (ds *DoubanService) GetRecentHotShows() ([]DoubanItem, error)
GetRecentHotShows fetches recent hot shows
func (*DoubanService) GetRecentHotTVs ¶ added in v1.3.0
func (ds *DoubanService) GetRecentHotTVs() ([]DoubanItem, error)
GetRecentHotTVs fetches recent hot TV shows
func (*DoubanService) GetTop250Movies ¶ added in v1.3.0
func (ds *DoubanService) GetTop250Movies() ([]DoubanItem, error)
GetTop250Movies fetches top 250 movies
type ErrorType ¶ added in v1.0.10
type ErrorType string
ErrorType 错误类型枚举
const ( // ErrorTypeUnsupportedLink 不支持的链接 ErrorTypeUnsupportedLink ErrorType = "UNSUPPORTED_LINK" // ErrorTypeInvalidLink 无效链接 ErrorTypeInvalidLink ErrorType = "INVALID_LINK" // ErrorTypeNoAccount 没有可用账号 ErrorTypeNoAccount ErrorType = "NO_ACCOUNT" // ErrorTypeNoValidAccount 没有有效账号 ErrorTypeNoValidAccount ErrorType = "NO_VALID_ACCOUNT" // ErrorTypeServiceCreation 服务创建失败 ErrorTypeServiceCreation ErrorType = "SERVICE_CREATION_FAILED" // ErrorTypeTransferFailed 转存失败 ErrorTypeTransferFailed ErrorType = "TRANSFER_FAILED" // ErrorTypeTagProcessing 标签处理失败 ErrorTypeTagProcessing ErrorType = "TAG_PROCESSING_FAILED" // ErrorTypeCategoryProcessing 分类处理失败 ErrorTypeCategoryProcessing ErrorType = "CATEGORY_PROCESSING_FAILED" // ErrorTypeResourceSave 资源保存失败 ErrorTypeResourceSave ErrorType = "RESOURCE_SAVE_FAILED" // ErrorTypePlatformNotFound 平台未找到 ErrorTypePlatformNotFound ErrorType = "PLATFORM_NOT_FOUND" // ErrorTypeLinkCheckFailed 链接检查失败 ErrorTypeLinkCheckFailed ErrorType = "LINK_CHECK_FAILED" )
type ForbiddenWordsProcessor ¶ added in v1.2.5
type ForbiddenWordsProcessor struct{}
ForbiddenWordsProcessor 违禁词处理器
func NewForbiddenWordsProcessor ¶ added in v1.2.5
func NewForbiddenWordsProcessor() *ForbiddenWordsProcessor
NewForbiddenWordsProcessor 创建违禁词处理器实例
func (*ForbiddenWordsProcessor) CheckContainsForbiddenWords ¶ added in v1.2.5
func (p *ForbiddenWordsProcessor) CheckContainsForbiddenWords(text string, forbiddenWords []string) (bool, []string)
CheckContainsForbiddenWords 检查字符串是否包含违禁词 参数:
- text: 要检查的文本
- forbiddenWords: 违禁词列表
返回:
- bool: 是否包含违禁词
- []string: 匹配到的违禁词列表
func (*ForbiddenWordsProcessor) ParseForbiddenWordsConfig ¶ added in v1.2.5
func (p *ForbiddenWordsProcessor) ParseForbiddenWordsConfig(config string) []string
ParseForbiddenWordsConfig 解析违禁词配置字符串 参数:
- config: 违禁词配置字符串,多个词用逗号或换行符分隔
返回:
- []string: 处理后的违禁词列表
func (*ForbiddenWordsProcessor) ProcessForbiddenWords ¶ added in v1.2.5
func (p *ForbiddenWordsProcessor) ProcessForbiddenWords(text string, forbiddenWords []string) (bool, []string, string)
ProcessForbiddenWords 处理违禁词:检查并替换 参数:
- text: 要处理的文本
- forbiddenWords: 违禁词列表
返回:
- bool: 是否包含违禁词
- []string: 匹配到的违禁词列表
- string: 替换后的文本
func (*ForbiddenWordsProcessor) ReplaceForbiddenWords ¶ added in v1.2.5
func (p *ForbiddenWordsProcessor) ReplaceForbiddenWords(text string, forbiddenWords []string) string
ReplaceForbiddenWords 替换字符串中的违禁词为 * 参数:
- text: 要处理的文本
- forbiddenWords: 违禁词列表
返回:
- string: 替换后的文本
func (*ForbiddenWordsProcessor) ReplaceForbiddenWordsWithHighlight ¶ added in v1.2.5
func (p *ForbiddenWordsProcessor) ReplaceForbiddenWordsWithHighlight(text string, forbiddenWords []string) string
ReplaceForbiddenWordsWithHighlight 替换字符串中的违禁词为 *(处理高亮标记) 参数:
- text: 要处理的文本(可能包含高亮标记)
- forbiddenWords: 违禁词列表
返回:
- string: 替换后的文本
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
File string `json:"file"`
Line int `json:"line"`
}
LogEntry 日志条目
func (LogEntry) MarshalJSON ¶ added in v1.3.2
为LogEntry实现自定义JSON序列化
type LogViewer ¶
type LogViewer struct {
// contains filtered or unexported fields
}
LogViewer 日志查看器
func (*LogViewer) CleanOldLogs ¶
CleanOldLogs 清理旧日志文件
func (*LogViewer) GetLogFiles ¶
GetLogFiles 获取所有日志文件
func (*LogViewer) GetLogStats ¶
GetLogStats 获取日志统计信息
func (*LogViewer) ParseLogEntriesFromFile ¶ added in v1.3.2
func (lv *LogViewer) ParseLogEntriesFromFile(filename string, levelFilter string, searchFilter string) ([]LogEntry, error)
ParseLogEntriesFromFile 从文件中解析日志条目
func (*LogViewer) ReadLogFile ¶
ReadLogFile 读取日志文件
func (*LogViewer) SearchLogs ¶
SearchLogs 搜索日志
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger 简化的日志器
func (*Logger) DebugWithFields ¶ added in v1.3.2
DebugWithFields 带字段的调试日志
func (*Logger) ErrorWithFields ¶ added in v1.3.2
ErrorWithFields 带字段的错误日志
func (*Logger) InfoWithFields ¶ added in v1.3.2
InfoWithFields 带字段的信息日志
func (*Logger) TelegramDebug ¶ added in v1.3.5
TelegramDebug Telegram调试日志
func (*Logger) TelegramError ¶ added in v1.3.5
TelegramError Telegram错误日志
func (*Logger) TelegramInfo ¶ added in v1.3.5
TelegramInfo Telegram信息日志
func (*Logger) TelegramWarn ¶ added in v1.3.5
TelegramWarn Telegram警告日志
type Rating ¶
type Rating struct {
Value float64 `json:"value"`
Count int `json:"count"`
Max int `json:"max"`
StarCount float64 `json:"star_count"`
}
Rating 评分
type ResourceError ¶ added in v1.0.10
type ResourceError struct {
Type ErrorType `json:"type"`
Message string `json:"message"`
URL string `json:"url,omitempty"`
Details string `json:"details,omitempty"`
}
ResourceError 资源处理错误
func GetResourceError ¶ added in v1.0.10
func GetResourceError(err error) *ResourceError
GetResourceError 获取资源错误
func NewCategoryProcessingError ¶ added in v1.0.10
func NewCategoryProcessingError(details string) *ResourceError
NewCategoryProcessingError 创建分类处理失败错误
func NewInvalidLinkError ¶ added in v1.0.10
func NewInvalidLinkError(url string, details string) *ResourceError
NewInvalidLinkError 创建无效链接错误
func NewLinkCheckError ¶ added in v1.0.10
func NewLinkCheckError(url string, details string) *ResourceError
NewLinkCheckError 创建链接检查失败错误
func NewNoAccountError ¶ added in v1.0.10
func NewNoAccountError(platform string) *ResourceError
NewNoAccountError 创建没有账号错误
func NewNoValidAccountError ¶ added in v1.0.10
func NewNoValidAccountError(platform string) *ResourceError
NewNoValidAccountError 创建没有有效账号错误
func NewPlatformNotFoundError ¶ added in v1.0.10
func NewPlatformNotFoundError(platform string) *ResourceError
NewPlatformNotFoundError 创建平台未找到错误
func NewResourceError ¶ added in v1.0.10
func NewResourceError(errorType ErrorType, message string, url string, details string) *ResourceError
NewResourceError 创建新的资源错误
func NewResourceSaveError ¶ added in v1.0.10
func NewResourceSaveError(url string, details string) *ResourceError
NewResourceSaveError 创建资源保存失败错误
func NewServiceCreationError ¶ added in v1.0.10
func NewServiceCreationError(url string, details string) *ResourceError
NewServiceCreationError 创建服务创建失败错误
func NewTagProcessingError ¶ added in v1.0.10
func NewTagProcessingError(details string) *ResourceError
NewTagProcessingError 创建标签处理失败错误
func NewTransferFailedError ¶ added in v1.0.10
func NewTransferFailedError(url string, details string) *ResourceError
NewTransferFailedError 创建转存失败错误
func NewUnsupportedLinkError ¶ added in v1.0.10
func NewUnsupportedLinkError(url string) *ResourceError
NewUnsupportedLinkError 创建不支持的链接错误
func (*ResourceError) Error ¶ added in v1.0.10
func (e *ResourceError) Error() string
Error 实现error接口
type ResourceForbiddenInfo ¶ added in v1.2.5
type ResourceForbiddenInfo struct {
HasForbiddenWords bool `json:"has_forbidden_words"`
ForbiddenWords []string `json:"forbidden_words"`
ProcessedTitle string `json:"-"` // 不序列化,仅内部使用
ProcessedDesc string `json:"-"` // 不序列化,仅内部使用
}
ResourceForbiddenInfo 资源违禁词信息
func CheckResourceForbiddenWords ¶ added in v1.2.5
func CheckResourceForbiddenWords(title, description string, forbiddenWords []string) ResourceForbiddenInfo
CheckResourceForbiddenWords 检查资源是否包含违禁词(检查标题和描述) 参数:
- title: 资源标题
- description: 资源描述
- forbiddenWords: 违禁词列表
返回:
- ResourceForbiddenInfo: 包含检查结果和处理后的文本
type TelegramLogEntry ¶ added in v1.3.0
type TelegramLogEntry struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Category string `json:"category,omitempty"` // telegram, push, message等
}
TelegramLogEntry Telegram日志条目
func GetTelegramLogs ¶ added in v1.3.0
func GetTelegramLogs(startTime *time.Time, endTime *time.Time, limit int) ([]TelegramLogEntry, error)
GetTelegramLogs 获取Telegram相关的日志
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
BuildTime time.Time `json:"build_time"`
GitCommit string `json:"git_commit"`
GitBranch string `json:"git_branch"`
GoVersion string `json:"go_version"`
NodeVersion string `json:"node_version"`
Platform string `json:"platform"`
Arch string `json:"arch"`
}
VersionInfo 版本信息结构
func LoadVersionFromFile ¶
func LoadVersionFromFile(filename string) (*VersionInfo, error)
LoadVersionFromFile 从文件加载版本信息