Add Chrome-based Discord client for user-token hybrid mode#2
Open
fox3000foxy wants to merge 2 commits into
Open
Add Chrome-based Discord client for user-token hybrid mode#2fox3000foxy wants to merge 2 commits into
fox3000foxy wants to merge 2 commits into
Conversation
- New DiscordClient class (Puppeteer + CDP) for real browser fingerprint - gateway-bus.ts: unified TypedBus for Gateway events - Hybrid mode: Eris (bot) receives, Chrome (user) sends/ACKs - Nonce added to DiscordClient.sendMessage (decimal format) - BOT_RPC disabled (dynamic status rotation commented out) - README: Hybrid Mode section, diagram 25 - puppeteer dependency
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.
TL;DR
Self-bot user tokens get flagged by Discord because Node.js HTTP clients lack real browser fingerprints. This PR adds a
DiscordClientbacked by Puppeteer+CDP that provides real TLS, cookies, andX-Super-Propertiesvia Chrome's native fetch stack, plus a unifiedgatewayBusfor Gateway events.Files to review (5 new, 3306 added):
src/discord-client.ts(start here)__puppetFetchrelay, send/edit/acksrc/core/gateway-bus.tsMESSAGE_CREATE,MESSAGE_REACTION_ADD)src/bot.tsDiscordClientwhenDISCORD_USER_TOKENpresent, channelnavigateTo(), RPC rotation disabledsrc/config.tsDISCORD_USER_TOKENexportstate-machines/25-hybrid-mode.mmdHow
DiscordClient.init(userToken)launches a real Chrome (headless=false), injects the user token intolocalStorage, and lands on@me. A CDP session hooks all Gateway WebSocket frames — eachMESSAGE_CREATEwithmention_tokentriggers an auto-ACK via Chrome's nativefetch.gatewayBus(TypedBus<GatewayEvents>) unifies Gateway events from both Chrome CDP and Eris.feedGatewayFrame()parses raw WebSocket JSON and emits typed events.triggerLunaReply()callsdiscordClient.navigateTo()—history.pushState+PopStateEvent— putting the Chrome session in the right channel without a page reload.__puppetFetch(window.fetch.bind(window)), called viapage.evaluate, routes all API calls through Chrome's real TLS/cookie/fingerprint stack.String(Date.now()) + String(random)) matching the official web client.Reviewer notes
discord_user_tokenis set. Without it, Eris runs exactly as before.setIntervalwas not human-like — commented out. Easy to re-enable.toString(16)— Discord's API expects a pure decimal numeric string.Tests
Existing tests pass (189/195; 6 failures are pre-existing
llama-server 404— no server in CI).Links