Compare commits

...

7 Commits

Author SHA1 Message Date
semantic-release-bot
887ee85e41 chore(release): 1.0.0-dev.7 [skip ci]
# @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)
2024-07-30 19:13:45 +00:00
PalmDevs
c9b788dc51 build(Needs bump): do not minify builds 2024-07-31 02:12:31 +07:00
PalmDevs
ab62e55e76 fix(bots/discord): broken regex when prefix set to special characters 2024-07-31 02:12:30 +07:00
semantic-release-bot
8f83687b7c chore(release): 1.0.0-dev.12 [skip ci]
# @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](a60c60c0f9))
2024-07-30 18:42:20 +00:00
PalmDevs
a60c60c0f9 fix(bots/discord): deployment runtime errors due to minification 2024-07-31 01:40:45 +07:00
semantic-release-bot
95a122a225 chore(release): 1.0.0-dev.11 [skip ci]
# @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](d234d79310))
2024-07-30 17:23:25 +00:00
PalmDevs
d234d79310 fix(bots/discord): reset counter when reconnected to api, redo message scan filter logic 2024-07-31 00:22:02 +07:00
12 changed files with 67 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
# @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) # @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)

View File

@@ -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.6", "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": {

View File

@@ -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',
}) })

View File

@@ -1,3 +1,17 @@
# @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) # @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)

View File

@@ -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.10", "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": {

View File

@@ -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',
}) })

View File

@@ -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')
})

View File

@@ -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
}

View File

@@ -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))
)
) )
} }

BIN
bun.lockb

Binary file not shown.

View File

@@ -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"
} }
} }

View 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}`)
}