# coding:utf-8

import logging
import requests
import json
import util

logger = logging.getLogger()
logger.setLevel(util.logger_level())


def weather_info(city_id):
    weather_api_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
    response_string = ''

    try:
        params = {'city':city_id}
        response = requests.get(weather_api_url,params=params)
        response_dict = json.loads(response.text)
        title = response_dict["title"]
        description = response_dict["description"]["text"]
        response_string += title + "です。:nerd_face:\n\n"
        forecasts_array = response_dict["forecasts"]
        forcast_array = []
        for forcast in forecasts_array:
            telop = forcast["telop"]
            telop_icon = ''
            if telop.find('雪') > -1:
                telop_icon = ':showman:'
            elif telop.find('雷') > -1:
                telop_icon = ':thunder_cloud_and_rain:'
            elif telop.find('晴') > -1:
                if telop.find('曇') > -1:
                    telop_icon = ':partly_sunny:'
                elif telop.find('雨') > -1:
                    telop_icon = ':partly_sunny_rain:'
                else:
                    telop_icon = ':sunny:'
            elif telop.find('雨') > -1:
                telop_icon = ':umbrella:'
            elif telop.find('曇') > -1:
                telop_icon = ':cloud:'
            else:
                telop_icon = ':fire:'

            temperature = forcast["temperature"]
            min_temp = temperature["min"]
            max_temp = temperature["max"]
            temp_text = ''
            if min_temp is not None:
                if len(min_temp) > 0:
                    temp_text += '\n最低気温は' + min_temp["celsius"] + "度です。"
            if max_temp is not None:
                if len(max_temp) > 0:
                    temp_text += '\n最高気温は' + max_temp["celsius"] + "度です。"

            forcast_array.append(forcast["dateLabel"] + ' ' + telop + telop_icon + temp_text)
        if len(forcast_array) > 0:
            response_string += '\n\n'.join(forcast_array)
        response_string += '\n\n' + description

    except Exception as e:
        response_string = 'すいません。天気検索でエラーを起こしてしまいました。改善出来るように頑張ります。:cold_sweat:\n' + e.message + '\n' + str(e)
    return response_string

0a0cfa974a64704a95c00cd35f27429496f75c96
<mask token>

<mask token>
logger.setLevel(util.logger_level())


def weather_info(city_id):
    weather_api_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
    response_string = ''
    try:
        params = {'city': city_id}
        response = requests.get(weather_api_url, params=params)
        response_dict = json.loads(response.text)
        title = response_dict['title']
        description = response_dict['description']['text']
        response_string += title + 'です。:nerd_face:\n\n'
        forecasts_array = response_dict['forecasts']
        forcast_array = []
        for forcast in forecasts_array:
            telop = forcast['telop']
            telop_icon = ''
            if telop.find('雪') > -1:
                telop_icon = ':showman:'
            elif telop.find('雷') > -1:
                telop_icon = ':thunder_cloud_and_rain:'
            elif telop.find('晴') > -1:
                if telop.find('曇') > -1:
                    telop_icon = ':partly_sunny:'
                elif telop.find('雨') > -1:
                    telop_icon = ':partly_sunny_rain:'
                else:
                    telop_icon = ':sunny:'
            elif telop.find('雨') > -1:
                telop_icon = ':umbrella:'
            elif telop.find('曇') > -1:
                telop_icon = ':cloud:'
            else:
                telop_icon = ':fire:'
            temperature = forcast['temperature']
            min_temp = temperature['min']
            max_temp = temperature['max']
            temp_text = ''
            if min_temp is not None:
                if len(min_temp) > 0:
                    temp_text += '\n最低気温は' + min_temp['celsius'] + '度です。'
            if max_temp is not None:
                if len(max_temp) > 0:
                    temp_text += '\n最高気温は' + max_temp['celsius'] + '度です。'
            forcast_array.append(forcast['dateLabel'] + ' ' + telop +
                telop_icon + temp_text)
        if len(forcast_array) > 0:
            response_string += '\n\n'.join(forcast_array)
        response_string += '\n\n' + description
    except Exception as e:
        response_string = (
            'すいません。天気検索でエラーを起こしてしまいました。改善出来るように頑張ります。:cold_sweat:\n' + e.
            message + '\n' + str(e))
    return response_string

<mask token>
logger = logging.getLogger()
logger.setLevel(util.logger_level())


