diff --git a/plugins/alert.py b/plugins/alert.py index 452f8e6..01a0a72 100644 --- a/plugins/alert.py +++ b/plugins/alert.py @@ -282,10 +282,18 @@ async def _poll_once(bot, key: str, announce: bool = True) -> None: seen_list = list(data.get("seen", {}).get(tag, [])) new_items = [item for item in items if item["id"] not in seen_set] - if announce and new_items: + # Filter: only announce results that actually contain the keyword + kw_lower = keyword.lower() + matched = [ + item for item in new_items + if kw_lower in item.get("title", "").lower() + or kw_lower in item.get("url", "").lower() + ] + + if announce and matched: channel = data["channel"] name = data["name"] - shown = new_items[:_MAX_ANNOUNCE] + shown = matched[:_MAX_ANNOUNCE] for item in shown: title = _truncate(item["title"]) if item["title"] else "(no title)" url = item["url"] @@ -293,7 +301,7 @@ async def _poll_once(bot, key: str, announce: bool = True) -> None: if url: line += f" -- {url}" await bot.send(channel, line) - remaining = len(new_items) - len(shown) + remaining = len(matched) - len(shown) if remaining > 0: await bot.send(channel, f"[{name}/{tag}] ... and {remaining} more")