import requests
from colorama import Fore
from plugin import plugin, require
from inspect import cleandoc


@require(network=True)
@plugin("corona")
class CoronaInfo:
    """
    corona 					: Display total cases of the world
    corona <Country name | country code>	: Display cases for the specific country"
    corona help					: Print this help


    ** Data provided by: https://api.covid19api.com/
    """
    def __call__(self, jarvis, s):
        if 'help' in s:
            jarvis.say(cleandoc(self.__doc__), Fore.GREEN)
        else:
            corona_info = self.get_corona_info(s)
            if corona_info:
                location = corona_info["Country"]
                jarvis.say(f"\t+++++++++++++++++++++++++++++++++++++++", Fore.CYAN)
                jarvis.say(f"\tCorona status: \"{location}\"", Fore.CYAN)
                jarvis.say(f"\t+++++++++++++++++++++++++++++++++++++++", Fore.CYAN)

                new_confirmed = corona_info["NewConfirmed"]
                jarvis.say(f"\tNew confirmed cases	: {new_confirmed}", Fore.YELLOW)

                total_confirmed = corona_info["TotalConfirmed"]
                jarvis.say(f"\tTotal confirmed cases	: {total_confirmed}", Fore.YELLOW)

                new_deaths = corona_info["NewDeaths"]
                jarvis.say(f"\tNew deaths		: {new_deaths}", Fore.RED)

                total_deaths = corona_info["TotalDeaths"]
                jarvis.say(f"\tTotal deaths		: {total_deaths}", Fore.RED)

                new_recovered = corona_info["NewRecovered"]
                jarvis.say(f"\tNew recovered		: {new_recovered}", Fore.GREEN)

                total_recovered = corona_info["TotalRecovered"]
                jarvis.say(f"\tTotal recovered		: {total_recovered}", Fore.GREEN)
            else:
                jarvis.say(f"Cant find the country \"{s}\"", Fore.RED)

    def get_corona_info(self, country_name):
        url = "https://api.covid19api.com/summary"
        response = requests.get(url)
        print(response)
        result = response.json()
        if country_name:
            for country in result["Countries"]:
                if (
                    country_name == country["Country"].lower()
                    or country_name == country["CountryCode"].lower()
                    or country_name == country["Slug"].lower()
                ):
                    return country
            return None
        global_info = result["Global"]
        global_info["CountryCode"] = "Worldwide"
        return result["Global"]

@@ -611,16 +611,250 @@
 ona_info
+ == %22URLError%22:%0A                jarvis.say(f%22Result was not available at the moment. Try again!!%22, Fore.RED)%0A            elif corona_info is None:%0A                jarvis.say(f%22Cant find the country %5C%22%7Bs%7D%5C%22%22, Fore.RED)%0A            else
 :%0A      
@@ -1984,97 +1984,8 @@
 EEN)
-%0A            else:%0A                jarvis.say(f%22Cant find the country %5C%22%7Bs%7D%5C%22%22, Fore.RED)
 %0A%0A  
@@ -2127,23 +2127,196 @@
     
-print(response)
+# Intermittently URL responds with a message - You have reached maximum request limit.%0A        if(response.text == %22You have reached maximum request limit.%22):%0A            return %22URLError%22
 %0A   
@@ -2780,20 +2780,16 @@
 %22Country
-Code
 %22%5D = %22Wo

Fix logical error and handle URL unresponsive error