From 3e5fc4cebaab39bf21727bf8b4ddba48c8fa6197 Mon Sep 17 00:00:00 2001 From: yasirarism <55983182+yasirarism@users.noreply.github.com> Date: Mon, 20 Mar 2023 19:06:42 +0700 Subject: [PATCH] Update chatbot_ai.py --- misskaty/plugins/chatbot_ai.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index 4f5bbaf2..5370749e 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -31,14 +31,12 @@ async def chatbot(c, m): msg = await kirimPesan(m, "Wait a moment looking for your answer..") try: response = (await http.post("https://api.openai.com/v1/chat/completions", headers=headers, json=json_data)).json() - if err := response["error"]: + if err := response.get("error"): return await editPesan(msg, err["message"]) answer = response["choices"][0]["message"]["content"] await editPesan(msg, answer) except MessageTooLong: answerlink = await post_to_telegraph(False, "MissKaty ChatBot ", answer) await editPesan(msg, f"Question for your answer has exceeded TG text limit, check this link to view.\n\n{answerlink}", disable_web_page_preview=True) - except (MessageNotModified, MessageIdInvalid): - pass except Exception as err: await editPesan(msg, f"Oppss. ERROR: {str(err)}")