feat: add postmessage for add note

This commit is contained in:
2025-07-05 08:28:37 +08:00
parent aefa8d371e
commit b0a0ab60d5
2 changed files with 11 additions and 7 deletions

View File

@@ -53,12 +53,12 @@
}, },
"post-note.ts": { "post-note.ts": {
"script_name": "post-note.ts", "script_name": "post-note.ts",
"script_length": 1925, "script_length": 2025,
"script_sha256": "dfd76c534aae1a31a86af9dd7de85dbf2426bfca45a7967b457ef3d114ede4a2", "script_sha256": "ed3d797d90c845b569c3280749cba07695951c555c99e70febd0fcc65de85db9",
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/post-note.ts", "script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/post-note.ts",
"single_script_file": true, "single_script_file": true,
"publish_time": 1737475603673, "publish_time": 1737475603673,
"update_time": 1750472965161 "update_time": 1751675304726
}, },
"print-env.ts": { "print-env.ts": {
"script_name": "print-env.ts", "script_name": "print-env.ts",

View File

@@ -20,12 +20,12 @@ if (!endpoint || !publicKeyPointHex) {
} }
const flags = parseArgs(Deno.args, { const flags = parseArgs(Deno.args, {
boolean: ["help"], boolean: ["help", "post-message"],
string: ["title"], string: ["title"],
}); });
if (flags.help) { if (flags.help) {
console.log("post-note.ts [--title <title>] <message>"); console.log("post-note.ts [--post-message] [--title <title>] <message>");
Deno.exit(0); Deno.exit(0);
} }
@@ -50,11 +50,15 @@ const encryptedMessage = await encryptEcdhP256(
); );
args.push(`memo=${encodeURIComponent(encryptedMessage.toString())}`); args.push(`memo=${encodeURIComponent(encryptedMessage.toString())}`);
if (flags["post-message"]) {
args.push("postMessage=true");
}
const response = await fetchWithTimoutAndAutoProxy( const response = await fetchWithTimoutAndAutoProxy(
`${endpoint}?${args.join("&")}`, `${endpoint}?${args.join("&")}`,
); );
console.info(response.status, await response.json()); console.info(response.status, await response.json());
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20250621T102758+08:00.MEYCIQCNUYJ+DlrcTT15QOdQ // @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20250705T082352+08:00.MEUCIQCXIiNRCQYEV3S5tDmu
// Z+6eFhnaJWSqMZhEBHxq0m3qMQIhAJvwKn5ZzXkDGj+PRcfCIQ0NWTLHTYsjcOOxUkYC/TBv // j/1mMjlNjHne9gWjxNJuJuz8pQIgNtTvQ4XwngDgNSAGYCUDCgB7abitnVUsG+NRVwJJurw=