Skip to content

feat(bot):Feishu channel mention, support PIC conversation, per-channel workspace, #567

Merged
qin-ctx merged 8 commits intomainfrom
feature/bot_per_channel
Mar 13, 2026
Merged

feat(bot):Feishu channel mention, support PIC conversation, per-channel workspace, #567
qin-ctx merged 8 commits intomainfrom
feature/bot_per_channel

Conversation

@yeshion23333
Copy link
Collaborator

@yeshion23333 yeshion23333 commented Mar 13, 2026

Description

Feishu Channel

  • Added Thread group message handling with two response modes: all messages require @mention by default; only topic replies need @mention in simplified mode
  • Improved @bot detection accuracy via dual recognition from mentions field and message content
  • Optimized "seen" reaction timing: only added when message needs processing
  • Fixed image download error display to show detailed raw error info

Configuration

  • Added PER_CHANNEL isolation mode for independent sandbox/memory per channel
  • Added open_id and thread_require_mention fields to Feishu config
  • Fixed root_api_key judgment error in config loading logic

CLI & Sandbox

  • Added --config-path parameter to gateway command for custom config file
  • Refactored chat command logging: always save DEBUG logs to rotating file (7-day retention), console logs controlled by --logs flag
  • Added per-channel sandbox isolation: independent workspaces for different channels

飞书消息

  • 新增话题群消息处理能力,支持两种响应模式:默认所有消息需@才响应;简化模式下仅话题回复需要@
  • 通过mentions字段和消息内容双重识别提升@机器人检测准确率
  • 优化"已读"表情时机:仅确认需要处理消息时才添加
  • 修复图片下载错误显示,展示更详细的原始错误信息

配置系统

  • 新增PER_CHANNEL隔离模式,支持按频道独立隔离沙箱和记忆数据
  • 飞书配置新增open_id、thread_require_mention字段适配话题群功能
  • 修复配置加载中root_api_key判断错误问题

命令行与沙箱

  • gateway命令新增--config-path参数支持指定自定义配置文件
  • 重构chat命令日志系统:始终保存DEBUG日志到自动轮转文件(保留7天),控制台日志通过--logs参数控制
  • 新增per-channel沙箱隔离模式:不同频道使用独立工作区,数据互不干扰

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Mention Detection Bug

App ID-based mention detection is only performed when bot_open_id is set, which may cause missed mentions if open_id is not configured.

if hasattr(message, 'mentions') and message.mentions and bot_open_id:
    for mention in message.mentions:
        if hasattr(mention, 'id') and hasattr(mention.id, 'open_id'):
            at_id = mention.id.open_id
            if at_id == bot_open_id:
                is_mentioned = True
                break
        # 兼容其他可能的ID格式
        at_id = getattr(mention, 'id', '') or getattr(mention, 'user_id', '')
        if at_id == f"app_{bot_app_id}" or at_id == bot_app_id:
            is_mentioned = True
            break
Possible AttributeError

Accessing message.root_id without checking if the attribute exists may raise an AttributeError for message types that don't include this field.

is_topic_starter = message.root_id == message.message_id or not message.root_id
Missing Method Check

Usage of session_key.channel_key() assumes the method exists; verify SessionKey implements channel_key() to avoid runtime errors.

return session_key.channel_key()

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add fallback for error message content

Accessing response.raw.content directly can raise an AttributeError if response.raw
is not available. Use a fallback to response.msg to ensure the error message is
always valid.

bot/vikingbot/channels/feishu.py [175-177]

 raise Exception(
-    f"Failed to download image: code={response.code}, msg={response.raw.content}, log_id={response.get_log_id()}"
+    f"Failed to download image: code={response.code}, msg={getattr(getattr(response, 'raw', None), 'content', response.msg)}, log_id={response.get_log_id()}"
 )
Suggestion importance[1-10]: 6

__

Why: Adds a fallback to response.msg to prevent AttributeError when accessing response.raw.content, improving error handling robustness.

Low

@qin-ctx qin-ctx merged commit 1d8efc3 into main Mar 13, 2026
5 checks passed
@qin-ctx qin-ctx deleted the feature/bot_per_channel branch March 13, 2026 03:31
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 13, 2026
@yeshion23333 yeshion23333 restored the feature/bot_per_channel branch March 13, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants