第一報と最終報のみをノートするように

This commit is contained in:
suti7yk5032 2024-08-16 00:34:22 +09:00
parent 7efaa9bbab
commit 62de9ff3d3

View file

@ -34,15 +34,19 @@ class Bot():
def format_earthquake_info(self, data):
if data['type'] == 'eew':
event_time = datetime.fromtimestamp(int(data['time']) / 1000).strftime("%Y年%m月%d%H時%M分%S秒")
if data['report'] == 'final':
report_number = '最終'
if data["report"] == '1' or data['report'] == 'final':
if data['report'] == 'final':
report_number = '最終'
else:
report_number = '' + data['report']
intensity = data['intensity']
epicenter = data['epicenter']
epicenter_depth = data['depth']
magnitude = data['magnitude']
result = {"result": 0, "detail": f"震源地 {epicenter} 予想震度 {intensity}\nマグニチュード {magnitude} 震源の深さ {epicenter_depth}\n緊急地震速報 {report_number}\n時刻 | {event_time}"}
else:
report_number = '' + data['report']
intensity = data['intensity']
epicenter = data['epicenter']
epicenter_depth = data['depth']
magnitude = data['magnitude']
result = {"result": 0, "detail": f"震源地 {epicenter} 予想震度 {intensity}\nマグニチュード {magnitude} 震源の深さ {epicenter_depth}\n緊急地震速報 {report_number}\n時刻 | {event_time}"}
result = {"result": 1, "detail": "not_1st_or_final_report"}
elif data['type'] == 'pga_alert_cancel':
print(data)
result = {"result": 0, "detail": f"誤報を検出。一つ前のノートは誤報です。"}
@ -83,6 +87,9 @@ def receive_earthquake_data():
elif info["detail"] == "intensity_report_detected":
print(f"{str(current_time)} intensity_report のため、無視されました。")
return jsonify({"status": "passed", "message": "intensity_report"}), 500
elif info["detail"] == "not_1st_or_final_report":
print(f"{str(current_time)} 第1報 または 最終報 以外 のため、無視されました。")
return jsonify({"status": "passed", "message": "not_1st_or_final_report"}), 500
else:
print(f"{str(current_time)} 不明なデータ のため、無視されました。\njsonの内容")
print(earthquake_data)