返回顶部
w

write-opennote写开放笔记

Write, update, and read OpenNote notes through the public API. Use when the user wants to publish notes, upload note images, manage labels, or look up previously written notes.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
87
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

write-opennote

通过OpenNote公共API写笔记

使用 https://api.opennote.cc/api/v1 的公共API向OpenNote写笔记。

开始使用

你需要准备

  1. 1. 一个 OpenNote账户 — 从 App Store 下载应用
  2. 一个 Pro订阅 — API访问是Pro功能
  3. 一个 个人访问令牌(PAT) — 从应用中生成

生成API令牌

  1. 1. 打开OpenNote应用
  2. 前往 个人资料API令牌
  3. 点击 创建令牌
  4. 选择你需要的权限范围:
- diaries:write — 创建和更新笔记 - images:write — 上传图片到笔记
  1. 5. 设置过期时间(默认:90天,最长:365天,或永不过期)
  2. 立即复制令牌 — 它以 milopatv1_ 开头,且 仅显示一次

设置环境变量

在你的OpenClaw环境中设置 OPENNOTEAPITOKEN:

选项A — OpenClaw配置(推荐):

在OpenClaw设置中,添加环境变量:

OPENNOTEAPITOKEN=milopatv1yourtoken_here

选项B — Shell配置文件(如果本地运行):
bash
export OPENNOTEAPITOKEN=milopatv1yourtoken_here

将其添加到 ~/.zshrc 或 ~/.bashrc 以在会话间持久化。

安全性:

  • - 切勿将令牌提交到版本控制
  • 该令牌授予对笔记的写入权限 — 请像密码一样对待
  • 如果泄露,请立即从应用的 个人资料API令牌 中撤销

令牌生命周期

  • - 令牌根据你设置的时长过期(默认90天)
  • 每个账户最多可以有 5个活跃令牌
  • 随时从应用中撤销未使用的令牌
  • 当令牌过期或被撤销时,生成一个新令牌并更新 OPENNOTEAPITOKEN
  • 如果收到 401 INVALIDAPITOKEN 错误,说明令牌已过期或被撤销

前提条件

令牌从 OPENNOTEAPITOKEN 环境变量中读取。它必须具有 diaries:write 权限范围。如果要上传图片,还需要 images:write 权限。

本地缓存文件

此技能在工作目录下的 .opennote/ 中维护两个本地文件:

  • - 标签缓存:.opennote/opennote-labels-cache.json — 缓存的用户标签
  • 笔记历史:.opennote/opennote-history.json — 通过此技能编写/编辑的所有笔记的日志

每次调用开始时始终读取这些文件。如果它们缺失,则视为空。如果用户询问之前编写的笔记,请查阅历史文件。

操作说明

步骤1:加载标签(获取或使用缓存)

读取 .opennote/opennote-labels-cache.json。如果存在且获取时间不超过24小时,则使用缓存的标签。

预期缓存格式:
json
{
fetchedAt: 1741111111111,
labels: [
{ categoryID: 1, categoryName: 个人, categoryColor: 4294198070 },
{ categoryID: 2, categoryName: 工作, categoryColor: 4283215696 }
]
}

如果缓存缺失、为空或过期(超过24小时),则从API获取标签:

bash
curl -s https://api.opennote.cc/api/v1/labels \
-H Authorization: Bearer $OPENNOTEAPITOKEN

响应:
json
{
labels: [
{ categoryID: 1, categoryName: 个人, categoryColor: 4294198070, visibility: true, coverImageName: null, lastModified: 1741111111111, fontFamily: null, backgroundPreset: null }
]
}

获取后,将结果写入 .opennote/opennote-labels-cache.json,并将当前时间戳作为 fetchedAt。

步骤2:选择标签/分类

  • - 如果用户通过名称或ID指定了标签,则使用该 categoryID。
  • 如果用户没有指定标签,则从缓存的标签列表中随机选择一个标签。
  • 如果根本没有缓存的标签,则使用 category: 0(无标签)。

当随机选择标签时,告知用户选择了哪个标签。

步骤3:收集用户的笔记内容

询问用户想写什么。收集:

  • - 笔记文本内容(必需)
  • 可选:标题
  • 可选:是否添加贴纸
  • 可选:是否包含图片(用户必须提供图片文件)

步骤4:生成时间戳和文件名

js
const now = Date.now(); // Unix毫秒
const fileName = ${now}.json;

步骤5:构建richContent(Quill Delta JSON字符串)

构建一个Quill Delta操作数组,然后使用 JSON.stringify() 将其转换为 richContent 字段。

支持的Quill Delta操作

纯文本:
json
{ insert: Hello world }

换行(必需 — 每个Delta必须至少以一个换行结束):
json
{ insert: \n }

内联样式(在文本插入上):

  • - bold(布尔值)
  • italic(布尔值)
  • underline(布尔值)
  • strike(布尔值)
  • color(十六进制字符串如 #2a7fff)— 使用下面的调色板以获得最佳效果
  • size(数字,通常2-99;应用默认值为17)

json
{ insert: 重要, attributes: { bold: true, color: #ff0000, size: 20 } }

可用颜色调色板(36种颜色):

始终存储浅色模式十六进制 — 应用在深色模式下渲染时会自动重新映射。

名称浅色模式十六进制
黑色#000000
炭灰色
#545454 |
| 深灰色 | #616161 |
| 暖石板色 | #455a64 |
| 深红 | #b71c1c |
| 深红 | #c0392b |
| 砖红色 | #bf360c |
| 深琥珀色 | #a04000 |
| 芥末色 | #9a6e00 |
| 深橄榄色 | #558b2f |
| 森林绿 | #2e7d32 |
| 深金色 | #8b6914 |
| 深青色 | #00695c |
| 深青色 | #00838f |
| 皇家蓝 | #1565c0 |
| 蓝色 | #007aff |
| 靛蓝 | #5856d6 |
| 深紫色 | #6a1b9a |
| 品红 | #e91e63 |
| 粉色 | #ff2d55 |
| 浆果色 | #880e4f |
| 李子色 | #6a0572 |
| 深紫罗兰 | #4a148c |
| 棕色 | #8d6e63 |
| 红色 | #ff3b30 |
| 深玫瑰色 | #ad1457 |
| 赤陶色 | #8b3a1f |
| 海绿色 | #007a63 |
| 午夜蓝 | #1a237e |
| 深鼠尾草 | #2e5902 |
| 赭色 | #7a5c00 |
| 钢灰色 | #37474f |
| 酒红色 | #8b0000 |
| 桃花心木色 | #6d2f1f |
| 深海色 | #005b72 |
| 深咖啡色 | #4e342e |

块/行样式(附加在行后的换行操作上):

  • - align:left、center、right
  • indent:整数
  • list:ordered、bullet、checked、unchecked
  • code-block:true
  • blockquote:true

json
{ insert: 一个项目符号点 },
{ insert: \n, attributes: { list: bullet } }

图片嵌入:
json
{ insert: {

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 write-opennote-1775927300 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 write-opennote-1775927300 技能

通过命令行安装

skillhub install write-opennote-1775927300

下载

⬇ 下载 write-opennote v1.0.0(免费)

文件大小: 6.9 KB | 发布时间: 2026-4-12 12:00

v1.0.0 最新 2026-4-12 12:00
- Initial release: Publish, update, and read notes using the OpenNote public API.
- Supports label management with caching for improved performance.
- Enables uploading note images and managing image embeds in notes.
- Maintains local log files for label cache and note history.
- Guides you through collecting note content, attaching labels, and assembling Quill rich content with formatting and images.
- Handles user authentication and security via the required API token environment variable.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部