fix: restrict bot to configured channel's threads + future tag-based triggering across repos
维护者通常 1 天内回复
@kpj2006 已经在做这个了。
开始于 2026年6月11日。
评估
这个 Issue 还没有评估数据。
描述
Summary
Currently the bot responds to messages in any thread across the entire server, not just threads that belong to the configured channel. This is a bug that needs to be fixed now, with a future enhancement to support tag-based triggering when the bot is deployed across multiple repos/servers.
Identified in: https://github.com/AOSSIE-Org/SkillBot/pull/6#discussion_r3393981241
Related PR: https://github.com/AOSSIE-Org/SkillBot/pull/6
Requested by: @kpj2006
Bug: Bot responds to ALL threads server-wide
Root Cause
In bot.py, the guard in process_message has a logic flaw:
is_in_thread = isinstance(message.channel, discord.Thread)
is_in_configured_channel = message.channel.id == DISCORD_CHANNEL_ID_INT
if not is_in_thread and not is_in_configured_channel:
return
When message.channel is a discord.Thread, its .id is the thread's own ID, not the parent channel's ID. The condition not is_in_thread and not is_in_configured_channel lets all threads pass regardless of which channel they belong to, because is_in_thread being True skips the channel ID check entirely.
Fix for Current Codebase
In bot.py, update the process_message function (around lines 169–173):
is_in_thread = isinstance(message.channel, discord.Thread)
- is_in_configured_channel = message.channel.id == DISCORD_CHANNEL_ID_INT
+ if is_in_thread:
+ is_in_configured_channel = message.channel.parent_id == DISCORD_CHANNEL_ID_INT
+ else:
+ is_in_configured_channel = message.channel.id == DISCORD_CHANNEL_ID_INT
- if not is_in_thread and not is_in_configured_channel:
+ if not is_in_configured_channel:
return
This uses message.channel.parent_id when the channel is a Thread, which correctly identifies the parent text channel.
Future Enhancement: Tag-based Triggering Across Repos
In a later phase, the bot will be deployed across multiple Discord servers/repos and should only respond when explicitly mentioned/tagged (e.g., @SkillBot <question>).
Changes needed when implementing this:
-
Add mention detection in
process_message:- Check if
client.useris mentioned inmessage.mentionsbefore processing. - Strip the mention prefix from the message content before passing it to Ollama.
- Check if
-
Remove or relax the single-channel restriction (
DISCORD_CHANNEL_ID_INTcheck):- Once tag-based triggering is in place, the bot can safely listen server-wide (or across guilds) since it only activates on explicit mentions.
-
Update
_get_or_create_thread:- Thread naming / parent channel logic may need to be generalized to work across any channel.
-
Update
.env/ configuration:DISCORD_CHANNEL_IDcan be made optional or replaced with a list of allowed channels/guilds.
-
Update
on_readybacklog processing:- Backlog catch-up should also filter by mentions to avoid re-processing unrelated messages.
- 主要语言
- Python
- 星标
- 10
- 派生
- 11
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AOSSIE-Org/SkillBot 的其他 Issue
-
[BUG]: Issue-creation intent is missed when the article is omitted (create issue for this)可能已有人在做 @Ankitavasudev 于 8 天前认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 82/100
AOSSIE-Org/SkillBot#65 · 2 条评论 ·
维护者通常 1 天内回复
-
[BUG]: Non-Atomic Gap Log Writes Can Cause Data Loss After an Interrupted Save可能重新可做 @SYED-IRTEZA-HUSSAIN-RIZVI 于 11 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 74/100
AOSSIE-Org/SkillBot#61 · 2 条评论 ·
维护者通常 1 天内回复
-
[BUG]: os.chdir() Changes the Process-Wide Working Directory During Repository Sync可能已有人在做 @aadityachhipa80-oss 于 2 天前认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 75/100
AOSSIE-Org/SkillBot#59 · 3 条评论 ·
维护者通常 1 天内回复
-
[BUG]: wait_for_ollama() Retries Indefinitely When Ollama Is Unavailable可能重新可做 @SYED-IRTEZA-HUSSAIN-RIZVI 于 11 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/SkillBot#56 · 3 条评论 ·
维护者通常 1 天内回复
-
[BUG]: Backlog Messages Are Re-processed on Discord Reconnection可能重新可做 @SYED-IRTEZA-HUSSAIN-RIZVI 于 11 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
难度 4/5 3-5 天 新手友好度 55/100
AOSSIE-Org/SkillBot#58 · 2 条评论 ·
维护者通常 1 天内回复
查看 AOSSIE-Org/SkillBot 的全部 Issue
相似的 Issue
-
needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
gke-labs/kube-agents#6778 · 1 条评论 ·
维护者通常 1 天内回复
-
Declare the CMS schema library in the optional recipients extra可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area:python in-progress
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
area/build-framework kind/enhancement priority/low
难度 2/5 1-3 小时 新手友好度 77/100
yugabyte/yugabyte-db#38826 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 72/100
sususweet/midea_auto_cloud#306 ·
维护者通常 9 天内回复