Skip to content

Instantly share code, notes, and snippets.

@sharl
Created April 22, 2021 06:31
Show Gist options
  • Save sharl/aafc46627a5cbd78ceae528eaefd857a to your computer and use it in GitHub Desktop.
Save sharl/aafc46627a5cbd78ceae528eaefd857a to your computer and use it in GitHub Desktop.
--- a/ircbot.js
+++ b/ircbot.js
@@ -145,7 +145,7 @@ async function amedasget(posname)
const day = ('0'+cur.getDate()).slice(-2);
const hour = ('0'+cur.getHours()).slice(-2);
const targetTime = `${year}${month}${day}_${hour}`;
- // const targetIndex = `${year}${month}${day}${hour}0000`;
+ const targetBase = `${year}${month}${day}${hour}0000`;
const responses = [];
for ( key in point ) {
const pointid = point[key];
@@ -157,7 +157,11 @@ async function amedasget(posname)
// YYYYMMDDHHMMSS
const mm = targetIndex.match(/\d{4}\d{2}\d{2}(\d{2})(\d{2})00/);
const lasttime = `${mm[1]}:${mm[2]}`;
+ const base = response.data[targetBase];
const data = response.data[targetIndex];
+ for (k in data) {
+ base[k] = data[k];
+ }
const {
temp, // 温度
precipitation1h, // 1時間降水量
@@ -172,7 +176,7 @@ async function amedasget(posname)
snow, // 積雪(cm)
snow1h, // 1時間積雪
sun1h, // 1時間日照時間
- } = data;
+ } = base;
var res = `${amedastable[pointid].kjName}(${amedastable[pointid].knName}) ${lasttime} `;
if ( temp != undefined ) res += `気温は${temp[0]}度 `;
if ( precipitation1h != undefined ) res += `降水量:${precipitation1h[0]}mm/h `;
@@ -182,7 +186,7 @@ async function amedasget(posname)
if ( humidity != undefined ) res += `湿度${humidity[0]}% `;
if ( pressure != undefined ) res += `気圧${pressure[0]}hPa `;
if ( snow != undefined) res += `積雪${snow[0]}cm `;
- if ( snow1h != undefined ) res += `降雪量:${snow1h[0]} `;
+ if ( snow1h != undefined ) res += `降雪量:${snow1h[0]}cm `;
if ( minTemp != undefined ) res += `最低気温 ${minTemp[0]} (${(minTempTime.hour+9)%24}:${minTempTime.minute}) `;
if ( maxTemp != undefined ) res += `最高気温 ${maxTemp[0]}(${(maxTempTime.hour+9)%24}:${maxTempTime.minute}) `;
// console.log(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment