Updates
Release rolling / release (push) Successful in 9m31s

This commit is contained in:
Raven Scott
2026-08-13 10:07:51 -04:00
parent 0b0f042416
commit c5380fd07b
13 changed files with 254 additions and 18 deletions
+49 -4
View File
@@ -252,10 +252,6 @@ async function run(ctx, argv) {
const loginMs = discordLoginTimeoutMs(ctx, argv)
const intents = [GatewayIntentBits.Guilds]
if (GatewayIntentBits.GuildMessages)
intents.push(GatewayIntentBits.GuildMessages)
if (GatewayIntentBits.DirectMessages)
intents.push(GatewayIntentBits.DirectMessages)
if (wantsMessageContent && GatewayIntentBits.MessageContent) {
intents.push(GatewayIntentBits.MessageContent)
}
@@ -353,6 +349,55 @@ async function run(ctx, argv) {
})
}
function discordRedactWs(s) {
return String(s || '').replace(/"token"\s*:\s*"[^"]*"/g, '"token":"***"')
}
function discordHookGateway(c) {
let tries = 0
const iv = setInterval(function () {
tries++
const mgr = c.ws && c.ws._ws
const shards = mgr && mgr.shards
let hooked = false
if (shards && typeof shards.values === 'function') {
const it = shards.values()
let n = it.next()
while (!n.done) {
const conn = n.value && n.value.connection
if (conn && !conn.__bareOsHooked) {
conn.__bareOsHooked = true
hooked = true
if (typeof conn.send === 'function') {
const origSend = conn.send.bind(conn)
conn.send = function (data) {
ctx.console.log(
'discord-bot: ws send ' +
discordRedactWs(data).slice(0, 180)
)
return origSend(data)
}
}
const prev = conn.onmessage
conn.onmessage = function (ev) {
const d = ev && ev.data
const text =
typeof d === 'string'
? d
: d && typeof d.toString === 'function'
? d.toString()
: String(d)
ctx.console.log('discord-bot: ws recv ' + text.slice(0, 180))
if (typeof prev === 'function') return prev.apply(this, arguments)
}
}
n = it.next()
}
}
if (hooked || tries > 80) clearInterval(iv)
}, 25)
}
discordHookGateway(client)
let loggingIn = true
let loginTimer = null
let loginTick = null