macos-screenshot-telegram

TotalClaw 作者 totalclaw

在 macOS 上截取屏幕截图并将其发送到 Telegram。当用户要求捕获屏幕、截取屏幕截图或将屏幕截图发送到 Telegram 时使用。 解决 OpenClaw 的消息工具错误 (#15541),该错误无法发送媒体。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~hoyin258-macos-screenshot-telegram
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~hoyin258-macos-screenshot-telegram/file -o hoyin258-macos-screenshot-telegram.md
# Setup (Prerequisites)

## 1. Telegram Bot Token

1. 搵 @BotFather on Telegram
2.  Send `/newbot` 創建新 bot
3. 拎個 bot token(好似 `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz`)

## 2. 搵 Telegram Chat ID

- **個人 ID:** 搵 @userinfobot 或者 forward message 俾 @userinfobot
- **Group ID:** Forward 任何 message 俾 @userinfobot

## 3. OpenClaw Config

響你既 OpenClaw profile config 度加入:

```json
{
  "telegram": {
    "botToken": "YOUR_BOT_TOKEN_HERE",
    "allowFrom": ["YOUR_CHAT_ID"]
  }
}
```

## 4. Profile Naming

記住你用既 profile 名(例如 `main`、`rescue`),之後用既時候補返上去。

---

# macOS Screenshot to Telegram

This skill captures the macOS screen and sends it directly via Telegram Bot API.

## Workflow

1. **Capture screenshot** using macOS built-in command:
   ```bash
   /usr/sbin/screencapture -x <output-path>
   ```

2. **Copy to workspace** (required - OpenClaw has security restriction):
   ```bash
   cp <source> <workspace>/screenshot.png
   ```

3. **Send via Telegram Bot API** (bypasses buggy message tool):
   ```bash
   BOT_TOKEN=$(grep botToken <config-path> | sed 's/.*"botToken": *"\([^"]*\)".*/\1/')
   curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
     -F "chat_id=<target-chat-id>" \
     -F "photo=@<workspace>/screenshot.png"
   ```

## Required Parameters

When using this skill, ask the user for:
- `target-chat-id`: The Telegram chat ID to send to (e.g., user's ID for DM)
- `profile`: The OpenClaw profile name (e.g., "main", "rescue")

## How to Find Paths

1. **Config file:** `~/.openclaw-<profile>/openclaw.json`
2. **Workspace:** `~/.openclaw/workspace-<profile>/`

For example, if your profile is "main", paths would be:
- Config: `~/.openclaw-main/openclaw.json`
- Workspace: `~/.openclaw/workspace-main/`

## Notes

- The `message` tool in OpenClaw has a bug (#15541) that returns success but doesn't send media
- Always use curl with Telegram Bot API directly for reliable media delivery
- The screenshot must be copied to workspace first due to OpenClaw's allowed directory security restriction
- This skill is profile-agnostic - just pass the correct profile name

---

## 中文说明

# 设置(前提条件)

## 1. Telegram Bot Token

1. 在 Telegram 上找到 @BotFather
2. 发送 `/newbot` 创建新 bot
3. 获取 bot token(类似 `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz`)

## 2. 获取 Telegram Chat ID

- **个人 ID:** 找到 @userinfobot,或者将消息转发给 @userinfobot
- **群组 ID:** 将任意消息转发给 @userinfobot

## 3. OpenClaw 配置

在你的 OpenClaw profile 配置中加入:

```json
{
  "telegram": {
    "botToken": "YOUR_BOT_TOKEN_HERE",
    "allowFrom": ["YOUR_CHAT_ID"]
  }
}
```

## 4. Profile 命名

记住你使用的 profile 名称(例如 `main`、`rescue`),之后使用时再填回去。

---

# macOS 截图到 Telegram

此技能捕获 macOS 屏幕并通过 Telegram Bot API 直接发送。

## 工作流

1. **捕获截图**,使用 macOS 内置命令:
   ```bash
   /usr/sbin/screencapture -x <output-path>
   ```

2. **复制到工作区**(必需——OpenClaw 有安全限制):
   ```bash
   cp <source> <workspace>/screenshot.png
   ```

3. **通过 Telegram Bot API 发送**(绕过有缺陷的 message 工具):
   ```bash
   BOT_TOKEN=$(grep botToken <config-path> | sed 's/.*"botToken": *"\([^"]*\)".*/\1/')
   curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
     -F "chat_id=<target-chat-id>" \
     -F "photo=@<workspace>/screenshot.png"
   ```

## 必需参数

使用此技能时,向用户询问:
- `target-chat-id`:要发送到的 Telegram chat ID(例如,用于私聊的用户 ID)
- `profile`:OpenClaw profile 名称(例如 "main"、"rescue")

## 如何查找路径

1. **配置文件:** `~/.openclaw-<profile>/openclaw.json`
2. **工作区:** `~/.openclaw/workspace-<profile>/`

例如,如果你的 profile 是 "main",路径将为:
- 配置:`~/.openclaw-main/openclaw.json`
- 工作区:`~/.openclaw/workspace-main/`

## 注意事项

- OpenClaw 中的 `message` 工具有一个错误 (#15541),它返回成功但不发送媒体
- 始终直接使用 curl 配合 Telegram Bot API,以实现可靠的媒体投递
- 由于 OpenClaw 的允许目录安全限制,必须先将截图复制到工作区
- 此技能与 profile 无关——只需传入正确的 profile 名称即可