def weather_info(city_id):
    weather_api_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
    response_string = ''
    try:
        params = {'city': city_id}
        response = requests.get(weather_api_url, params=params)
        response_dict = json.loads(response.text)
        title = response_dict['title']
        description = response_dict['description']['text']
        response_string += title + 'です。:nerd_face:\n\n'
        forecasts_array = response_dict['forecasts']
        forcast_array = []
        for forcast in forecasts_array:
            telop = forcast['telop']
            telop_icon = ''
            if telop.find('雪') > -1:
                telop_icon = ':showman:'
            elif telop.find('雷') > -1:
                telop_icon = ':thunder_cloud_and_rain:'
            elif telop.find('晴') > -1:
                if telop.find('曇') > -1:
                    telop_icon = ':partly_sunny:'
                elif telop.find('雨') > -1:
                    telop_icon = ':partly_sunny_rain:'
                else:
                    telop_icon = ':sunny:'
            elif telop.find('雨') > -1:
                telop_icon = ':umbrella:'
            elif telop.find('曇') > -1:
                telop_icon = ':cloud:'
            else:
                telop_icon = ':fire:'
            temperature = forcast['temperature']
            min_temp = temperature['min']
            max_temp = temperature['max']
            temp_text = ''
            if min_temp is not None:
                if len(min_temp) > 0:
                    temp_text += '\n最低気温は' + min_temp['celsius'] + '度です。'
            if max_temp is not None:
                if len(max_temp) > 0:
                    temp_text += '\n最高気温は' + max_temp['celsius'] + '度です。'
            forcast_array.append(forcast['dateLabel'] + ' ' + telop +
                telop_icon + temp_text)
        if len(forcast_array) > 0:
            response_string += '\n\n'.join(forcast_array)
        response_string += '\n\n' + description
    except Exception as e:
        response_string = (
            'すいません。天気検索でエラーを起こしてしまいました。改善出来るように頑張ります。:cold_sweat:\n' + e.
            message + '\n' + str(e))
    return response_string

import logging
import requests
import json
import util
logger = logging.getLogger()
logger.setLevel(util.logger_level())


def weather_info(city_id):
    weather_api_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
    response_string = ''
    try:
        params = {'city': city_id}
        response = requests.get(weather_api_url, params=params)
        response_dict = json.loads(response.text)
        title = response_dict['title']
        description = response_dict['description']['text']
        response_string += title + 'です。:nerd_face:\n\n'
        forecasts_array = response_dict['forecasts']
        forcast_array = []
        for forcast in forecasts_array:
            telop = forcast['telop']
            telop_icon = ''
            if telop.find('雪') > -1:
                telop_icon = ':showman:'
            elif telop.find('雷') > -1:
                telop_icon = ':thunder_cloud_and_rain:'
            elif telop.find('晴') > -1:
                if telop.find('曇') > -1:
                    telop_icon = ':partly_sunny:'
                elif telop.find('雨') > -1:
                    telop_icon = ':partly_sunny_rain:'
                else:
                    telop_icon = ':sunny:'
            elif telop.find('雨') > -1:
                telop_icon = ':umbrella:'
            elif telop.find('曇') > -1:
                telop_icon = ':cloud:'
            else:
                telop_icon = ':fire:'
            temperature = forcast['temperature']
            min_temp = temperature['min']
            max_temp = temperature['max']
            temp_text = ''
            if min_temp is not None:
                if len(min_temp) > 0:
                    temp_text += '\n最低気温は' + min_temp['celsius'] + '度です。'
            if max_temp is not None:
                if len(max_temp) > 0:
                    temp_text += '\n最高気温は' + max_temp['celsius'] + '度です。'
            forcast_array.append(forcast['dateLabel'] + ' ' + telop +
                telop_icon + temp_text)
        if len(forcast_array) > 0:
            response_string += '\n\n'.join(forcast_array)
        response_string += '\n\n' + description
    except Exception as e:
        response_string = (
            'すいません。天気検索でエラーを起こしてしまいました。改善出来るように頑張ります。:cold_sweat:\n' + e.
            message + '\n' + str(e))
    return response_string

# coding:utf-8

import logging
import requests
import json
import util

logger = logging.getLogger()
logger.setLevel(util.logger_level())


def weather_info(city_id):
    weather_api_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
    response_string = ''

    try:
        params = {'city':city_id}
        response = requests.get(weather_api_url,params=params)
        response_dict = json.loads(response.text)
        title = response_dict["title"]
        description = response_dict["description"]["text"]
        response_string += title + "です。:nerd_face:\n\n"
        forecasts_array = response_dict["forecasts"]
        forcast_array = []
        for forcast in forecasts_array:
            telop = forcast["telop"]
            telop_icon = ''
            if telop.find('雪') > -1:
                telop_icon = ':showman:'
            elif telop.find('雷') > -1:
                telop_icon = ':thunder_cloud_and_rain:'
            elif telop.find('晴') > -1:
                if telop.find('曇') > -1:
                    telop_icon = ':partly_sunny:'
                elif telop.find('雨') > -1:
                    telop_icon = ':partly_sunny_rain:'
                else:
                    telop_icon = ':sunny:'
            elif telop.find('雨') > -1:
                telop_icon = ':umbrella:'
            elif telop.find('曇') > -1:
                telop_icon = ':cloud:'
            else:
                telop_icon = ':fire:'

            temperature = forcast["temperature"]
            min_temp = temperature["min"]
            max_temp = temperature["max"]
            temp_text = ''
            if min_temp is not None:
                if len(min_temp) > 0:
                    temp_text += '\n最低気温は' + min_temp["celsius"] + "度です。"
            if max_temp is not None:
                if len(max_temp) > 0:
                    temp_text += '\n最高気温は' + max_temp["celsius"] + "度です。"

            forcast_array.append(forcast["dateLabel"] + ' ' + telop + telop_icon + temp_text)
        if len(forcast_array) > 0:
            response_string += '\n\n'.join(forcast_array)
        response_string += '\n\n' + description

    except Exception as e:
        response_string = 'すいません。天気検索でエラーを起こしてしまいました。改善出来るように頑張ります。:cold_sweat:\n' + e.message + '\n' + str(e)
    return response_string
