介绍
# GIF Sender
在 WhatsApp 对话中自然地发送 GIF。
## 关键:WhatsApp GIF 工作流
WhatsApp 不支持直接的 Tenor/Giphy URL。你必须: 1. 下载 GIF 2. 转换为 MP4 3. 使用 `gifPlayback: true` 发送
## 完整工作流
### 步骤 1:搜索 GIF ```bash gifgrep "SEARCH QUERY" --max 5 --format url ``` 使用英文搜索以获得最佳结果。
**务必获取 5 个结果并根据文件名/描述选择最好的一个**——不要只取第一个结果。
### 步骤 2:下载 GIF ```bash curl -sL "GIF_URL" -o /tmp/gif.gif ```
### 步骤 3:转换为 MP4 ```bash ffmpeg -i /tmp/gif.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" /tmp/gif.mp4 -y ```
### 步骤 4:通过消息工具发送 ``` message action=send to=NUMBER message="" filePath=/tmp/gif.mp4 gifPlayback=true ```
注意:使用不可见字符 ``(从左至右标记,U+200E)作为消息,以发送不带可见标题的 GIF。
## 单行示例
```bash # Search gifgrep "thumbs up" --max 3 --format url
# Pick best URL, then: curl -sL "https://media.tenor.com/xxx.gif" -o /tmp/g.gif && \ ffmpeg -i /tmp/g.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" /tmp/g.mp4 -y 2>/dev/null
# Then send with message tool, gifPlayback=true ```
## 何时发送 GIF
✅ 适合的时候: - 用户要求发送 GIF - 庆祝好消息 - 有趣的反应 - 表达情绪(兴奋、捂脸等)
❌ 不要滥用: - 每个语境发一张 GIF 就够了 - 并不是每条消息都需要 GIF
## 常用搜索词
| 情绪 | 搜索词 | |---------|--------------| | 开心 | celebration, party, dancing, excited | | 认可 | thumbs up, nice, good job, applause | | 有趣 | laugh, lol, haha, funny | | 震惊 | mind blown, shocked, surprised, wow | | 难过 | crying, sad, disappointed | | 沮丧 | facepalm, ugh, annoyed | | 爱 | heart, love, hug | | 酷 | sunglasses, cool, awesome |
## 安全与注意事项
- **来源域名**:gifgrep 仅搜索可信的 GIF 提供商(Tenor、Giphy) - **文件处理**:所有下载均进入 `/tmp` 并每次被覆盖(`-y` 标志) - **空标题**:`` 字符(U+200E,从左至右标记)用作不可见标题,以便 WhatsApp 发送不带可见文本的 GIF。这是标准的 Unicode 控制字符,不是注入技术 - **WhatsApp 集成**:使用平台内置的 `message` 工具——不需要单独的 WhatsApp 凭证 - **ffmpeg 安全**:仅处理来自可信提供商的 GIF 文件;无任意文件执行
## 原理
- WhatsApp 会在内部将所有 GIF 转换为 MP4 - 直接的 Tenor/Giphy URL 经常失败 - 带有 `gifPlayback=true` 的 MP4 会显示为循环 GIF - 小文件大小 = 快速发送