mirror of
https://github.com/syuilo/ai.git
synced 2025-04-18 08:36:42 +00:00
😇
This commit is contained in:
parent
fb4ed538c6
commit
4133d9aeb3
3 changed files with 27 additions and 6 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"typescript.tsdk": "node_modules\\typescript\\lib"
|
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||||
}
|
"C_Cpp.errorSquiggles": "Disabled"
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ export default class extends Module {
|
||||||
public readonly name = "earthquake";
|
public readonly name = "earthquake";
|
||||||
private message: string = "";
|
private message: string = "";
|
||||||
|
|
||||||
|
private earthQuakeIndex: string[] = ["0未満", "0", "1", "2", "3", "4", "5弱", "5強", "6弱", "7"]
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public install() {
|
public install() {
|
||||||
this.createListenServer();
|
this.createListenServer();
|
||||||
|
@ -65,7 +67,7 @@ export default class extends Module {
|
||||||
const rawDataString = Buffer.concat(buffers).toString();
|
const rawDataString = Buffer.concat(buffers).toString();
|
||||||
// rawDataString について、Unicodeエスケープシーケンスが含まれていたら通常の文字列に変換する
|
// rawDataString について、Unicodeエスケープシーケンスが含まれていたら通常の文字列に変換する
|
||||||
// JSONでなければreturn falseする
|
// JSONでなければreturn falseする
|
||||||
if (rawDataString.match(/\\u[0-9a-f]{4}/)) {
|
if (rawDataString.match(/\\u[0-9a-f]{4}/) || true) {
|
||||||
const rawDataJSON = JSON.parse(
|
const rawDataJSON = JSON.parse(
|
||||||
rawDataString.replace(/\\u([\d\w]{4})/g, (match, p1) => {
|
rawDataString.replace(/\\u([\d\w]{4})/g, (match, p1) => {
|
||||||
return String.fromCharCode(parseInt(p1, 16));
|
return String.fromCharCode(parseInt(p1, 16));
|
||||||
|
@ -79,16 +81,34 @@ export default class extends Module {
|
||||||
max_index: rawDataJSON.max_index,
|
max_index: rawDataJSON.max_index,
|
||||||
intensity_list: rawDataJSON.intensity_list,
|
intensity_list: rawDataJSON.intensity_list,
|
||||||
};
|
};
|
||||||
this.message = `震度レポート\n${data.time.toLocaleString()}\n\n${
|
this.message = `地震かも?\n\n震度レポート\n${data.time.toLocaleString()}\n最大震度:${this.earthQuakeIndex[data.max_index + 1]}\n\n${
|
||||||
data.intensity_list.map((intensity) =>
|
data.intensity_list.map((intensity) =>
|
||||||
`震度${intensity.intensity}: ${intensity.region_list.join(" ")}`
|
`震度${this.earthQuakeIndex[intensity.index + 1]}: ${intensity.region_list.join(" ")}`
|
||||||
).join("\n")
|
).join("\n")
|
||||||
}`;
|
}`;
|
||||||
}
|
} if (rawDataJSON.type == 'eew' && false) {
|
||||||
|
const data: 緊急地震速報 = {
|
||||||
|
type: rawDataJSON.type,
|
||||||
|
time: new Date(parseInt(rawDataJSON.time)),
|
||||||
|
report: rawDataJSON.report,
|
||||||
|
epicenter: rawDataJSON.epicenter,
|
||||||
|
depth: rawDataJSON.depth,
|
||||||
|
magnitude: rawDataJSON.magnitude,
|
||||||
|
latitude: rawDataJSON.latitude,
|
||||||
|
longitude: rawDataJSON.longitude,
|
||||||
|
intensity: rawDataJSON.intensity,
|
||||||
|
index: rawDataJSON.index,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.report == '1') {
|
||||||
|
this.message = `**TEST TEST TEST TEST**\n地震かも?\n\n緊急地震速報\n${data.time.toLocaleString()}\n\n第${data.report}報\n震源地: ${data.epicenter}\n震源の深さ: ${data.depth}\n地震の規模(M): ${data.magnitude}\n緯度: ${data.latitude}\n経度: ${data.longitude}\n予想される最大震度(?): ${data.intensity}\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
console.log(rawDataJSON); // デバッグ用
|
console.log(rawDataJSON); // デバッグ用
|
||||||
this.returnResponse(res, "ok");
|
this.returnResponse(res, "ok");
|
||||||
if (this.message) {
|
if (this.message) {
|
||||||
this.ai.post({
|
this.ai.post({
|
||||||
|
cw: "試験運用中!!!!!",
|
||||||
visibility: "home",
|
visibility: "home",
|
||||||
text: this.message,
|
text: this.message,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue