Feat: #7
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import client from "@/lib/client";
|
import client from "@/lib/client";
|
||||||
import config from "@/lib/config";
|
import config from "@/lib/config";
|
||||||
import initI18n from "@/lib/i18n";
|
import initI18n from "@/lib/i18n";
|
||||||
|
import Memory from "@/lib/memory";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { readFileSync } from "node:fs";
|
import { readFileSync } from "node:fs";
|
||||||
@@ -39,11 +40,21 @@ if (config.earthquake?.useHistoryData) {
|
|||||||
? JSON.parse(event.data)
|
? JSON.parse(event.data)
|
||||||
: event.data;
|
: event.data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`メッセージのパースでエラーが発生: ${err}`);
|
console.error(`地震情報メッセージのパースでエラーが発生: ${err}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mem = Memory.memory;
|
||||||
|
if (mem.processedInfo.includes(message.id) && !config.debug) {
|
||||||
|
console.log("重複した地震情報: ", message.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
processMessage(message);
|
processMessage(message);
|
||||||
|
if (!config.debug) {
|
||||||
|
mem.processedInfo.concat([message.id]);
|
||||||
|
Memory.memory = mem;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class MemoryClass {
|
|||||||
constructor() {
|
constructor() {
|
||||||
if (!existsSync(path)) {
|
if (!existsSync(path)) {
|
||||||
writeFileSync(path, JSON.stringify({
|
writeFileSync(path, JSON.stringify({
|
||||||
|
processedInfo: [],
|
||||||
repliedUeuse: [],
|
repliedUeuse: [],
|
||||||
permissions: {},
|
permissions: {},
|
||||||
userid: "",
|
userid: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user