From 53a66f52022848f95a98be0188bb1d63829a5484 Mon Sep 17 00:00:00 2001 From: 3nd3r Date: Sun, 28 Dec 2025 17:52:02 -0600 Subject: [PATCH] Update duckhelp to send PM with detailed commands --- MULTI_CHANNEL_PLAN.md | 45 ++++++++++++++++++++++++++++++ src/duckhuntbot.py | 64 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 MULTI_CHANNEL_PLAN.md diff --git a/MULTI_CHANNEL_PLAN.md b/MULTI_CHANNEL_PLAN.md new file mode 100644 index 0000000..6b5579c --- /dev/null +++ b/MULTI_CHANNEL_PLAN.md @@ -0,0 +1,45 @@ +# Multi-Channel Support Implementation + +## What Multi-Channel Means +- Players have **separate stats in each channel** +- Nick "Bob" in #channel1 has different XP than "Bob" in #channel2 +- Database structure: `channels -> #channel1 -> players -> bob` + +## Changes Needed + +### 1. Database Structure (db.py) +```python +{ + "channels": { + "#channel1": { + "players": { + "bob": { "xp": 100, ... }, + "alice": { "xp": 50, ... } + } + }, + "#channel2": { + "players": { + "bob": { "xp": 20, ... } # Different stats! + } + } + } +} +``` + +### 2. Database Methods +- `get_player(nick, channel)` - Get player in specific channel +- `get_players_for_channel(channel)` - Get all players in a channel +- `iter_all_players()` - Iterate over all channels and players + +### 3. Command Changes (duckhuntbot.py) +- Pass `channel` parameter when calling `db.get_player(nick, channel)` +- Channel normalization (case-insensitive) + +### 4. Stats Commands +- `!duckstats` shows stats for current channel +- `!globalducks` shows combined stats across all channels + +## Benefits +- Fair: Can't bring channel1 XP into channel2 +- Better: Each channel has own leaderboard +- Clean: Stats don't mix between channels diff --git a/src/duckhuntbot.py b/src/duckhuntbot.py index 5f7ff56..2262a13 100644 --- a/src/duckhuntbot.py +++ b/src/duckhuntbot.py @@ -1027,19 +1027,69 @@ class DuckHuntBot: self.send_message(channel, f"{nick} > Error retrieving leaderboard data.") async def handle_duckhelp(self, nick, channel, _player): - """Handle !duckhelp command""" + """Handle !duckhelp command - sends detailed help via PM""" + + # Send notification to channel + if channel.startswith('#'): + self.send_message(channel, f"{nick} > Please check your PM for the duckhunt command list.") + + # Build detailed help message help_lines = [ - self.messages.get('help_header'), - self.messages.get('help_user_commands'), - self.messages.get('help_help_command') + "=== DuckHunt Commands ===", + "", + "BASIC COMMANDS:", + " !bang - Shoot at a duck", + " !bef or !befriend - Try to befriend a duck", + " !reload - Reload your gun", + "", + "INFO COMMANDS:", + " !duckstats [player] - View duck hunting statistics", + " !topduck - View leaderboard (top hunters)", + "", + "SHOP COMMANDS:", + " !shop - View available items", + " !shop buy - Purchase an item from the shop", + "", + "EXAMPLES:", + " When a duck appears, type: !bang", + " To reload: !reload", + " Check your stats: !duckstats", + " Buy item #2 from shop: !shop buy 2", ] # Add admin commands if user is admin - if self.is_admin(f"{nick}!user@host"): - help_lines.append(self.messages.get('help_admin_commands')) + # We need to construct a proper user string for is_admin check + user_string = f"{nick}!user@host" # Simplified check + if hasattr(self, 'is_admin') and self.is_admin(user_string): + help_lines.extend([ + "", + "=== ADMIN COMMANDS ===", + " !rearm - Give player a gun", + " !disarm - Confiscate player's gun", + " !ignore - Ignore player's commands", + " !unignore - Unignore player", + " !ducklaunch [duck_type] - Force spawn a duck (normal, golden, fast)", + " !join #channel - Make bot join a channel", + " !part #channel - Make bot leave a channel", + "", + "Admin commands work in PM or in-channel." + ]) + help_lines.extend([ + "", + "=== TIPS ===", + "- Ducks spawn randomly. Watch for them!", + "- Golden ducks have multiple HP and give more XP", + "- Fast ducks fly away quickly", + "- Buy items from !shop to improve your hunting", + "", + "Good luck hunting! 🦆" + ]) + + # Send all help lines as PM for line in help_lines: - self.send_message(channel, line) + self.send_message(nick, line) + async def handle_use(self, nick, channel, player, args): """Handle !use command"""