ChatMask Skill
When the user sends chat screenshots and asks to pixelate or hide identity
elements, follow the steps below in order: Setup → Workflow.
No external API key is required. This skill uses your existing AI
capabilities to locate regions in the image, then delegates only the image
manipulation to the local Python script.
Setup (run once, idempotent)
Run this block before the first job. Every step is guarded so re-running is safe.
CODEBLOCK0
What this installs: Pillow (image processing) and python-dotenv (.env loader
for standalone use only). The requests package is not installed by the
skill — it is only needed for standalone/non-skill mode and lives in
requirements-standalone.txt. No network calls are made by the script at runtime.
Network behavior: The only outbound calls in Setup are git clone (one-time)
and pip install (one-time). During Workflow, process.py makes no network
calls when --bbox-json is supplied — all processing is local.
Workflow
Read Element Selection and Option Configuration to translate natural-language
requests into the correct flags before running.
1. Prepare directories
CODEBLOCK1
2. Process each image individually
Each image must be analysed and pixelated separately. Different screenshots
have different element positions — passing one image's bounding boxes to another
would leave sensitive regions unredacted. Repeat the following block for every
image the user sent.
Why per-image? --bbox-json is scoped to a single image. process.py
enforces this: it exits with an error if more than one image is present in the
input directory when --bbox-json is used.
For each image <filename.png>:
2a. Copy the image into its own input directory
CODEBLOCK2
2b. Analyse the image with your vision capabilities
Use the prompt below on $IN_DIR/$IMG_FILE and capture the JSON output.
The schema uses normalized coordinates (0-1000) where (0,0) is top-left
and (1000,1000) is bottom-right, in y_min, x_min, y_max, x_max order.
CODEBLOCK3
Omit keys for elements the user did not request (see Element Selection below).
2c. Run pixelation for this image
Pass the JSON from 2b via --bbox-json. No API key is read or written.
CODEBLOCK4
Repeat steps 2a–2c for every image before proceeding.
3. Return results to user
CODEBLOCK5
Attach or share all processed images from $OUT_DIR/.
Element Selection
Translate the user's intent to --elements. Default (no flag) pixelates all three.
| User says (EN / 中文) | INLINECODE15 flag |
|---|
| all / default / 全部 / 默认 / 全部打码 | (omit flag — default: all three) |
| chat name only / 只隐藏聊天名称 |
--elements chat_name |
| profile pics only / 只隐藏头像 |
--elements profile_pic |
| display names only / 只隐藏昵称 / 只隐藏用户名 |
--elements display_name |
| avatars and display names / 隐藏头像和昵称 |
--elements profile_pic,display_name |
| chat name and avatars / 隐藏聊天名称和头像 |
--elements chat_name,profile_pic |
| chat name and display names / 隐藏聊天名称和昵称 |
--elements chat_name,display_name |
When not all three elements are requested, omit the unused keys from the
bounding-box JSON prompt in step 2 to reduce noise.
Element definitions:
- - chatname: Title text in the top navigation bar (group name, contact name, channel title)
- profilepic: Circular/rounded avatar images next to message bubbles
- display_name: Text username/nickname labels next to or above message bubbles
Option Configuration
| User says (EN / 中文) | Flag |
|---|
| soft blur / mist effect / 模糊效果 / 雾化(默认) | INLINECODE22 (default) |
| block / mosaic / pixelate blocks / 马赛克 / 方块效果 |
--pixel-mode B |
Full Example (copy-paste ready)
Two images processed, each with its own per-image bounding-box analysis:
CODEBLOCK6
More examples
CODEBLOCK7
Troubleshooting
| Symptom | Cause | Fix |
|---|
| INLINECODE24 | Multiple images in input dir with INLINECODE25 | Use a separate $IN_DIR per image and run process.py once per image |
| INLINECODE28 fails |
Missing venv module | Run
apt-get install -y python3-venv then re-run Setup |
|
git clone fails | No git installed or no network | Run
apt-get install -y git or check network connectivity |
|
No images found in input directory | Copy step failed | Check
ls $IN_DIR/ and confirm the filename is exact |
| Image copied unchanged with
SKIPPED in summary | JSON parse failure | Check printed warning; verify the bbox JSON is valid |
| Wrong regions pixelated | Bounding boxes were inaccurate | Re-analyse the image and adjust coordinates; try
--pixel-mode B |
ChatMask 技能
当用户发送聊天截图并要求对身份信息元素进行像素化或隐藏时,请按以下顺序执行步骤:设置 → 工作流程。
无需外部 API 密钥。 本技能利用您现有的 AI 能力定位图像中的区域,然后仅将图像处理操作委托给本地 Python 脚本。
设置(运行一次,幂等)
在首次任务前运行此代码块。每一步都有保护措施,因此重新运行是安全的。
bash
默认安装路径 — 可在调用技能前通过设置 CHATPIXELATEPATH 覆盖
CHAT
PIXELATEPATH=${CHAT
PIXELATEPATH:-$HOME/.openclaw/skills/chatmask}
1. 克隆仓库并切换到固定、审计过的提交版本
审计提交:62b0d1132e8cad8455ef29f74a98da486ff102d4 (frankz2020/chatmask, v1.1.0)
PINNED_SHA=62b0d1132e8cad8455ef29f74a98da486ff102d4
if [ ! -d $CHAT
PIXELATEPATH/.git ]; then
git clone https://github.com/frankz2020/chatmask.git $CHAT
PIXELATEPATH
fi
强制使用固定提交 — 防止分支移动导致静默漂移
(cd $CHAT
PIXELATEPATH && git fetch --quiet origin && git checkout --quiet $PINNED_SHA)
2. 如果虚拟环境不存在则创建
if [ ! -d $CHAT
PIXELATEPATH/.venv ]; then
python3 -m venv $CHAT
PIXELATEPATH/.venv \
|| { apt-get install -y python3-venv && python3 -m venv $CHAT
PIXELATEPATH/.venv; }
fi
3. 安装/升级依赖(Pillow, python-dotenv — 运行时无网络调用)
$CHAT
PIXELATEPATH/.venv/bin/pip install -q -r $CHAT
PIXELATEPATH/requirements.txt
export CHATPIXELATEPATH
PYTHON=$CHATPIXELATEPATH/.venv/bin/python3
安装内容: Pillow(图像处理)和 python-dotenv(仅独立使用时的 .env 加载器)。requests 包不由技能安装——它仅在独立/非技能模式下需要,位于 requirements-standalone.txt 中。脚本在运行时不会进行任何网络调用。
网络行为: 设置中唯一的出站调用是 git clone(一次性)和 pip install(一次性)。在工作流程中,当提供 --bbox-json 时,process.py 不进行任何网络调用——所有处理均在本地完成。
工作流程
在运行前阅读元素选择和选项配置,将自然语言请求转换为正确的标志。
1. 准备目录
bash
JOBID=job$(date +%s)
OUTDIR=/tmp/chatpixelateout$JOB_ID
mkdir -p $OUT_DIR
2. 单独处理每张图像
每张图像必须单独分析和像素化。 不同的截图具有不同的元素位置——将一张图像的边界框传递给另一张图像会导致敏感区域未被遮盖。对用户发送的每张图像重复以下代码块。
为什么逐张处理? --bbox-json 作用于单张图像。process.py 强制执行此规则:当使用 --bbox-json 时,如果输入目录中存在多张图像,则会报错退出。
对于每张图像 :
2a. 将图像复制到其单独的输入目录
bash
为每个文件使用新的单图像输入目录
IMG_FILE=
# 替换为实际文件名
INDIR=/tmp/chatpixelatein${JOBID}${IMG_FILE%.*}
mkdir -p $IN_DIR
cp $HOME/.openclaw/media/inbound/$IMGFILE $INDIR/
2b. 使用您的视觉能力分析图像
对 $INDIR/$IMGFILE 使用以下提示,并捕获 JSON 输出。
模式使用归一化坐标(0-1000),其中 (0,0) 为左上角,(1000,1000) 为右下角,顺序为 ymin, xmin, ymax, xmax。
您是一名隐私专家,正在分析聊天/消息应用截图。
该应用可能是微信、WhatsApp、Telegram、iMessage、Slack、Discord、LINE、
KakaoTalk 或任何其他消息应用。界面可能是英文、中文或任何其他语言。
根据视觉布局和位置识别请求的元素,而不是根据应用特定的标签。
您的任务:
定位以下所有出现的元素并返回其边界框:
- 1. chatnames — 顶部导航/标题栏中的文本标题(对话名称、群组名称、频道标题、返回按钮联系人姓名)。
- profilepics — 消息气泡旁、标题栏中或参与者列表中的圆形或圆角头像图像。每个不同的头像出现都是一个独立的区域。
- display_names — 消息气泡旁边或上方的文本用户名/昵称标签(发送者姓名,与标题栏标题不同)。
规则:
- - 仅返回上面列出的元素。
- 每个元素出现必须是一个独立的区域。
- 覆盖完整的可见区域,并添加少量内边距。
- 如果某个元素类型不可见,则为该键返回空列表。
- 使用归一化坐标(0-1000),其中 (0,0) 为左上角,(1000,1000) 为右下角。
- 坐标顺序:ymin, xmin, ymax, xmax(上、左、下、右)。
- 所有值必须为 0 到 1000 之间的整数。
仅使用以下精确模式返回 JSON 对象(JSON 外无额外文本):
{
chatnames: [{ymin: int, xmin: int, ymax: int, x_max: int}],
profilepics: [{ymin: int, xmin: int, ymax: int, x_max: int}],
displaynames: [{ymin: int, xmin: int, ymax: int, x_max: int}]
}
省略用户未请求的元素键(参见下面的元素选择)。
2c. 对此图像运行像素化
通过 --bbox-json 传递 2b 中的 JSON。不会读取或写入 API 密钥。
bash
BBOX=<2b 的 JSON 输出>
$PYTHON $CHATPIXELATEPATH/process.py \
$IN_DIR \
$OUT_DIR \
--bbox-json $BBOX \
[选项] # 参见下面的元素选择和选项配置
在继续之前,对每张图像重复步骤 2a–2c。
3. 向用户返回结果
bash
ls $OUTDIR/*pixelated.png
附加或分享来自 $OUT_DIR/ 的所有已处理图像。
元素选择
将用户的意图转换为 --elements。默认(无标志)像素化所有三个元素。
| 用户说法(英文 / 中文) | --elements 标志 |
|---|
| all / default / 全部 / 默认 / 全部打码 | (省略标志 — 默认:全部三个) |
| chat name only / 只隐藏聊天名称 |
--elements chat_name |
| profile pics only / 只隐藏头像 | --elements profile_pic |
| display names only / 只隐藏昵称 / 只隐藏用户名 | --elements display_name |
| avatars and display names / 隐藏头像和昵称 | --elements profilepic,displayname |
| chat name and avatars / 隐藏聊天名称和头像 | --elements chatname,profilepic |
| chat name and display names / 隐藏聊天名称和昵称 | --elements chatname,displayname |
当未请求全部三个元素时,从步骤 2 的边界框 JSON 提示中省略未使用的键以减少干扰。
元素定义:
- - chatname:顶部导航栏中的标题文本(群组名称、联系人姓名、频道标题)
- profilepic:消息气泡旁的圆形/圆角头像图像
- display_name:消息气泡旁边或上方的文本用户名/昵称标签
选项配置
| 用户说法(英文 / 中文) | 标志 |
|---|
| soft blur / mist effect / 模糊效果 / 雾化(默认) | --pixel-mode A (默认) |
| block / mosaic / pixelate blocks / 马赛克 / 方块效果 |
--pixel-mode B