From 84530b0aeb824801ae20eee1a5a2c2d58ee25d80 Mon Sep 17 00:00:00 2001 From: Vikram Vishwakarma Date: Tue, 20 Aug 2024 20:32:50 +0530 Subject: [PATCH] updating iquote with a custom file hosted on gist --- main/core/methods/functions/syncpart.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/main/core/methods/functions/syncpart.py b/main/core/methods/functions/syncpart.py index 8d1a9c86..28117869 100644 --- a/main/core/methods/functions/syncpart.py +++ b/main/core/methods/functions/syncpart.py @@ -4,6 +4,7 @@ import os import time import math +import random import datetime import html import inspect @@ -267,10 +268,21 @@ def animeQuote( app.quote() """ - results = requests.get("https://animechan.vercel.app/api/random", timeout=5).json() - msg = f"❝ {results.get('quote')} ❞" - msg += f" [ {results.get('anime')} ]\n\n" - msg += f"- {results.get('character')}\n\n" + anime_quote_url = "https://gist.github.com/vikramisdev/7a53a8eaac465ad065d2fd90faef55cc" + msg = "" + + r = list(requests.get(anime_quote_url, timeout=5).json()) + random_index = random.randint(0, len(r) - 1) + results = r[random_index] + + + if results is not None: + msg += f"❝ {results.get('quote')} ❞" + msg += f" [ {results.get('anime')} ]\n\n" + msg += f"- {results.get('character')}\n\n" + else: + msg = "No Quotes Found" + return msg