From db49246a4c08c3c3a0c46944e35acb44a55b55fe Mon Sep 17 00:00:00 2001 From: Advocaite Date: Fri, 9 Oct 2026 15:46:29 +0800 Subject: [PATCH] Discord bot: always relay the in-game Discord channel Configs made before 2026-10-07 have no Discord entry in chat.channels, so /6 chat never reached Discord. New option chat.game_channel (default Discord) is relayed regardless of that list. --- contrib/discord_bot/README.md | 1 + contrib/discord_bot/forever_bot.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/discord_bot/README.md b/contrib/discord_bot/README.md index 64a35b54d9..583594f79d 100644 --- a/contrib/discord_bot/README.md +++ b/contrib/discord_bot/README.md @@ -285,6 +285,7 @@ A list of `{ "name": "...", "host": "...", "port": N }`. The example has Auth se | Key | Default | Meaning | |---|---|---| | `channels` | General, Trade, LookingForGroup, LocalDefense | Which in-game channels to relay, and the label each gets in Discord: `{"General": "General", "LookingForGroup": "LFG"}` shows `[LFG]`. An empty `{}` relays every system channel. | +| `game_channel` | `Discord` | The in-game Discord channel (same name as `Discord.Channel.Name` in the worldserver configs). Always relayed, even when `channels` leaves it out. In-game to Discord needs the worldserver from 2026-10-09 or newer (it writes this channel to `Chat.log`). | | `format` | `{faction}[{channel}] <{player}> {message}` | Line format. Placeholders: `{faction}` (`[A] ` or `[H] `), `{channel}`, `{player}`, `{message}`, `{zone}` (e.g. Durotar for General; empty for LFG), `{realm}`. Example: `**[{channel}]** <{player}> {message}`. | | `from_discord` | `false` | Discord to game: messages in a realm's `chat_channel_id` go to its in-game Discord channel (`.discord say` over RA). Needs the Message Content intent (step 2) and `Discord.Channel.Enable = 1` (step 5). Text only: attachments, embeds, stickers and reactions are dropped, mentions become names, line breaks become spaces, `|` becomes `/`, the server cuts it to 255 characters. Messages of bots (this one included) are ignored, so nothing echoes. | | `poll_seconds` | `1` | How often the logs are read. | diff --git a/contrib/discord_bot/forever_bot.py b/contrib/discord_bot/forever_bot.py index bf63fea2a4..5db83e718e 100644 --- a/contrib/discord_bot/forever_bot.py +++ b/contrib/discord_bot/forever_bot.py @@ -243,7 +243,10 @@ def format_chat_line(line, realm): base, _, zone = channel.partition(' - ') chat = CFG.get('chat', {}) names = {k.lower(): v for k, v in (chat.get('channels') or {}).items()} - if names and base.lower() not in names: + # the in-game Discord channel (worldserver Discord.Channel.Name) is always relayed: configs made before 2026-10-07 have no + # "Discord" entry in chat.channels, and their /6 chat never reached Discord + game_channel = str(chat.get('game_channel') or 'Discord').lower() + if names and base.lower() not in names and base.lower() != game_channel: return None message = clean_wow_text(message) if not message: