improve weather regex
This commit is contained in:
parent
77027c1478
commit
4934996654
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user