From 9ef772152783e1cff7f9c60a26a245c92f02947c Mon Sep 17 00:00:00 2001 From: ShukeBta <272197458+ShukeBta@users.noreply.github.com> Date: Sat, 20 Jun 2026 01:16:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(telegram):=20=E8=AE=A2=E9=98=85/=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=80=9A=E7=9F=A5=E8=A1=A5=E5=85=85=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=89=80=E9=9C=80=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 合并 #39 媒体通知模板后, formatTelegramMediaNotification 需要事件携带 片名/简介/外链/资源标题等字段才能渲染丰富内容。补充数据源中现成可用的字段: - 订阅命中: title(订阅名)/overview/imdb_url(由 IMDBID 拼)/resource_title(首个命中资源) - 下载完成: title/overview/resource_title(torrent 原始名, 供模板提取季集与版本) 缺失项(年份/评分/tmdb 链接等无现成来源)模板会自动略过, 不影响回退。 --- internal/service/downloads.go | 11 +++++++++++ internal/service/subscription.go | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/internal/service/downloads.go b/internal/service/downloads.go index ade9197..b0ea9f2 100644 --- a/internal/service/downloads.go +++ b/internal/service/downloads.go @@ -1357,6 +1357,11 @@ func (d *DownloadService) notifyDownloadComplete(ctx context.Context, torrent QB } body := fmt.Sprintf("任务:%s\n保存路径:%s\nHash:%s", name, firstNonEmpty(torrent.ContentPath, torrent.SavePath), torrent.Hash) data := map[string]interface{}{} + // resource_title 供 Telegram 模板从发布名提取季集(SxxEyy)与版本(分辨率/编码/ + // 字幕组等)信息;隐藏不直接展示。优先用 torrent 原始名(信息最全)。 + if rt := strings.TrimSpace(torrent.Name); rt != "" { + data["resource_title"] = rt + } if task != nil { if strings.TrimSpace(task.PosterURL) != "" { data["poster_url"] = task.PosterURL @@ -1370,6 +1375,12 @@ func (d *DownloadService) notifyDownloadComplete(ctx context.Context, torrent QB if strings.TrimSpace(task.MediaCategory) != "" { data["media_category"] = task.MediaCategory } + if strings.TrimSpace(task.Title) != "" { + data["title"] = task.Title + } + if strings.TrimSpace(task.Overview) != "" { + data["overview"] = task.Overview + } } go func() { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) diff --git a/internal/service/subscription.go b/internal/service/subscription.go index ca69843..4878aa9 100644 --- a/internal/service/subscription.go +++ b/internal/service/subscription.go @@ -469,6 +469,20 @@ func (s *SubscriptionService) notifySubscriptionHit(sub *model.Subscription, que if strings.TrimSpace(sub.MediaCategory) != "" { data["media_category"] = sub.MediaCategory } + // 补充媒体通知模板(formatTelegramMediaNotification)所需字段:片名 / 简介 / + // 外链 / 资源标题(供模板提取季集 + 版本)。仅填现成可用的,缺失项模板会自动略过。 + if strings.TrimSpace(sub.Name) != "" { + data["title"] = sub.Name + } + if strings.TrimSpace(sub.Overview) != "" { + data["overview"] = sub.Overview + } + if id := strings.TrimSpace(sub.IMDBID); id != "" { + data["imdb_url"] = "https://www.imdb.com/title/" + id + "/" + } + if len(resources) > 0 { + data["resource_title"] = resources[0] + } s.notify.BroadcastEvent(ctx, NotifyEvent{ Type: EventSubscriptionHit, Title: "MediaStationGo 订阅命中新资源",