From 1d3ed2f8aa3c1a8e978adb792b9fa48b9c52d2c3 Mon Sep 17 00:00:00 2001 From: ctwj <908504609@qq.com> Date: Sat, 2 Aug 2025 23:57:14 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E8=87=AA=E5=8A=A8=E8=BD=AC=E5=AD=98?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E5=8C=85=E5=90=AB=E8=BF=9D=E7=A6=81=E8=AF=8D?= =?UTF-8?q?=E7=9A=84=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/scheduler.go | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/utils/scheduler.go b/utils/scheduler.go index 40e0570..2edc1f3 100644 --- a/utils/scheduler.go +++ b/utils/scheduler.go @@ -771,9 +771,43 @@ func (s *Scheduler) processAutoTransfer() { Info("找到 %d 个需要转存的资源", len(resources)) + // 获取违禁词配置 + forbiddenWords, err := s.systemConfigRepo.GetConfigValue(entity.ConfigKeyForbiddenWords) + if err != nil { + Error("获取违禁词配置失败: %v", err) + forbiddenWords = "" // 如果获取失败,使用空字符串 + } + + // 过滤包含违禁词的资源 + var filteredResources []*entity.Resource + if forbiddenWords != "" { + words := strings.Split(forbiddenWords, ",") + for _, resource := range resources { + shouldSkip := false + title := strings.ToLower(resource.Title) + description := strings.ToLower(resource.Description) + + for _, word := range words { + word = strings.TrimSpace(word) + if word != "" && (strings.Contains(title, strings.ToLower(word)) || strings.Contains(description, strings.ToLower(word))) { + Info("跳过包含违禁词 '%s' 的资源: %s", word, resource.Title) + shouldSkip = true + break + } + } + + if !shouldSkip { + filteredResources = append(filteredResources, resource) + } + } + Info("违禁词过滤后,剩余 %d 个资源需要转存", len(filteredResources)) + } else { + filteredResources = resources + } + // 并发自动转存 - resourceCh := make(chan *entity.Resource, len(resources)) - for _, res := range resources { + resourceCh := make(chan *entity.Resource, len(filteredResources)) + for _, res := range filteredResources { resourceCh <- res } close(resourceCh) @@ -797,7 +831,7 @@ func (s *Scheduler) processAutoTransfer() { }(account) } wg.Wait() - Info("自动转存处理完成,账号数: %d,资源数: %d", len(validAccounts), len(resources)) + Info("自动转存处理完成,账号数: %d,资源数: %d", len(validAccounts), len(filteredResources)) } // getResourcesForTransfer 获取需要转存的资源