Del: noticeUwuzuのAA / Del: worker_threadsを廃止 / FIx: client.tsでパスが誤っている問題 / Chg: Collapseのアップデートに反映

This commit is contained in:
2026-05-27 05:53:38 +09:00
parent 6b35112d1e
commit 0fe88a36ab
5 changed files with 62 additions and 71 deletions
+13 -18
View File
@@ -11,18 +11,18 @@ type SuccessPosted<T = string> = {
post: {
id: T;
content: string;
zone: "normal" | string;
zone: "normal" | "free";
created_at: string;
};
};
}
const BASE_URL = "https://collapse.jp/api/v3/bot";
const BASE_URL = "https://collapse.jp/api/v3/bot/";
export const createPost = async (data: {
text: string;
zone?: "normal" | string;
replyTarget?: "all" | string;
zone?: "normal" | "free";
replyTarget?: "all" | "followers" | "mutual" | "mentioned" | "none";
replyid?: string;
images?: [Blob, string][];
}, title: string) => {
@@ -78,30 +78,25 @@ export const createPost = async (data: {
const replyid = data.replyid === undefined && firstUniqid !== ""
? firstUniqid
: data.replyid;
const reply = replyid !== undefined
? `/${replyid}/reply`
: "";
const url = new URL(`/posts${reply}`, BASE_URL);
const body = new FormData();
body.append("content", data.text);
if (!replyid) {
body.append("zone", data.zone ?? "normal");
body.append("reply_restriction", data.replyTarget ?? "all");
body.append("zone", data.zone ?? "normal");
body.append("reply_restriction", data.replyTarget ?? "all");
if (replyid) {
body.append("reply_to_id", replyid);
}
if (data.images) {
data.images.forEach(img => body.append("images", img[0], img[1]));
}
const req = await fetch(url, {
const req = await fetch(new URL("posts", BASE_URL), {
method: "POST",
body: JSON.stringify({
content: data.text,
zone: data.zone ?? "normal",
reply_restriction: data.replyTarget ?? "all",
}),
body,
headers: {
"Authorization": `Bearer ${config.mtweet.token}`,
"Content-Type": "application/json",
"X-Idempotency-Key": String(process.hrtime.bigint()),
},
});
@@ -114,7 +109,7 @@ export const createPost = async (data: {
break;
}
console.warn(`${title}の投稿に失敗しました (試行 ${attempt}/${config.post.maxRetries}):`, res.error.message);
console.warn(`${title}の投稿に失敗しました (試行 ${attempt}/${config.post.maxRetries}):`, `${res.error.message}(${res.error.code})`);
if (attempt < config.post.maxRetries) {
const interval = res.error.details?.retry_after
? res.error.details.retry_after * 1000