from sopel import module
import pywapi

#this will give you a dictionary of all cities in the world with this city's name Be specific (city, country)!
lookup = pywapi.get_location_ids('montreal')

#workaround to access last item of dictionary
for i in lookup:
    location_id = i

#location_id now contains the city's code
weather_com_result = pywapi.get_weather_from_weather_com(location_id)

temp = weather_com_result['current_conditions']['temperature'].lower()

temp = int(temp)

@module.rule('how are')
def hi(bot, trigger):
    if temp < 0:
        bot.say('I am so cooooolllddddd, it is ' + str(temp) + ' degrees')
    elif temp < 5:
        bot.say('I am quite miserablaaaahhh it is ' + str(temp) + ' degrees')
    elif temp < 10:
        bot.say('I am quite miserablaaaahhh it is ' + str(temp) + ' degrees')    elif temp < 20:
        bot.say('I am gooooddd it is ' + str(temp) + ' degrees')
    elif temp < 30:
        bot.say('aufh it is ' + str(temp) + ' degrees')
    else:
        bot.say('hoooottt it is ' + str(temp) + ' degrees')