From 11b928c2422bf93521820d93ef24b7df3ad4127d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Jan 2026 22:14:59 +0000 Subject: [PATCH 1/2] Add debug test scripts for troubleshooting Added two diagnostic tools: test_mention.py: - Tests MentionDetector with various message formats - Shows nickname generation (Kene from Kenearos) - Displays extracted content from mentions - Helps verify mention detection is working correctly test_irc.py: - Minimal IRC bot for testing message reception - Prints all received messages to console - Helps diagnose if IRC connection is receiving messages - Useful for debugging connection issues These tools help troubleshoot when bot doesn't respond: 1. Run test_mention.py to verify detection logic 2. Run test_irc.py to verify IRC message reception --- test_irc.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ test_mention.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 test_irc.py create mode 100644 test_mention.py diff --git a/test_irc.py b/test_irc.py new file mode 100644 index 0000000..6747885 --- /dev/null +++ b/test_irc.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +""" +Simple IRC test to see if messages are received +""" +import irc.bot +from dotenv import load_dotenv +import os + +load_dotenv() + +class TestBot(irc.bot.SingleServerIRCBot): + def __init__(self): + token = os.getenv("TWITCH_OAUTH_TOKEN") + nickname = os.getenv("TWITCH_BOT_NICKNAME") + channel = os.getenv("TWITCH_CHANNEL") + + print(f"Bot: {nickname}") + print(f"Channel: {channel}") + print(f"Token: {token[:15]}...") + + irc.bot.SingleServerIRCBot.__init__( + self, + [("irc.chat.twitch.tv", 6667, token)], + nickname, + nickname + ) + self.channel = channel + + def on_welcome(self, connection, event): + print(f"✅ Connected! Joining {self.channel}") + connection.cap("REQ", ":twitch.tv/membership") + connection.cap("REQ", ":twitch.tv/tags") + connection.cap("REQ", ":twitch.tv/commands") + connection.join(self.channel) + + def on_pubmsg(self, connection, event): + username = event.source.nick + message = event.arguments[0] + print(f"📨 MESSAGE | {username}: {message}") + +if __name__ == "__main__": + print("Starting IRC test bot...") + print("Write a message in your Twitch chat!") + print("Press Ctrl+C to stop") + print() + + bot = TestBot() + bot.start() diff --git a/test_mention.py b/test_mention.py new file mode 100644 index 0000000..66c005e --- /dev/null +++ b/test_mention.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +""" +Test script to check if mention detection works +""" +from utils import MentionDetector + +# Test with your bot name +detector = MentionDetector(bot_name="Kenearos") + +print("Testing Mention Detection for bot: Kenearos") +print("=" * 60) +print(f"Generated nicknames: {detector.nicknames}") +print() + +# Test messages +test_messages = [ + "@Kenearos Hi", + "Kenearos: wie gehts dir?", + "Kene was meinst du?", + "Hey Kenearos!", + "kenearos test", + "KENEAROS TEST", + "Hi wie gehts", + "Hallo", + "test message without bot", +] + +for msg in test_messages: + is_mentioned = detector.is_mentioned(msg) + is_greeting = detector.is_ambiguous_greeting(msg) + content = detector.extract_content(msg) if is_mentioned else "N/A" + + print(f"Message: '{msg}'") + print(f" Mentioned: {is_mentioned}") + print(f" Ambiguous greeting: {is_greeting}") + print(f" Extracted content: '{content}'") + print() From 82a1687bdeba8ea093705e564ad8e08100ac9f3a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Jan 2026 22:18:41 +0000 Subject: [PATCH 2/2] Expand nickname generation for better name variations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced _generate_nicknames() to support more name variations: Before (for 8-char name "Kenearos"): - Generated: Kene (4 chars only) After: - Generates at 4, 6, 8, 10, 12 character positions - For "kenearosmd": Kene, Kenear, Kenearos, kenearosmd - Special handling: removes 'md' suffix if present (kenearosmd → also adds kenearos) This allows users with longer usernames to be recognized: - Bot name "kenearosmd" generates: kene, kenear, kenearos - Bot responds to all variations and the full name Fixes issue where users couldn't use their full username if it was longer than the configured bot name. --- utils.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utils.py b/utils.py index 826a549..674a170 100644 --- a/utils.py +++ b/utils.py @@ -49,11 +49,16 @@ class MentionDetector: """Generate common nicknames from bot name""" nicknames = [] - # For kenearosmd, generate: Kene, Kenearos - if len(bot_name) >= 4: - nicknames.append(bot_name[:4]) # First 4 chars (Kene) - if len(bot_name) >= 8: - nicknames.append(bot_name[:8]) # First 8 chars (Kenearos) + # Generate nicknames at 4, 6, 8, 10 character positions + # For kenearosmd: Kene, Kenear, Kenearos, kenearosmd + for length in [4, 6, 8, 10, 12]: + if len(bot_name) >= length: + nicknames.append(bot_name[:length]) + + # Also add common variations + # If name ends with 'md', add version without it + if bot_name.lower().endswith('md') and len(bot_name) > 2: + nicknames.append(bot_name[:-2]) # kenearos from kenearosmd # Remove duplicates and the full name nicknames = [n for n in set(nicknames) if n != bot_name]