feat(discordsh): wire bevy_chat IRC client with graceful degradation#9892
Merged
feat(discordsh): wire bevy_chat IRC client with graceful degradation#9892
Conversation
…radation (#9850) Connects the Discord bot to the existing ergo IRC server via bevy_chat::ChatClient for cross-platform world events. Gracefully degrades if IRC is unavailable. Startup: - If IRC_HOST is set, attempts ChatClient::from_env() connection - On success: stored as Some(ChatClient) in AppState - On failure: logs warning, stores None — all IRC features silently disabled - If IRC_HOST not set: logs info, skips entirely World event emission (fire-and-forget via tokio::spawn): - Boss killed → #world-events [EVENT:KILL] player defeated boss - Dungeon victory → #world-events [EVENT:VICTORY] player cleared depth N - Player death → #world-events [EVENT:DEATH] player was slain - All events include structured JSON payload for isometric game consumption New module: discord/game/irc_events.rs - emit_boss_killed(), emit_rare_drop(), emit_player_death() - emit_victory(), emit_quest_complete() - Each checks Option<ChatClient>, no-ops on None AppState changes: - new() is now async (for IRC connect) - irc: Option<ChatClient> field added All 701 tests pass (IRC is None in test environment).
Open
26 tasks
Contributor
Dependency ReviewThe following issues were found:
Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. License Issuespackages/rust/bevy/bevy_chat/Cargo.toml
OpenSSF Scorecard
Scanned Files
|
…#9850) WASM clients (isometric game in browser) can't do raw TCP to ergo. They connect via WebSocket to chat.kbve.com (irc-gateway → ergo:8080). Transport is selected at compile time via cfg(target_arch): - Native (not wasm32): tokio TcpStream → ergo:6667 (unchanged) - WASM (wasm32): web_sys::WebSocket → wss://chat.kbve.com Public API is identical on both platforms: - ChatClient::new(config) / connect() / send() / disconnect() - Native: subscribe() returns broadcast::Receiver (async) - WASM: drain_incoming() returns Vec (polled each frame by Bevy plugin) WASM client features: - Automatic IRC registration on WebSocket open (NICK/USER/JOIN) - PING/PONG keepalive handling - PRIVMSG parsing with structured ChatMessage decode - Closures leaked for WebSocket lifetime (standard WASM pattern) - Non-Send (Rc<RefCell>) — must run on main thread File structure: - client_native.rs — tokio TCP (was client.rs) - client_wasm.rs — web_sys::WebSocket (new) - lib.rs — conditional export based on target_arch Cargo.toml changes: - tokio moved to cfg(not(wasm32)) target dependency - Added wasm-bindgen, web-sys, js-sys as cfg(wasm32) dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Connects the Discord bot to ergo IRC via
bevy_chat::ChatClientfor cross-platform world events (#9850). Gracefully handles unavailable IRC — no crash, no blocked startup.Startup behavior
IRC_HOSTset, ergo reachableIRC_HOSTset, ergo unreachableirc: None, events silently disabledIRC_HOSTnot setWorld events emitted to
#world-events[EVENT:KILL] Player@discord: Player defeated Glass Golem[EVENT:VICTORY] Player@discord: Player cleared depth 7[EVENT:DEATH] Player@discord: Player was slainEvents include JSON payload for structured consumption by isometric game.
New module
discord/game/irc_events.rs— 5 emit functions (boss_killed, rare_drop, player_death, victory, quest_complete), all fire-and-forget viatokio::spawn.Changes
AppState::new()is nowasync(for IRC connect)AppState.irc: Option<ChatClient>fieldAll 701 tests pass. IRC is
Nonein test environment.Test plan
IRC_HOSTunset — verify clean startup with "IRC not configured" logIRC_HOST=ergo-irc-service.irc.svc.cluster.local— verify connection#world-eventsreceives event