From 8fe69d3457ed161451df23378dae1268afc0967d Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Sun, 11 Feb 2024 21:46:02 +0700 Subject: [PATCH] Custom text error incase api key is expired or got rate limiter Signed-off-by: Yasir Aris M --- misskaty/plugins/chatbot_ai.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index 1bd41fe8..2afd01c7 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -108,7 +108,9 @@ async def openai_chatbot(_, ctx: Message, strings): except APIConnectionError as e: await msg.edit_msg(f"The server could not be reached because {e.__cause__}") except RateLimitError as e: - await msg.edit_msg("A 429 status code was received; we should back off a bit.") + if "billing details" in e: + return await msg.edit_msg("This openai key from this bot has expired, please give openai key donation for bot owner.") + await msg.edit_msg("You're got rate limit, please try again later.") except APIStatusError as e: await msg.edit_msg(f"Another {e.status_code} status code was received with response {e.response}") except Exception as e: