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++) {
|
for (let i = 0; i < helps.length; i++) {
|
||||||
const help = helps[i];
|
const help = helps[i];
|
||||||
if (!help)
|
if (!help)
|
||||||
break;
|
continue;
|
||||||
|
|
||||||
summarys += `${i18next.t(`help${help.charAt(0).toUpperCase()}${help.slice(1)}`)}${EOL}`;
|
summarys += `${i18next.t(`help${help.charAt(0).toUpperCase()}${help.slice(1)}`)}${EOL}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,22 @@ try {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const response = await client.request("me/notification/", {
|
const response = await client.request("me/notification/", {
|
||||||
|
page: 1,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
for (const notification of response.data) {
|
for (const [index, notification] of response.data.entries()) {
|
||||||
if (notification.category !== "reply")
|
if (notification.category !== "reply")
|
||||||
break;
|
continue;
|
||||||
|
|
||||||
if (!notification.valueid) {
|
if (!notification.valueid) {
|
||||||
console.warn("返信通知にvalueidが存在しないため、スキップします");
|
console.warn("返信通知にvalueidが存在しないため、スキップします");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mem = Memory.memory;
|
||||||
|
if (mem.lastReadReply === notification.valueid) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +42,12 @@ try {
|
|||||||
|
|
||||||
if (!ueuseResponse.success || !ueuseResponse.data[0]) {
|
if (!ueuseResponse.success || !ueuseResponse.data[0]) {
|
||||||
console.warn("返信通知からユーズを参照できないため、スキップします");
|
console.warn("返信通知からユーズを参照できないため、スキップします");
|
||||||
break;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index === 0) {
|
||||||
|
const mem = Memory.memory;
|
||||||
|
mem.lastReadReply = ueuseResponse.data[0].uniqid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ueuses.push(ueuseResponse.data[0]);
|
ueuses.push(ueuseResponse.data[0]);
|
||||||
@@ -48,11 +59,24 @@ try {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const response = await client.request("ueuse/mentions", {
|
const response = await client.request("ueuse/mentions", {
|
||||||
|
page: 1,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.success) {
|
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 {
|
} else {
|
||||||
console.warn("メンションの取得に失敗しましたが、続行します");
|
console.warn("メンションの取得に失敗しましたが、続行します");
|
||||||
}
|
}
|
||||||
@@ -61,13 +85,6 @@ try {
|
|||||||
ueuses = [...new Set(ueuses)];
|
ueuses = [...new Set(ueuses)];
|
||||||
|
|
||||||
for (const ueuse of 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;
|
const mem = Memory.memory;
|
||||||
let text = ueuse.text;
|
let text = ueuse.text;
|
||||||
text = text.replace(`@${mem.userid}`, "");
|
text = text.replace(`@${mem.userid}`, "");
|
||||||
@@ -119,14 +136,6 @@ try {
|
|||||||
console.warn("ユーズの作成に失敗しました:", response.error_code);
|
console.warn("ユーズの作成に失敗しました:", response.error_code);
|
||||||
break;
|
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);
|
process.exit(0);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ const processMessage = async (message: any) => {
|
|||||||
for (const point of message.points) {
|
for (const point of message.points) {
|
||||||
const scaleMsg = scaleMessages[String(point.scale)];
|
const scaleMsg = scaleMessages[String(point.scale)];
|
||||||
if (!scaleMsg)
|
if (!scaleMsg)
|
||||||
break;
|
continue;
|
||||||
|
|
||||||
points[scaleMsg]?.push(point);
|
points[scaleMsg]?.push(point);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -10,8 +10,9 @@ class MemoryClass {
|
|||||||
if (!existsSync(path)) {
|
if (!existsSync(path)) {
|
||||||
writeFileSync(path, JSON.stringify({
|
writeFileSync(path, JSON.stringify({
|
||||||
processedInfo: [],
|
processedInfo: [],
|
||||||
repliedUeuse: [],
|
|
||||||
permissions: {},
|
permissions: {},
|
||||||
|
lastReadMention: "",
|
||||||
|
lastReadReply: "",
|
||||||
userid: "",
|
userid: "",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user