关于 google-chat
google-chat 是用于读取和管理 Google Chat 消息、空间、会话串及成员的命令行 skill。它采用独立 OAuth,而非 MCP 服务,并且需要 Google Workspace 账户。
主要功能
- 01读取消息、会话串、空间和成员
- 02发送消息、私信和媒体
- 03编辑、删除消息并添加表情回应
- 04为用户和空间设置别名
- 05通过 dry-run 预览写入请求
适用场景
- 01查看空间中的近期消息
- 02在会话串中发消息或回复
- 03向同事发送私信
MCP 相关
它使用独立 OAuth 身份验证,无需 MCP 服务。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ sanjay3290/ ai-skills --skill google-chat安装后在 Claude Code 中输入/google-chat确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.gitignoredirectory.example.jsonREADME.mdrequirements.txtscripts/auth.pychat.py详细介绍
Google Chat
轻量级 Google Chat 集成,使用独立的 OAuth 身份验证。无需 MCP 服务。
⚠️ 需要 Google Workspace 帐户。 不支持个人 Gmail 帐户。
所有内容都会以经过身份验证的用户身份发送,因此请谨慎处理写入命令,视其为对外发送: 在向空间发布消息之前,先与用户确认确切文本;绝不要发送到用户未指定的频道。
首次设置
pip install -r requirements.txt
python scripts/auth.py login # opens browser
python scripts/auth.py status # verify
python scripts/auth.py logout
命令
所有操作均通过 scripts/chat.py 执行。首次使用时,如果尚未登录,会自动进行身份验证。
读取
python scripts/chat.py get-messages spaces/AAAA123 --limit 10
python scripts/chat.py get-messages spaces/AAAA123 --limit 10 --raw # full JSON
python scripts/chat.py get-message spaces/AAAA123/messages/XYZ
python scripts/chat.py list-threads spaces/AAAA123
python scripts/chat.py list-spaces
python scripts/chat.py find-space "Project Alpha" # ignores punctuation/spacing
python scripts/chat.py list-members spaces/AAAA123
默认情况下,读取输出经过精简:每条消息占一个区块,包含时间戳、发送者、文本和资源名称。与原始 API 负载相比,体积约缩小 14 倍;当 Agent 读取的每个令牌都需要付费时,这一点很重要。需要完整 JSON 时,请使用 --raw。
写入
python scripts/chat.py send-message spaces/AAAA123 "Hello team!"
python scripts/chat.py send-dm [email protected] "Hey, quick question..."
python scripts/chat.py reply-in-thread spaces/AAAA123 spaces/AAAA123/threads/T "Following up."
python scripts/chat.py send-media spaces/AAAA123 "Latest mocks" --file a.png --file b.png
python scripts/chat.py edit-message spaces/AAAA123/messages/XYZ "Corrected text."
python scripts/chat.py delete-message spaces/AAAA123/messages/XYZ
python scripts/chat.py delete-message spaces/AAAA123/messages/XYZ --force # has thread replies
python scripts/chat.py add-reaction spaces/AAAA123/messages/XYZ 👍
python scripts/chat.py setup-space "New Project" [email protected] [email protected]
python scripts/chat.py find-dm [email protected]
在任何写入命令中添加 --dry-run,即可打印请求而不实际发送。配置或测试工作流时可使用它,避免内容出现在真实频道中。(对于 send-dm,它会报告解析出的收件人,而非私信空间,因为解析需要实时调用。)
编辑和删除
send-message、send-dm 和 send-media 会返回所创建消息的 name(spaces/X/messages/Y)——这就是 edit-message、delete-message 和 add-reaction 所需的参数。你只能编辑或删除自己发送的消息。要修正较早的消息,请先使用 get-messages 查找其名称。
附件
send-media 接受可重复使用的 --file。只有当所有附件都是媒体(图片或视频)时,Google Chat 才允许在一条消息中添加多个附件;混合类型的批次会自动拆分为每个文件一条消息,并将说明文字放在第一条消息中。--attachment 仍可作为单个 --file 的别名使用。
可选别名
输入完整的电子邮件地址和 spaces/AAAA... ID 很麻烦,而且让 Agent 调用 list-spaces 来查找每天使用的频道也很慢。将 directory.example.json 复制为 directory.json 并设置短名称映射:
{
"users": { "alex": "[email protected]" },
"spaces": { "team": { "id": "spaces/AAAAxxxxxxx", "name": "My Team" } }
}
之后,send-message team "Deploying now" 和 send-dm alex "..." 都会在本地解析,不会调用 API。完整电子邮件地址和 spaces/... 名称仍可在任何地方使用。
directory.json 是个人文件,并已加入 gitignore。它完全可选——不使用时,所有命令仍然可用;无法解析的别名会立即报错并列出有效别名,而不会静默退回到扫描。
消息格式
Chat 支持 *bold*、_italic_、~strike~、`code`、三反引号代码块和 <url|label> 链接。它不支持 Markdown 标题、表格或 []( ) 链接——这些内容会按原样显示。
令牌管理
令牌使用系统密钥环安全存储:
- macOS:Keychain
- Windows:Windows Credential Locker
- Linux:Secret Service API(GNOME Keyring、KDE Wallet 等)
服务名称:google-chat-skill-oauth。过期令牌会自动刷新。