Add OpenClaw workspace configuration and tools
- Add agent configuration files (AGENTS.md, USER.md, IDENTITY.md, SOUL.md) - Add git configuration and skills management scripts - Add frontend/backend analysis tools and reports - Add DingTalk media sender utilities and documentation - Fix OpenClaw runtime environment (Node.js and Python) - Configure git remotes and push scripts
This commit is contained in:
79
send_cnblogs_info.js
Normal file
79
send_cnblogs_info.js
Normal file
@@ -0,0 +1,79 @@
|
||||
// 直接调用钉钉媒体上传 API 发送已有的截图
|
||||
const axios = require('axios');
|
||||
const FormData = require('form-data');
|
||||
|
||||
const ACCESS_TOKEN_URL = "https://api.dingtalk.com/v1.0/oauth2/accessToken";
|
||||
const UPLOAD_URL = "https://oapi.dingtalk.com/media/upload";
|
||||
const SEND_URL = "https://api.dingtalk.com/v1.0/robot/groupMessages/send";
|
||||
|
||||
const APP_KEY = "ding4ursdp0l2giat4bj";
|
||||
const APP_SECRET = "J0gBicjKiIHoKla7WfKKhRs1Tv8L6Xd5UhW3EVQByF16G7Vn7UUcRhP6u-PBCQNo";
|
||||
const OPEN_CONVERSATION_ID = "cidcjYshXVtKck5LfOO9AqOJg==";
|
||||
const ROBOT_CODE = "ding4ursdp0l2giat4bj";
|
||||
|
||||
async function getAccessToken() {
|
||||
const response = await axios.post(ACCESS_TOKEN_URL, {
|
||||
appKey: APP_KEY,
|
||||
appSecret: APP_SECRET
|
||||
});
|
||||
return response.data.accessToken;
|
||||
}
|
||||
|
||||
async function sendMarkdownMessage(accessToken, title, text) {
|
||||
const headers = {
|
||||
"x-acs-dingtalk-access-token": accessToken,
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
|
||||
const body = {
|
||||
robotCode: ROBOT_CODE,
|
||||
openConversationId: OPEN_CONVERSATION_ID,
|
||||
msgKey: "sampleMarkdown",
|
||||
msgParam: JSON.stringify({
|
||||
title: title,
|
||||
text: text
|
||||
})
|
||||
};
|
||||
|
||||
try {
|
||||
console.log('\n发送消息到钉钉群聊...');
|
||||
const response = await axios.post(SEND_URL, body, { headers });
|
||||
|
||||
if (response.status === 200) {
|
||||
console.log(`✅ 消息发送成功!ProcessQueryKey: ${response.data.processQueryKey}\n`);
|
||||
return true;
|
||||
} else {
|
||||
console.log(`❌ 发送失败\n`);
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(`❌ 发送异常: ${err.message}\n`);
|
||||
if (err.response?.data) {
|
||||
console.log(`详细错误: ${JSON.stringify(err.response.data, null, 2)}\n`);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
console.log('='.repeat(60));
|
||||
console.log('发送 cnblogs.com 首页消息');
|
||||
console.log('='.repeat(60));
|
||||
|
||||
const accessToken = await getAccessToken();
|
||||
console.log('✓ Access Token 获取成功');
|
||||
|
||||
// 由于浏览器不可用,发送文本消息包含信息
|
||||
const markdownText = `# cnblogs.com 首页截图\n\n抱歉,浏览器服务暂时不可用,无法自动截图。\n\n请手动访问 https://cnblogs.com 查看首页。\n\n**截图提示:**\n\n如果你需要 cnblogs.com 首页截图,请:\n1. 手动访问 https://cnblogs.com\n2. 使用浏览器截图或录制\n3. 截图文件可以保存在桌面\n\n\n后续我可以帮你发送截图到群聊。`;
|
||||
|
||||
await sendMarkdownMessage(accessToken, "cnblogs.com", markdownText);
|
||||
|
||||
console.log('='.repeat(60));
|
||||
} catch (err) {
|
||||
console.error('\n错误:', err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user