Browse Source

se añade nueva información del clima

Pablo Barrera Yaksic 2 months ago
parent
commit
98d94481c3
4 changed files with 20 additions and 2 deletions
  1. 2 1
      .gitignore
  2. BIN
      bot-clima.zip
  3. 8 1
      index.js
  4. 10 0
      serverless.yml

+ 2 - 1
.gitignore

@@ -1 +1,2 @@
-node_modules
+node_modules
+.env

BIN
bot-clima.zip


+ 8 - 1
index.js

@@ -38,7 +38,14 @@ exports.handler = async (event, context) => {
 
   const bot = new BotClima(mastodon, weather);
   const data = await bot.getCurrentWeather();
-  const message = `La temperatura actual en ${process.env.OPENWEATHERAPI_CITY} es: ${data.weather.temp.cur}\u00B0C`;
+  console.log('Data', data );
+  const message = `
+  El reporte del clima en ${process.env.OPENWEATHERAPI_CITY} es:\n
+  La temperatura actual es de ${data.weather.temp.cur}\u00B0C
+  La humedad es del ${data.weather.humidity}%
+  Vientos de ${data.weather.wind.speed} m/s
+  Condición ${data.weather.description.charAt(0).toUpperCase() + data.weather.description.slice(1)}\n ${data.weather.icon.url}
+  `;
   await bot.post(message);
   const response = { statusCode: 200, body: JSON.stringify(message) };
   return response;

+ 10 - 0
serverless.yml

@@ -0,0 +1,10 @@
+service: mastodon-bot-clima
+frameworkVersion: '3'
+
+provider:
+  name: aws
+  runtime: nodejs20.x
+
+functions:
+  weather:
+    handler: index.handler