Add cc/weather

This commit is contained in:
Nova Cat 2025-03-15 15:49:31 -07:00
parent 48f9e5b1b8
commit 5c07d18682

30
cc/weather Normal file
View file

@ -0,0 +1,30 @@
import requests, os, sys
if "WAPIKEY" in os.environ:
print("MeowNexUS requires the WAPIKEY environment variable for this command to function.")
sys.exit(1)
query = requests.get("http://api.weatherapi.com/v1/current.json?key=" + os.environ["WAPIKEY"] + "&q=" + " ".join(sys.argv[3:])).json()
weathers = {
1: {
1000: "☀️",
1003: "⛅",
1006: "☁️",
1009: "☁️",
1030: "🌫️",
1063: "🌦️",
**dict.fromkeys([1063, 1150, 1153, 1180, 1183, 1186, 1189, 1192, 1195, 1198, 1201, 1204, 1207, 1240, 1243, 1246, 1249, 1252], "🌧️"),
**dict.fromkeys([1063, 1150, 1153], "🌨️")
},
0: {
1000: "🌙",
1003: "☁️",
1006: "☁️",
1009: "☁️",
1030: "🌫️",
**dict.fromkeys([1063, 1150, 1153, 1180, 1183, 1186, 1189, 1192, 1195, 1198, 1201, 1204, 1207, 1240, 1243, 1246, 1249, 1252], "🌧️"),
**dict.fromkeys([1063, 1150, 1153], "🌨️")
}
}
if "error" in query:
print("API ERROR: " + query["error"]["message"])
else:
print("")