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
This commit is contained in:
parent
5daf62ba22
commit
11b928c242
2 changed files with 85 additions and 0 deletions
48
test_irc.py
Normal file
48
test_irc.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue