From 5c07d186824558b5ccf95ad8f99ce8a948462f4f Mon Sep 17 00:00:00 2001 From: swee <meow@swee.codes> Date: Sat, 15 Mar 2025 15:49:31 -0700 Subject: [PATCH] Add cc/weather --- cc/weather | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cc/weather diff --git a/cc/weather b/cc/weather new file mode 100644 index 0000000..12d6fd9 --- /dev/null +++ b/cc/weather @@ -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("") \ No newline at end of file