From faa4a52e54abb8a0a511bb78ae618b9695647eae Mon Sep 17 00:00:00 2001 From: Rafli <93827765+raf-li@users.noreply.github.com> Date: Mon, 5 Oct 2026 22:01:47 +0700 Subject: [PATCH] Fix @ai answers failing with "name 'chan_name' is not defined" Splitting the asker line into PM and channel variants dropped the line that sets chan_name, so every @ai question (channel and PM) failed. Co-Authored-By: Claude Opus 5.5 --- ai_chat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ai_chat.py b/ai_chat.py index 99ad72c..1595b51 100644 --- a/ai_chat.py +++ b/ai_chat.py @@ -764,6 +764,7 @@ def answer(self, question: str, history: List[Tuple[str, str]], context: Any = N if isinstance(context, dict): extra = [] req_nick = context.get("nickname") or "Pengguna" + chan_name = context.get("channel_name") or f"channel {context.get('channel')}" is_pm = bool(context.get("is_pm")) if is_pm: extra.append(f"Penanya: {req_nick} (mengirim pertanyaan via Private Message / PM, sedang berada di channel: {chan_name}).")