Files
LangBot/src/langbot/templates/metadata/pipeline/trigger.yaml
Guanchao Wang b8df0dbd7f feat: message aggregator (#1985)
* feat: aggregator

* fix: resolve deadlock, mutation, and safety issues in message aggregator

- Fix deadlock: don't await cancelled timer tasks inside the lock;
  _flush_buffer acquires the same lock, causing a deadlock cycle
- Fix message_event mutation: keep original message_event unmodified
  to preserve message_id/metadata for reply/quote; only pass merged
  message_chain separately
- Fix Plain positional arg: Plain('\n') → Plain(text='\n')
- Fix float() ValueError: wrap delay cast in try/except
- Add MAX_BUFFER_MESSAGES (10) cap to prevent unbounded buffer growth
- Default enabled to false to avoid surprising latency on upgrade
- Fix flush_all: cancel all timers under one lock acquisition, then
  flush outside the lock to avoid deadlock

---------

Co-authored-by: RockChinQ <rockchinq@gmail.com>
2026-02-25 14:20:34 +08:00

169 lines
6.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: trigger
label:
en_US: Trigger
zh_Hans: 触发条件
stages:
- name: group-respond-rules
label:
en_US: Group Respond Rule
zh_Hans: 群响应规则
description:
en_US: The respond rule of the messages in the groups
zh_Hans: 群内消息的响应规则
config:
- name: at
label:
en_US: At
zh_Hans: '@'
description:
en_US: Whether to trigger when the message mentions the bot
zh_Hans: 是否在消息@机器人时触发
type: boolean
required: true
default: false
- name: prefix
label:
en_US: Prefix
zh_Hans: 前缀
description:
en_US: Messages with these prefixes will be responded (the prefixes will be removed automatically when sending to AI)
zh_Hans: 具有这些前缀的消息将被响应(发送给 AI 时会自动去除对应前缀)
type: array[string]
required: true
default: []
- name: regexp
label:
en_US: Regexp
zh_Hans: 正则表达式
description:
en_US: Messages with these regular expressions will be responded
zh_Hans: 符合这些正则表达式的消息将被响应
type: array[string]
required: true
default: []
- name: random
label:
en_US: Random
zh_Hans: 随机
description:
en_US: 'Probability of automatically responding to messages that are not matched by other rules. Range: 0.0-1.0 (0%-100%).'
zh_Hans: '自动响应其他规则未匹配的消息的概率。范围0.0-1.0 (0%-100%)。'
type: float
required: false
default: 0
- name: access-control
label:
en_US: Access Control
zh_Hans: 访问控制
config:
- name: mode
label:
en_US: Mode
zh_Hans: 模式
description:
en_US: The mode of the access control
zh_Hans: 访问控制模式
type: select
required: true
default: blacklist
options:
- name: blacklist
label:
en_US: Blacklist
zh_Hans: 黑名单
- name: whitelist
label:
en_US: Whitelist
zh_Hans: 白名单
- name: blacklist
label:
en_US: Blacklist
zh_Hans: 黑名单
description:
en_US: Sessions in the blacklist will be ignored, the format is `{launcher_type}_{launcher_id}`remove quotes, for example `person_123` matches private chat, `group_456` matches group chat, `person_*` matches all private chats, `group_*` matches all group chats, `*_123` matches private and group chats with user ID 123
zh_Hans: 黑名单中的会话将被忽略;会话格式:`{launcher_type}_{launcher_id}`(删除引号),例如 `person_123` 匹配私聊会话,`group_456` 匹配群聊会话;`person_*` 匹配所有私聊会话,`group_*` 匹配所有群聊会话;`*_123` 匹配用户 ID 为 123 的私聊和群聊消息
type: array[string]
required: true
default: []
- name: whitelist
label:
en_US: Whitelist
zh_Hans: 白名单
description:
en_US: Only respond to sessions in the whitelist, the format is `{launcher_type}_{launcher_id}`remove quotes, for example `person_123` matches private chat, `group_456` matches group chat, `person_*` matches all private chats, `group_*` matches all group chats, `*_123` matches private and group chats with user ID 123
zh_Hans: 仅响应白名单中的会话;会话格式:`{launcher_type}_{launcher_id}`(删除引号),例如 `person_123` 匹配私聊会话,`group_456` 匹配群聊会话;`person_*` 匹配所有私聊会话,`group_*` 匹配所有群聊会话;`*_123` 匹配用户 ID 为 123 的私聊和群聊消息
type: array[string]
required: true
default: []
- name: ignore-rules
label:
en_US: Ignore Rules
zh_Hans: 消息忽略规则
description:
en_US: Ignore rules that apply to both group and private messages
zh_Hans: 对群聊、私聊消息均适用的忽略规则(优先级高于群响应规则)
config:
- name: prefix
label:
en_US: Prefix
zh_Hans: 前缀
description:
en_US: Messages with these prefixes will be ignored
zh_Hans: 包含这些前缀的消息将被忽略
type: array[string]
required: true
default: []
- name: regexp
label:
en_US: Regexp
zh_Hans: 正则表达式
description:
en_US: Messages with these regular expressions will be ignored
zh_Hans: 符合这些正则表达式的消息将被忽略
type: array[string]
required: true
default: []
- name: message-aggregation
label:
en_US: Message Aggregation
zh_Hans: 消息聚合
description:
en_US: When a user sends multiple messages consecutively, wait for a period and merge them into one before processing
zh_Hans: 当用户连续发送多条消息时,等待一段时间后合并为一条消息再处理(防抖)
config:
- name: enabled
label:
en_US: Enable Message Aggregation
zh_Hans: 启用消息聚合
description:
en_US: If enabled, consecutive messages from the same user will be merged after a delay
zh_Hans: 如果启用,同一用户连续发送的消息将在延迟后合并处理
type: boolean
required: true
default: false
- name: delay
label:
en_US: Aggregation Delay (seconds)
zh_Hans: 聚合延迟(秒)
description:
en_US: 'Wait time before merging messages. Range: 1.0-10.0 seconds.'
zh_Hans: '合并消息前的等待时间。范围1.0-10.0 秒。'
type: float
required: true
default: 1.5
- name: misc
label:
en_US: Misc
zh_Hans: 杂项
config:
- name: combine-quote-message
label:
en_US: Combine Quote Message
zh_Hans: 合并引用消息
description:
en_US: If enabled, the bot will combine the quote message with the user's message
zh_Hans: 如果启用,将合并引用消息与用户发送的消息
type: boolean
required: true
default: true