2026.4.0-beta.0 #12
+31
-17
@@ -17,22 +17,39 @@ export const createUeuse = async (data: ApiMap["ueuse/create"]["body"], title: s
|
||||
const mem = Memory.memory;
|
||||
const maxLength = mem.max_length;
|
||||
const excessedMessage = "👉返信に続きがあります。";
|
||||
|
||||
let remainingText = data.text;
|
||||
|
||||
// 行単位で分割
|
||||
let lines = data.text.split(EOL);
|
||||
let firstUniqid = "";
|
||||
|
||||
while (remainingText.length > 0) {
|
||||
while (lines.length > 0) {
|
||||
let currentText = "";
|
||||
let bodyTextLength = 0;
|
||||
|
||||
const limit = maxLength - (excessedMessage.length + EOL.length * 2);
|
||||
|
||||
if (remainingText.length <= maxLength) {
|
||||
currentText = remainingText;
|
||||
bodyTextLength = remainingText.length;
|
||||
remainingText = "";
|
||||
} else {
|
||||
bodyTextLength = maxLength - excessedMessage.length - 2;
|
||||
currentText = remainingText.slice(0, bodyTextLength) + EOL.repeat(2) + excessedMessage;
|
||||
remainingText = remainingText.slice(bodyTextLength);
|
||||
while (lines.length > 0) {
|
||||
const nextLine = lines[0];
|
||||
if (nextLine === undefined) break;
|
||||
|
||||
if (nextLine.length > limit && currentText === "") {
|
||||
const targetLine = lines.shift() || "";
|
||||
currentText = targetLine.slice(0, limit);
|
||||
|
||||
lines.unshift(targetLine.slice(limit));
|
||||
break;
|
||||
}
|
||||
|
||||
const potentialText = currentText ? currentText + EOL + nextLine : nextLine;
|
||||
if (potentialText.length <= limit) {
|
||||
currentText = potentialText;
|
||||
lines.shift();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.length > 0) {
|
||||
currentText += EOL.repeat(2) + excessedMessage;
|
||||
}
|
||||
|
||||
let postedUniqid = "";
|
||||
@@ -64,10 +81,7 @@ export const createUeuse = async (data: ApiMap["ueuse/create"]["body"], title: s
|
||||
break;
|
||||
}
|
||||
|
||||
if (firstUniqid === "") {
|
||||
firstUniqid = postedUniqid;
|
||||
}
|
||||
|
||||
if (firstUniqid === "") firstUniqid = postedUniqid;
|
||||
console.log(`${title}を投稿:`, postedUniqid);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user