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:
70
test_msgkey.js
Normal file
70
test_msgkey.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// 测试不同的 msgKey 发送图片
|
||||
const axios = require('axios');
|
||||
|
||||
const ACCESS_TOKEN_URL = "https://api.dingtalk.com/v1.0/oauth2/accessToken";
|
||||
const APP_KEY = "ding4ursdp0l2giat4bj";
|
||||
const APP_SECRET = "J0gBicjKiIHoKla7WfKKhRs1Tv8L6Xd5UhW3EVQByF16G7Vn7UUcRhP6u-PBCQNo";
|
||||
const OPEN_CONVERSATION_ID = "cidcjYshXVtKck5LfOO9AqOJg==";
|
||||
const ROBOT_CODE = "ding4ursdp0l2giat4bj";
|
||||
const MEDIA_ID = "@lADPD0ni1-bFMwXNB9DNARg";
|
||||
|
||||
async function getAccessToken() {
|
||||
const response = await axios.post(ACCESS_TOKEN_URL, {
|
||||
appKey: APP_KEY,
|
||||
appSecret: APP_SECRET
|
||||
});
|
||||
return response.data.accessToken;
|
||||
}
|
||||
|
||||
// 尝试不同的 msgKey
|
||||
const MSG_KEYS = [
|
||||
"sampleImage",
|
||||
"image",
|
||||
"msg",
|
||||
"imageText",
|
||||
"image_message"
|
||||
];
|
||||
|
||||
async function trySend(accessToken, msgKey) {
|
||||
const url = `https://api.dingtalk.com/v1.0/robot/orgGroupSend`;
|
||||
const headers = {
|
||||
"x-acs-dingtalk-access-token": accessToken,
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
|
||||
const body = {
|
||||
openConversationId: OPEN_CONVERSATION_ID,
|
||||
robotCode: ROBOT_CODE,
|
||||
msgKey: msgKey,
|
||||
msgParam: JSON.stringify({
|
||||
"mediaId": MEDIA_ID,
|
||||
"altText": "日本 Yahoo 首页截图"
|
||||
})
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post(url, body, { headers });
|
||||
console.log(`✅ msgKey "${msgKey}" 成功!`);
|
||||
console.log(`Response: ${JSON.stringify(response.data)}`);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.log(`❌ msgKey "${msgKey}" 失败: ${err.response?.data?.message || err.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const accessToken = await getAccessToken();
|
||||
console.log(`Access Token 获取成功\n`);
|
||||
|
||||
console.log(`尝试发送图片到群聊...`);
|
||||
console.log(`Conversation ID: ${OPEN_CONVERSATION_ID}`);
|
||||
console.log(`Media ID: ${MEDIA_ID}\n`);
|
||||
|
||||
for (const msgKey of MSG_KEYS) {
|
||||
await trySend(accessToken, msgKey);
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user