Fix: for文でスキップではなくループの終了を行っていた問題 / Feat: #10
This commit is contained in:
@@ -47,7 +47,7 @@ export default async function helpCommand(ueuse: ueuseModule, args: string[]) {
|
||||
for (let i = 0; i < helps.length; i++) {
|
||||
const help = helps[i];
|
||||
if (!help)
|
||||
break;
|
||||
continue;
|
||||
|
||||
summarys += `${i18next.t(`help${help.charAt(0).toUpperCase()}${help.slice(1)}`)}${EOL}`;
|
||||
}
|
||||
|
||||
@@ -17,16 +17,22 @@ try {
|
||||
|
||||
{
|
||||
const response = await client.request("me/notification/", {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
for (const notification of response.data) {
|
||||
for (const [index, notification] of response.data.entries()) {
|
||||
if (notification.category !== "reply")
|
||||
break;
|
||||
continue;
|
||||
|
||||
if (!notification.valueid) {
|
||||
console.warn("返信通知にvalueidが存在しないため、スキップします");
|
||||
continue;
|
||||
}
|
||||
|
||||
const mem = Memory.memory;
|
||||
if (mem.lastReadReply === notification.valueid) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,7 +42,12 @@ try {
|
||||
|
||||
if (!ueuseResponse.success || !ueuseResponse.data[0]) {
|
||||
console.warn("返信通知からユーズを参照できないため、スキップします");
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
const mem = Memory.memory;
|
||||
mem.lastReadReply = ueuseResponse.data[0].uniqid;
|
||||
}
|
||||
|
||||
ueuses.push(ueuseResponse.data[0]);
|
||||
@@ -48,11 +59,24 @@ try {
|
||||
|
||||
{
|
||||
const response = await client.request("ueuse/mentions", {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
ueuses.push(...response.data);
|
||||
for (const [index, mention] of response.data.entries()) {
|
||||
const mem = Memory.memory;
|
||||
if (mem.lastReadMention === mention.uniqid) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
const mem = Memory.memory;
|
||||
mem.lastReadMention = mention.uniqid;
|
||||
}
|
||||
|
||||
ueuses.push(mention);
|
||||
}
|
||||
} else {
|
||||
console.warn("メンションの取得に失敗しましたが、続行します");
|
||||
}
|
||||
@@ -61,13 +85,6 @@ try {
|
||||
ueuses = [...new Set(ueuses)];
|
||||
|
||||
for (const ueuse of ueuses) {
|
||||
const repliedUeuse = (Memory.memory["repliedUeuse"] as string[]);
|
||||
|
||||
if (repliedUeuse.includes(ueuse.uniqid)) {
|
||||
console.log("既に応答しているため、スキップします");
|
||||
break;
|
||||
}
|
||||
|
||||
const mem = Memory.memory;
|
||||
let text = ueuse.text;
|
||||
text = text.replace(`@${mem.userid}`, "");
|
||||
@@ -119,14 +136,6 @@ try {
|
||||
console.warn("ユーズの作成に失敗しました:", response.error_code);
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
const repliedUeuse = (Memory.memory["repliedUeuse"] as string[]);
|
||||
repliedUeuse.push(ueuse.uniqid);
|
||||
const mem = Memory.memory;
|
||||
mem["repliedUeuse"] = repliedUeuse;
|
||||
Memory.memory = mem;
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
|
||||
@@ -111,7 +111,7 @@ const processMessage = async (message: any) => {
|
||||
for (const point of message.points) {
|
||||
const scaleMsg = scaleMessages[String(point.scale)];
|
||||
if (!scaleMsg)
|
||||
break;
|
||||
continue;
|
||||
|
||||
points[scaleMsg]?.push(point);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user