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:
61
send_dingtalk_simple.ps1
Normal file
61
send_dingtalk_simple.ps1
Normal file
@@ -0,0 +1,61 @@
|
||||
$APP_KEY = "ding4ursdp0l2giat4bj"
|
||||
$APP_SECRET = "J0gBicjKiIHoKla7WfKKhRs1Tv8L6Xd5UhW3EVQByF16G7Vn7UUcRhP6u-PBCQNo"
|
||||
$OPEN_CONVERSATION_ID = "cidcjYshXVtKck5LfOO9AqOJg=="
|
||||
$ROBOT_CODE = "4293382733"
|
||||
$IMAGE_PATH = "C:\Users\ALC\.openclaw\media\browser\1ad3cfc9-2dd5-496b-9fa5-26d23b973f76.jpg"
|
||||
|
||||
Write-Host "开始发送图片到钉钉..."
|
||||
|
||||
# Get Access Token
|
||||
$tokenUrl = "https://api.dingtalk.com/v1.0/oauth2/accessToken"
|
||||
$tokenHeaders = @{ "Content-Type" = "application/json" }
|
||||
$tokenBody = @{ appKey = $APP_KEY; appSecret = $APP_SECRET } | ConvertTo-Json
|
||||
|
||||
$response = Invoke-RestMethod -Uri $tokenUrl -Method Post -Headers $tokenHeaders -Body $tokenBody
|
||||
$accessToken = $response.accessToken
|
||||
Write-Host "Access Token obtained."
|
||||
|
||||
# Upload file
|
||||
$uploadUrl = "https://api.dingtalk.com/v1.0/media/upload?type=image"
|
||||
$uploadHeaders = @{ "x-acs-dingtalk-access-token" = $accessToken }
|
||||
|
||||
$fileBytes = [System.IO.File]::ReadAllBytes($IMAGE_PATH)
|
||||
$fileName = Split-Path $IMAGE_PATH -Leaf
|
||||
|
||||
$boundary = "----WebKitFormBoundary" + [System.Guid]::NewGuid().ToString()
|
||||
$body = @()
|
||||
|
||||
$body += "--$boundary"
|
||||
$body += "Content-Disposition: form-data; name=`"file`"; filename=`"$fileName`""
|
||||
$body += "Content-Type: application/octet-stream"
|
||||
$body += ""
|
||||
$body += [System.Text.Encoding]::ASCII.GetString($fileBytes)
|
||||
$body += "--$boundary--"
|
||||
|
||||
$body = [System.Text.Encoding]::UTF8.GetBytes($body -join "`r`n")
|
||||
|
||||
$uploadHeaders["Content-Type"] = "multipart/form-data; boundary=$boundary"
|
||||
|
||||
$uploadResponse = Invoke-RestMethod -Uri $uploadUrl -Method Post -Headers $uploadHeaders -Body $body
|
||||
$mediaId = $uploadResponse.mediaId
|
||||
Write-Host "File uploaded. Media ID: $mediaId"
|
||||
|
||||
# Send message
|
||||
$sendUrl = "https://api.dingtalk.com/v1.0/robot/orgGroupSend"
|
||||
$sendHeaders = @{
|
||||
"x-acs-dingtalk-access-token" = $accessToken
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
$sendBody = @{
|
||||
openConversationId = $OPEN_CONVERSATION_ID
|
||||
robotCode = $ROBOT_CODE
|
||||
msgKey = "sampleImage"
|
||||
msgParam = @{
|
||||
mediaId = $mediaId
|
||||
altText = "日本 Yahoo 首页截图"
|
||||
} | ConvertTo-Json -Depth 3
|
||||
} | ConvertTo-Json -Depth 3
|
||||
|
||||
$sendResponse = Invoke-RestMethod -Uri $sendUrl -Method Post -Headers $sendHeaders -Body $sendBody
|
||||
Write-Host "Message sent. Process Query Key: $($sendResponse.processQueryKey)"
|
||||
Reference in New Issue
Block a user