From 49349966549bdd2fda1e0b856fbc5970bf3d7a74 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sat, 15 Sep 2018 13:19:43 +0200 Subject: [PATCH] improve weather regex --- scripts/meteo.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/meteo.coffee b/scripts/meteo.coffee index 34e52b3..a2a2637 100644 --- a/scripts/meteo.coffee +++ b/scripts/meteo.coffee @@ -16,7 +16,7 @@ moment = require 'moment' -regex = /(?:(?:d(?:a|i)mmi il )?meteo(?: per (.+))?|che tempo (?:fa|c'è)(?: (?:a|in) (.+))?)\??$/i +regex = /(?:(?:(?:mi (?:dici|dai)|dammi) (?:il (?:tempo|meteo)|(?:le previsioni)))(?: ?(?:(?:per ?(?:(?:l')|il |lo |la |i |gli |le )?)|di |a ))?|(?:che tempo (?:fa|(?:c'?(?:è|e|e')))(?: ?(?:in|a) )?))([^?!]+)?.*$/i url1 = 'http://ip-api.com/json/' url2 = 'http://api.openweathermap.org/data/2.5/weather?lang=it&units=metric' @@ -64,7 +64,7 @@ module.exports = (robot) -> tramonto alle #{dusk}" robot.respond regex, (res) -> - city = res.match[1] || res.match[2] + city = res.match[1] if city? get_weather city, send_weather res else