From 26d7ee531e81d32ac249f5a8e94b09d7661be42b Mon Sep 17 00:00:00 2001 From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:57:34 -0500 Subject: [PATCH] Create randomquote.py --- packages/randomquote.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/randomquote.py diff --git a/packages/randomquote.py b/packages/randomquote.py new file mode 100644 index 0000000..a2a7315 --- /dev/null +++ b/packages/randomquote.py @@ -0,0 +1,25 @@ +# ["randomquote", "packages.randomquote", ["randomquote"]] +# Made By OusmBlueNinja +import requests + +def randomquote(command: list): + if len(command) != 0: + print("Usage: randomquote") + return + + try: + # Fetch a random quote from the Zen Quotes API + response = requests.get("https://zenquotes.io/api/random") + if response.status_code == 200: + quote_data = response.json() + if quote_data and "q" in quote_data[0]: + quote = quote_data[0]["q"] + print("Random Zen Quote:") + print(quote) + else: + print("Failed to retrieve a quote.") + else: + print("Failed to retrieve a quote.") + except Exception as e: + print(f"An error occurred: {str(e)}") +