-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot_response.py
61 lines (46 loc) · 1.5 KB
/
bot_response.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from datetime import datetime
def welcome_message(name):
welcome_msg = "Hola {} enviame el nombre de un municipio de Cuba para conocer su estado meteorológico"
return welcome_msg.format(name)
def get_gemoji(description):
emoji_dict = {
'claro': '☀️',
'despejado': '☀️',
'moderada': '🌦',
'ligera': '🌦',
'nublado': '🌥',
'intensa': '🌨',
'eléctricas': '🌩',
'tormentas': '🌩'
}
gemoji = '☁️'
for k in emoji_dict.keys():
if k in description:
gemoji = emoji_dict[k]
return gemoji
def weather_message(weather):
res_msg ="🌐 {}\n📅 {}\n{}\n🌡 {}°C\n💧 {}%\n⏱ {} hpa\n🌬 {} Km/h {}\n"
gemoji = get_gemoji(weather.descriptionWeather)
return res_msg.format(
weather.cityName,
str(weather.dt.date),
gemoji + ' ' + weather.descriptionWeather,
weather.temp,
weather.humidity,
weather.pressure,
weather.windVelocity,
weather.windDirectionDescription,
)
def forecast_message(weather):
res_msg ="🌐 {}\n"
day_msg = "\n📅 {}\n{}\n🌡min. {}°C\n🌡max. {}°C\n"
result = res_msg.format(weather.cityName)
for i in range(1, len(weather.days)):
w = weather.days[i]
result += day_msg.format(
datetime.strftime(w.day, "%d-%m-%Y"),
get_gemoji(w.description) + ' ' + w.description,
w.tmin,
w.tmax,
)
return result