LINE 设置
概述
LINE channel 把 Anyy 连接到 LINE Messaging API webhooks。它支持 direct messages、groups、webhook receiving 和 live-smoke 检查。
前提条件
- 一个 LINE Messaging API channel。
- Channel access token。
- Channel secret。
- 可供 Anyy gateway 使用的公网 HTTPS webhook endpoint。
- 可选 bot user id,用于过滤自己消息。
配置
创建凭据
创建或复用 LINE Messaging API channel,并把 webhook 配到 Anyy 的 LINE webhook path:
/channels/line/webhook
配置 Anyy
anyy setup channels line \
--secret channel_access_token='line-access-token' \
--secret channel_secret='line-channel-secret' \
--write-config
可选:
channels:
line:
bot_user_id: "line-bot-user-id"
setup 默认值:
| 字段 | 默认值 |
|---|---|
account_id | line |
webhook_path | /channels/line/webhook |
mention_aliases | ["anyy"] |
dm_policy | open |
group_policy | mention |
send_chunk_chars | 4000 |
启动 Gateway
anyy gateway start
anyy channels reload
运行 Doctor 检查
anyy channels doctor line
访问策略
私信
LINE 默认 dm_policy: open。私有助手建议使用 allowlist,并在 allow_from 中写 LINE user id。
群组
LINE 默认 group_policy: mention。群消息需要 mention alias,除非你配置更开放的策略。
管理员
LINE channel policy 和共享 command authorization 是两层。
Sessions
每个被接受的 LINE 用户或群组会映射到一个 Anyy session。
媒体支持
入站媒体
当前 LINE adapter 没有声明 inbound media 能力。
出站媒体
当前 LINE adapter 只发送文本回复。
命令
使用共享 messaging commands。群里如 group_policy 是 mention,需要包含配置的 mention alias。
Cron 投递
anyy cron create \
--name "LINE reminder" \
--schedule "30m" \
--prompt "Send a reminder" \
--delivery-target current_user_default \
--delivery-channel line
故障排查
- Webhook verification 失败:检查
channel_secret_ref和公网 webhook URL。 - 无法回复:检查
channel_access_token_ref。 - 群消息被忽略:mention
anyy或调整group_policy。 - 意外用户可以访问 bot:使用
dm_policy: allowlist。