Line 适配器配置
Line 适配器配置说明。
配置项
channel_access_token
- 类型:
string - 必填: ✅
- 说明: Line Channel Access Token,从 Line Developers Console 获取
channel_secret
- 类型:
string - 必填: ✅
- 说明: Line Channel Secret,从 Line Developers Console 获取
receive_mode
- 类型:
webhook | manual - 必填: ❌
- 默认值:
webhook - 说明:
manual不注册接收路由,由已有 Host 或队列调用适配器的ingest()
destination
- 类型:
string - 必填: ❌
- 说明: LINE destination user ID;配置后会拒绝投递到其他机器人的事件
配置示例
基础配置
yaml
line.my_bot:
channel_access_token: 'your_channel_access_token'
channel_secret: 'your_channel_secret'手动接入已有 Host
yaml
line.my_bot:
channel_access_token: 'your_channel_access_token'
channel_secret: 'your_channel_secret'
receive_mode: manual
destination: 'U0123456789abcdef0123456789abcdef'获取 Channel Access Token
- 访问 Line Developers Console
- 创建或选择一个 Provider
- 创建一个新的 Messaging API Channel
- 在 Channel 的 "Messaging API" 页面,点击 "Issue" 生成 Channel Access Token
获取 Channel Secret
- 访问 Line Developers Console
- 选择你的 Channel
- 在 "Basic settings" 页面找到 Channel Secret
Webhook 配置
启动 onebots 服务后,需要在 Line Developers Console 配置 Webhook URL:
- 进入你的 Channel 设置
- 在 "Messaging API" 页面找到 "Webhook settings"
- 设置 Webhook URL:
https://your-domain.com/line/{account_id}/webhook - 点击 "Verify" 验证
- 启用 "Use webhook"
提示
- Webhook URL 必须使用 HTTPS
- 确保服务器可从公网访问
- 本地开发可使用 ngrok 等工具