Loading...
Loading...
Compare original and translation side by side
export FEISHU_APP_ID="cli_xxxxxxxxxxxxxxxx"
export FEISHU_APP_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".envFEISHU_APP_ID=cli_xxxxxxxxxxxxxxxx
FEISHU_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxexport FEISHU_APP_ID="cli_xxxxxxxxxxxxxxxx"
export FEISHU_APP_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".envFEISHU_APP_ID=cli_xxxxxxxxxxxxxxxx
FEISHU_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxim:resourceim:messageim:resourceim:message// Example: User asks to "send me a screenshot"
// The skill will automatically:
// 1. Read OpenClaw config for Feishu credentials
// 2. Upload the screenshot to Feishu
// 3. Send it to the user// 示例:用户要求“send me a screenshot”
// 工具会自动执行:
// 1. 读取OpenClaw的飞书配置凭证
// 2. 将截图上传至飞书
// 3. 发送给用户node feishu-image.js --image /path/to/screenshot.png --to ou_xxxxxxxxnode feishu-image.js --image chart.png --to ou_xxxxxxxx --text "Q4 Sales Report"node feishu-image.js --image announcement.png --to oc_xxxxxxxx --chatnode feishu-image.js --image /path/to/screenshot.png --to ou_xxxxxxxxnode feishu-image.js --image chart.png --to ou_xxxxxxxx --text "Q4 Sales Report"node feishu-image.js --image announcement.png --to oc_xxxxxxxx --chatconst { FeishuImage } = require('./scripts/feishu-image.js');
const sender = new FeishuImage({
appId: 'cli_xxxxxxxxxxxxxxxx',
appSecret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});
// Send image to a user
await sender.sendImage({
imagePath: '/path/to/screenshot.png',
receiveId: 'ou_xxxxxxxx',
receiveType: 'user'
});
// Send image with text
await sender.sendImage({
imagePath: '/path/to/chart.png',
receiveId: 'ou_xxxxxxxx',
receiveType: 'user',
text: 'Here is the sales report'
});const { FeishuImage } = require('./scripts/feishu-image.js');
const sender = new FeishuImage({
appId: 'cli_xxxxxxxxxxxxxxxx',
appSecret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});
// 向用户发送图片
await sender.sendImage({
imagePath: '/path/to/screenshot.png',
receiveId: 'ou_xxxxxxxx',
receiveType: 'user'
});
// 发送带文字的图片
await sender.sendImage({
imagePath: '/path/to/chart.png',
receiveId: 'ou_xxxxxxxx',
receiveType: 'user',
text: 'Here is the sales report'
});| Option | Short | Description | Required |
|---|---|---|---|
| | Path to the image file | Yes |
| | Recipient's Feishu open_id or chat_id | Yes |
| Optional text message to include | No | |
| | Send to a chat group (default: user) | No |
| | Show help message | No |
| 选项 | 缩写 | 说明 | 是否必填 |
|---|---|---|---|
| | 图片文件路径 | 是 |
| | 收件人的飞书open_id或chat_id | 是 |
| 可选的附带文字消息 | 否 | |
| | 发送至聊天群组(默认:用户) | 否 |
| | 显示帮助信息 | 否 |
undefinedundefinedundefinedundefinednew FeishuImage(config)new FeishuImage(config)config.appIdconfig.appSecretconfig.baseUrlconst sender = new FeishuImage({
appId: process.env.FEISHU_APP_ID,
appSecret: process.env.FEISHU_APP_SECRET
});config.appIdconfig.appSecretconfig.baseUrlconst sender = new FeishuImage({
appId: process.env.FEISHU_APP_ID,
appSecret: process.env.FEISHU_APP_SECRET
});async sendImage(options)async sendImage(options)options.imagePathoptions.receiveIdoptions.receiveTypeoptions.textFeishuImageErrortry {
const messageId = await sender.sendImage({
imagePath: '/path/to/screenshot.png',
receiveId: 'ou_xxxxxxxx',
receiveType: 'user',
text: 'Here is the screenshot you requested'
});
console.log('Image sent successfully, message ID:', messageId);
} catch (error) {
console.error('Failed to send image:', error.message);
}options.imagePathoptions.receiveIdoptions.receiveTypeoptions.textFeishuImageErrortry {
const messageId = await sender.sendImage({
imagePath: '/path/to/screenshot.png',
receiveId: 'ou_xxxxxxxx',
receiveType: 'user',
text: 'Here is the screenshot you requested'
});
console.log('Image sent successfully, message ID:', messageId);
} catch (error) {
console.error('Failed to send image:', error.message);
}FeishuImageError| Error Code | Description | Solution |
|---|---|---|
| FEISHU_APP_ID or FEISHU_APP_SECRET not set | Set environment variables or pass to constructor |
| Authentication with Feishu API failed | Check app_id and app_secret are correct |
| Image file does not exist | Check the image path is correct |
| Image upload to Feishu failed | Check network connection and file size limits |
| Message sending failed | Check recipient ID and permissions |
const { FeishuImage, FeishuImageError } = require('./scripts/feishu-image.js');
try {
await sender.sendImage({ ... });
} catch (error) {
if (error instanceof FeishuImageError) {
switch (error.code) {
case 'MISSING_CREDENTIALS':
console.error('Please set FEISHU_APP_ID and FEISHU_APP_SECRET');
break;
case 'AUTH_FAILED':
console.error('Invalid credentials. Check your app ID and secret.');
break;
case 'FILE_NOT_FOUND':
console.error(`Image file not found: ${error.details.path}`);
break;
default:
console.error(`Error: ${error.message}`);
}
} else {
console.error('Unexpected error:', error);
}
}FeishuImageError| 错误码 | 说明 | 解决方案 |
|---|---|---|
| FEISHU_APP_ID或FEISHU_APP_SECRET未设置 | 设置环境变量或传入构造函数 |
| 飞书API认证失败 | 检查app_id和app_secret是否正确 |
| 图片文件不存在 | 检查图片路径是否正确 |
| 图片上传至飞书失败 | 检查网络连接和文件大小限制 |
| 消息发送失败 | 检查收件人ID和权限 |
const { FeishuImage, FeishuImageError } = require('./scripts/feishu-image.js');
try {
await sender.sendImage({ ... });
} catch (error) {
if (error instanceof FeishuImageError) {
switch (error.code) {
case 'MISSING_CREDENTIALS':
console.error('Please set FEISHU_APP_ID and FEISHU_APP_SECRET');
break;
case 'AUTH_FAILED':
console.error('Invalid credentials. Check your app ID and secret.');
break;
case 'FILE_NOT_FOUND':
console.error(`Image file not found: ${error.details.path}`);
break;
default:
console.error(`Error: ${error.message}`);
}
} else {
console.error('Unexpected error:', error);
}
}