mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-12 06:06:21 +00:00
Compare commits
10 Commits
@revanced/
...
@revanced/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
887ee85e41 | ||
|
|
c9b788dc51 | ||
|
|
ab62e55e76 | ||
|
|
8f83687b7c | ||
|
|
a60c60c0f9 | ||
|
|
95a122a225 | ||
|
|
d234d79310 | ||
|
|
3188f8dbed | ||
|
|
9b9bb1e1e6 | ||
|
|
d31616ebcb |
@@ -1,3 +1,12 @@
|
|||||||
|
# @revanced/bot-websocket-api [1.0.0-dev.7](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.6...@revanced/bot-websocket-api@1.0.0-dev.7) (2024-07-30)
|
||||||
|
|
||||||
|
# @revanced/bot-websocket-api [1.0.0-dev.6](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.5...@revanced/bot-websocket-api@1.0.0-dev.6) (2024-07-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bots/discord:** hanging process when disconnecting from API too many times ([d31616e](https://github.com/revanced/revanced-helper/commit/d31616ebcba6f1dcd8bde183bcb8d1adb1501b61))
|
||||||
|
|
||||||
# @revanced/bot-websocket-api [1.0.0-dev.5](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.4...@revanced/bot-websocket-api@1.0.0-dev.5) (2024-07-23)
|
# @revanced/bot-websocket-api [1.0.0-dev.5](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.4...@revanced/bot-websocket-api@1.0.0-dev.5) (2024-07-23)
|
||||||
|
|
||||||
# @revanced/bot-websocket-api [1.0.0-dev.4](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.3...@revanced/bot-websocket-api@1.0.0-dev.4) (2024-07-23)
|
# @revanced/bot-websocket-api [1.0.0-dev.4](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.3...@revanced/bot-websocket-api@1.0.0-dev.4) (2024-07-23)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@revanced/bot-websocket-api",
|
"name": "@revanced/bot-websocket-api",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0-dev.5",
|
"version": "1.0.0-dev.7",
|
||||||
"description": "🧦 WebSocket API server for bots assisting ReVanced",
|
"description": "🧦 WebSocket API server for bots assisting ReVanced",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ await Bun.build({
|
|||||||
entrypoints: ['./src/index.ts'],
|
entrypoints: ['./src/index.ts'],
|
||||||
outdir: './dist',
|
outdir: './dist',
|
||||||
target: 'bun',
|
target: 'bun',
|
||||||
minify: true,
|
|
||||||
sourcemap: 'external',
|
sourcemap: 'external',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -21,7 +20,6 @@ await Bun.build({
|
|||||||
external: ['tesseract.js-core/*'],
|
external: ['tesseract.js-core/*'],
|
||||||
target: 'bun',
|
target: 'bun',
|
||||||
outdir: './dist/worker',
|
outdir: './dist/worker',
|
||||||
minify: true,
|
|
||||||
sourcemap: 'external',
|
sourcemap: 'external',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
},
|
},
|
||||||
"useNodejsImportProtocol": {
|
"useNodejsImportProtocol": {
|
||||||
"level": "off"
|
"level": "off"
|
||||||
|
},
|
||||||
|
"useNumberNamespace": {
|
||||||
|
"level": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,24 @@
|
|||||||
|
# @revanced/discord-bot [1.0.0-dev.12](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.11...@revanced/discord-bot@1.0.0-dev.12) (2024-07-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bots/discord:** deployment runtime errors due to minification ([a60c60c](https://github.com/revanced/revanced-helper/commit/a60c60c0f994a4c256b7d0582e99a1731209cf49))
|
||||||
|
|
||||||
|
# @revanced/discord-bot [1.0.0-dev.11](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.10...@revanced/discord-bot@1.0.0-dev.11) (2024-07-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bots/discord:** reset counter when reconnected to api, redo message scan filter logic ([d234d79](https://github.com/revanced/revanced-helper/commit/d234d79310caed9c43e14a905f9ef46a110e071d))
|
||||||
|
|
||||||
|
# @revanced/discord-bot [1.0.0-dev.10](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.9...@revanced/discord-bot@1.0.0-dev.10) (2024-07-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bots/discord:** hanging process when disconnecting from API too many times ([d31616e](https://github.com/revanced/revanced-helper/commit/d31616ebcba6f1dcd8bde183bcb8d1adb1501b61))
|
||||||
|
|
||||||
# @revanced/discord-bot [1.0.0-dev.9](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.8...@revanced/discord-bot@1.0.0-dev.9) (2024-07-30)
|
# @revanced/discord-bot [1.0.0-dev.9](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.8...@revanced/discord-bot@1.0.0-dev.9) (2024-07-30)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ export default {
|
|||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("my-command")
|
.setName("my-command")
|
||||||
.setDescription("My cool command")
|
.setDescription("My cool command")
|
||||||
// Allowing this command to be used in DMs
|
|
||||||
.setDMPermission(true)
|
|
||||||
// DO NOT forget this line!
|
// DO NOT forget this line!
|
||||||
.toJSON(),
|
.toJSON(),
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@revanced/discord-bot",
|
"name": "@revanced/discord-bot",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0-dev.9",
|
"version": "1.0.0-dev.12",
|
||||||
"description": "🤖 Discord bot assisting ReVanced",
|
"description": "🤖 Discord bot assisting ReVanced",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ await Bun.build({
|
|||||||
outdir: './dist/src',
|
outdir: './dist/src',
|
||||||
target: 'bun',
|
target: 'bun',
|
||||||
external: ['./config.js'],
|
external: ['./config.js'],
|
||||||
minify: true,
|
|
||||||
sourcemap: 'external',
|
sourcemap: 'external',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ withContext(on, 'disconnect', ({ api, config, logger }, reason, msg) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (api.disconnectCount >= (config.api.disconnectLimit ?? 3)) {
|
if (api.disconnectCount >= (config.api.disconnectLimit ?? 3)) {
|
||||||
console.error('Disconnected from bot API too many times')
|
logger.fatal('Disconnected from bot API too many times')
|
||||||
// We don't want the process hanging
|
// We don't want the process hanging
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
import { on, withContext } from '$utils/api/events'
|
import { on, withContext } from '$utils/api/events'
|
||||||
|
|
||||||
withContext(on, 'ready', ({ logger }) => void logger.info('Connected to the bot API'))
|
withContext(on, 'ready', ({ api, logger }) => {
|
||||||
|
// Reset disconnect count, so it doesn't meet the threshold for an accidental disconnect
|
||||||
|
api.disconnectCount = 0
|
||||||
|
logger.info('Connected to the bot API')
|
||||||
|
})
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ withContext(on, 'messageCreate', async (context, msg) => {
|
|||||||
|
|
||||||
if (msg.author.bot) return
|
if (msg.author.bot) return
|
||||||
|
|
||||||
const regex = new RegExp(`^(?:${config.prefix}|${msg.client.user.toString()}\\s*)([a-zA-Z-_]+)(?:\\s+)?(.+)?`)
|
const regex = new RegExp(
|
||||||
|
`^(?:${config.prefix ? `${escapeRegexSpecials(config.prefix)}|` : ''}${msg.client.user.toString()}\\s*)([a-zA-Z-_]+)(?:\\s+)?(.+)?`,
|
||||||
|
)
|
||||||
const matches = msg.content.match(regex)
|
const matches = msg.content.match(regex)
|
||||||
|
|
||||||
if (!matches) return
|
if (!matches) return
|
||||||
@@ -51,3 +53,12 @@ withContext(on, 'messageCreate', async (context, msg) => {
|
|||||||
await msg.reply({ embeds: [err instanceof CommandError ? err.toEmbed() : createStackTraceEmbed(err)] })
|
await msg.reply({ embeds: [err instanceof CommandError ? err.toEmbed() : createStackTraceEmbed(err)] })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const escapeRegexSpecials = (str: string): string => {
|
||||||
|
let escapedStr = ''
|
||||||
|
for (const char of str) {
|
||||||
|
if (['.', '+', '*', '?', '$', '(', ')', '[', ']', '{', '}', '|', '\\'].includes(char)) escapedStr += `\\${char}`
|
||||||
|
else escapedStr += char
|
||||||
|
}
|
||||||
|
return escapedStr
|
||||||
|
}
|
||||||
|
|||||||
@@ -113,15 +113,24 @@ export const messageMatchesFilter = (message: Message, filter: NonNullable<Confi
|
|||||||
if (!filter) return true
|
if (!filter) return true
|
||||||
|
|
||||||
const memberRoles = new Set(message.member?.roles.cache.keys())
|
const memberRoles = new Set(message.member?.roles.cache.keys())
|
||||||
const blFilter = filter.blacklist
|
const { blacklist, whitelist } = filter
|
||||||
|
|
||||||
// If matches blacklist, will return false
|
// If matches only blacklist, will return false
|
||||||
// Any other case, will return true
|
// If matches whitelist but also matches blacklist, will return false
|
||||||
return !(
|
// If matches only whitelist, will return true
|
||||||
blFilter &&
|
// If matches neither, will return true
|
||||||
(blFilter.channels?.includes(message.channelId) ||
|
return (
|
||||||
blFilter.roles?.some(role => memberRoles.has(role)) ||
|
(whitelist
|
||||||
blFilter.users?.includes(message.author.id))
|
? whitelist.channels?.includes(message.channelId) ||
|
||||||
|
whitelist.roles?.some(role => memberRoles.has(role)) ||
|
||||||
|
whitelist.users?.includes(message.author.id)
|
||||||
|
: true) &&
|
||||||
|
!(
|
||||||
|
blacklist &&
|
||||||
|
(blacklist.channels?.includes(message.channelId) ||
|
||||||
|
blacklist.roles?.some(role => memberRoles.has(role)) ||
|
||||||
|
blacklist.users?.includes(message.author.id))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
],
|
],
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch",
|
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch",
|
||||||
"drizzle-kit@0.22.8": "patches/drizzle-kit@0.22.8.patch"
|
"drizzle-kit@0.22.8": "patches/drizzle-kit@0.22.8.patch",
|
||||||
|
"decancer@3.2.3": "patches/decancer@3.2.3.patch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,19 +49,13 @@ export class ClientWebSocketManager {
|
|||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
if (!this.ready) {
|
if (!this.ready) {
|
||||||
this.#socket?.close(DisconnectReason.TooSlow)
|
this.#socket?.close(DisconnectReason.TooSlow)
|
||||||
throw new Error('WebSocket connection was not readied in time')
|
this._handleDisconnect(DisconnectReason.TooSlow, 'WebSocket connection was not readied in time')
|
||||||
}
|
}
|
||||||
}, this.timeout)
|
}, this.timeout)
|
||||||
|
|
||||||
const errorBeforeReadyHandler = (err: Error) => {
|
|
||||||
cleanup()
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
|
|
||||||
const closeBeforeReadyHandler = (code: number, reason: Buffer) => {
|
const closeBeforeReadyHandler = (code: number, reason: Buffer) => {
|
||||||
clearTimeout(timeout)
|
|
||||||
this._handleDisconnect(code, reason.toString())
|
this._handleDisconnect(code, reason.toString())
|
||||||
throw new Error('WebSocket connection closed before ready')
|
cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
const readyHandler = () => {
|
const readyHandler = () => {
|
||||||
@@ -71,15 +65,14 @@ export class ClientWebSocketManager {
|
|||||||
rs()
|
rs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const socket = this.#socket
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
this.#socket.off('open', readyHandler)
|
socket.off('open', readyHandler)
|
||||||
this.#socket.off('close', closeBeforeReadyHandler)
|
socket.off('close', closeBeforeReadyHandler)
|
||||||
this.#socket.off('error', errorBeforeReadyHandler)
|
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#socket.on('open', readyHandler)
|
this.#socket.on('open', readyHandler)
|
||||||
this.#socket.on('error', errorBeforeReadyHandler)
|
|
||||||
this.#socket.on('close', closeBeforeReadyHandler)
|
this.#socket.on('close', closeBeforeReadyHandler)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rj(e)
|
rj(e)
|
||||||
|
|||||||
13
patches/decancer@3.2.3.patch
Normal file
13
patches/decancer@3.2.3.patch
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/src/lib.js b/src/lib.js
|
||||||
|
index de45d7dbe82975b09eff3742d0718accae2107fc..0575daa03dfabdd5c96928458ff4270cb8f7188a 100644
|
||||||
|
--- a/src/lib.js
|
||||||
|
+++ b/src/lib.js
|
||||||
|
@@ -42,7 +42,7 @@ function isMusl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBinding(name) {
|
||||||
|
- const path = join(__dirname, '..', `decancer.${name}.node`)
|
||||||
|
+ const path = join(import.meta.dir, '..', `decancer.${name}.node`)
|
||||||
|
|
||||||
|
return require(existsSync(path) ? path : `@vierofernando/decancer-${name}`)
|
||||||
|
}
|
||||||
@@ -25,8 +25,8 @@ const Options = {
|
|||||||
[
|
[
|
||||||
'@semantic-release/npm',
|
'@semantic-release/npm',
|
||||||
{
|
{
|
||||||
npmPublish: false,
|
npmPublish: false,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'@semantic-release/git',
|
'@semantic-release/git',
|
||||||
|
|||||||
Reference in New Issue
Block a user