mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-12 06:06:21 +00:00
Compare commits
20 Commits
@revanced/
...
@revanced/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d862401a0 | ||
|
|
91bac934ab | ||
|
|
d74fba4092 | ||
|
|
ce76c5f08e | ||
|
|
bb2182e707 | ||
|
|
9b2888b944 | ||
|
|
ba1a467e20 | ||
|
|
c97fffb32f | ||
|
|
d138af46d1 | ||
|
|
75a57b0e16 | ||
|
|
c06033e573 | ||
|
|
d290417ff3 | ||
|
|
a21aa348d7 | ||
|
|
479812e199 | ||
|
|
f6119946f8 | ||
|
|
5d1af3c31c | ||
|
|
14c98e87df | ||
|
|
8e3946a666 | ||
|
|
c2009ca6d4 | ||
|
|
22d3eea88d |
@@ -1,3 +1,60 @@
|
|||||||
|
# @revanced/bot-websocket-api 1.0.0 (2025-04-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **apis/websocket:** also include tesseract core files in build ([7dfbf6c](https://github.com/revanced/revanced-bots/commit/7dfbf6c92c49100954fa4aca471dce4ab9fd9565))
|
||||||
|
* **apis/websocket:** attempt to fix missing remote address ([9b2888b](https://github.com/revanced/revanced-bots/commit/9b2888b944ea1d61d31aa5df3536768e9a2dadf8))
|
||||||
|
* **apis/websocket:** build and runtime issues ([89d8ab1](https://github.com/revanced/revanced-bots/commit/89d8ab1ee58278a9a96cdc31c679d0a0a0d865af))
|
||||||
|
* **apis/websocket:** builds not working due to dynamic import requirement ([fc7be22](https://github.com/revanced/revanced-bots/commit/fc7be22c6c15974c7394790e93de2a23a6627153))
|
||||||
|
* **apis/websocket:** don't bundle `tesseract.js` ([51a6fb6](https://github.com/revanced/revanced-bots/commit/51a6fb65f0df3409eacffb297430840a0e326989))
|
||||||
|
* **apis/websocket:** fix forever stuck Promise ([168f40d](https://github.com/revanced/revanced-bots/commit/168f40def64ca213cd2b549f4bafed4c0e1e3695))
|
||||||
|
* **apis/websocket:** fix undefined error ([2f03800](https://github.com/revanced/revanced-bots/commit/2f03800c61c00e59e512567d273a195e605d6736))
|
||||||
|
* **apis/websocket:** hardcoded paths in tesseract worker builds ([38e00eb](https://github.com/revanced/revanced-bots/commit/38e00eb4e59c763bd74d27b9b9b482ea66e4dcf4))
|
||||||
|
* **apis/websocket:** improve logging and error handling ([b6cbe9d](https://github.com/revanced/revanced-bots/commit/b6cbe9d64c01ff11feab8351fb801bc1aee48325))
|
||||||
|
* **bots/discord:** hanging process when disconnecting from API too many times ([d31616e](https://github.com/revanced/revanced-bots/commit/d31616ebcba6f1dcd8bde183bcb8d1adb1501b61))
|
||||||
|
* fix typings and formatting ([479812e](https://github.com/revanced/revanced-bots/commit/479812e199b52cdb295a5746e0767306afab3413))
|
||||||
|
* other small issues ([bc437a5](https://github.com/revanced/revanced-bots/commit/bc437a5ec7ce1d339094d608e2a61ac5f460c163))
|
||||||
|
* remove error cb handling for `socket.send()` calls ([29544d4](https://github.com/revanced/revanced-bots/commit/29544d4e0127173465796b7e3c62161f4db59c8b))
|
||||||
|
* run projects with `--bun` ([bb2182e](https://github.com/revanced/revanced-bots/commit/bb2182e707fa40c555d56138972eeea28f1b3cf9))
|
||||||
|
* **types:** fix issues with typings ([669e24c](https://github.com/revanced/revanced-bots/commit/669e24ca8103ea051b4e61160dd0f978e36707ea))
|
||||||
|
* update repo url ([a21aa34](https://github.com/revanced/revanced-bots/commit/a21aa348d7f32cd0ee65b371e9594520c0a9d3f1))
|
||||||
|
|
||||||
|
|
||||||
|
### chore
|
||||||
|
|
||||||
|
* fix more build issues ([77fefb9](https://github.com/revanced/revanced-bots/commit/77fefb9bef286a22f40a4d76b79c64fcc5a2467f))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **apis/websocket:** clear old client sessions and instances ([43bd0a0](https://github.com/revanced/revanced-bots/commit/43bd0a021cd885a3d74a1f307ec2935e81d17458))
|
||||||
|
* **apis/websocket:** return `true` for data on a `TrainedMessage` packet ([65add4d](https://github.com/revanced/revanced-bots/commit/65add4dfeed2fa067c2c8e2377f7d01d505ade54))
|
||||||
|
* **packages/shared:** add logger factory ([17c6be7](https://github.com/revanced/revanced-bots/commit/17c6be7bee5b5c24fd4a5279e73374b0bb7a6229))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* In `@revanced/discord-bot`, its environment variable
|
||||||
|
`DATABASE_URL` has been renamed to `DATABASE_PATH`
|
||||||
|
and the `file:` prefix is no longer needed
|
||||||
|
|
||||||
|
# @revanced/bot-websocket-api [1.0.0-dev.11](https://github.com/revanced/revanced-bots/compare/@revanced/bot-websocket-api@1.0.0-dev.10...@revanced/bot-websocket-api@1.0.0-dev.11) (2025-04-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **apis/websocket:** attempt to fix missing remote address ([9b2888b](https://github.com/revanced/revanced-bots/commit/9b2888b944ea1d61d31aa5df3536768e9a2dadf8))
|
||||||
|
* run projects with `--bun` ([bb2182e](https://github.com/revanced/revanced-bots/commit/bb2182e707fa40c555d56138972eeea28f1b3cf9))
|
||||||
|
|
||||||
|
# @revanced/bot-websocket-api [1.0.0-dev.10](https://github.com/revanced/revanced-bots/compare/@revanced/bot-websocket-api@1.0.0-dev.9...@revanced/bot-websocket-api@1.0.0-dev.10) (2025-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix typings and formatting ([479812e](https://github.com/revanced/revanced-bots/commit/479812e199b52cdb295a5746e0767306afab3413))
|
||||||
|
* update repo url ([a21aa34](https://github.com/revanced/revanced-bots/commit/a21aa348d7f32cd0ee65b371e9594520c0a9d3f1))
|
||||||
|
|
||||||
# @revanced/bot-websocket-api [1.0.0-dev.9](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.8...@revanced/bot-websocket-api@1.0.0-dev.9) (2024-08-03)
|
# @revanced/bot-websocket-api [1.0.0-dev.9](https://github.com/revanced/revanced-helper/compare/@revanced/bot-websocket-api@1.0.0-dev.8...@revanced/bot-websocket-api@1.0.0-dev.9) (2024-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,4 @@ WORKDIR /app
|
|||||||
COPY --from=build /build/apis/websocket/dist /app
|
COPY --from=build /build/apis/websocket/dist /app
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
|
|
||||||
ENTRYPOINT [ "bun", "run", "index.js" ]
|
ENTRYPOINT [ "bun", "--bun", "run", "index.js" ]
|
||||||
|
|||||||
@@ -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.9",
|
"version": "1.0.0",
|
||||||
"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": {
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/revanced/revanced-helper.git",
|
"url": "git+https://github.com/revanced/revanced-bots.git",
|
||||||
"directory": "apis/websocket"
|
"directory": "apis/websocket"
|
||||||
},
|
},
|
||||||
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
@@ -23,18 +23,18 @@
|
|||||||
],
|
],
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
"url": "https://github.com/revanced/revanced-bots/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
"homepage": "https://github.com/revanced/revanced-bots#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@revanced/bot-shared": "workspace:*",
|
"@revanced/bot-shared": "workspace:*",
|
||||||
"@sapphire/async-queue": "^1.5.3",
|
"@sapphire/async-queue": "^1.5.5",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.4.1",
|
||||||
"tesseract.js": "^5.1.1",
|
"tesseract.js": "^5.1.1",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.18.1",
|
||||||
"typed-emitter": "^2.1.0"
|
"typed-emitter": "^2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { createLogger } from '@revanced/bot-shared'
|
import { createLogger } from '@revanced/bot-shared'
|
||||||
import { cp, rm } from 'fs/promises'
|
import { cp, exists, rm } from 'fs/promises'
|
||||||
|
|
||||||
const logger = createLogger()
|
const logger = createLogger()
|
||||||
|
|
||||||
logger.info('Cleaning previous build...')
|
logger.info('Cleaning previous build...')
|
||||||
await rm('./dist', { recursive: true })
|
if (await exists('./dist')) await rm('./dist', { recursive: true })
|
||||||
|
|
||||||
logger.info('Building WebSocket API...')
|
logger.info('Building WebSocket API...')
|
||||||
await Bun.build({
|
await Bun.build({
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default class Client {
|
|||||||
protected _toBuffer(data: RawData) {
|
protected _toBuffer(data: RawData) {
|
||||||
if (data instanceof Buffer) return data
|
if (data instanceof Buffer) return data
|
||||||
if (data instanceof ArrayBuffer) return Buffer.from(data)
|
if (data instanceof ArrayBuffer) return Buffer.from(data)
|
||||||
return Buffer.concat(data)
|
return Buffer.concat(data as Uint8Array[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,13 @@ const wss = new WebSocketServer({
|
|||||||
|
|
||||||
wss.on('connection', async (socket, request) => {
|
wss.on('connection', async (socket, request) => {
|
||||||
try {
|
try {
|
||||||
if (!request.socket.remoteAddress) {
|
const addrInfo = request.socket.address()
|
||||||
|
if (!('address' in addrInfo)) {
|
||||||
socket.close()
|
socket.close()
|
||||||
return logger.warn('Connection failed because client is missing remote address')
|
return logger.warn('Connection failed because client is missing remote address. addrInfo =', addrInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = `${request.socket.remoteAddress}:${request.socket.remotePort}`
|
const id = `${addrInfo.address}:${addrInfo.port}`
|
||||||
|
|
||||||
if (clientIds.has(id)) {
|
if (clientIds.has(id)) {
|
||||||
logger.warn(`Client ${id} already connected, disconnecting old session`)
|
logger.warn(`Client ${id} already connected, disconnecting old session`)
|
||||||
|
|||||||
@@ -1,3 +1,35 @@
|
|||||||
|
# @revanced/discord-bot [1.0.0-dev.38](https://github.com/revanced/revanced-bots/compare/@revanced/discord-bot@1.0.0-dev.37...@revanced/discord-bot@1.0.0-dev.38) (2025-04-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* run projects with `--bun` ([bb2182e](https://github.com/revanced/revanced-bots/commit/bb2182e707fa40c555d56138972eeea28f1b3cf9))
|
||||||
|
|
||||||
|
# @revanced/discord-bot [1.0.0-dev.37](https://github.com/revanced/revanced-bots/compare/@revanced/discord-bot@1.0.0-dev.36...@revanced/discord-bot@1.0.0-dev.37) (2025-03-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bots/discord/utils/duration:** fix specified default unit not working ([d138af4](https://github.com/revanced/revanced-bots/commit/d138af46d1f25a11b6f8ab3790ecaa70b1d716a9))
|
||||||
|
|
||||||
|
# @revanced/discord-bot [1.0.0-dev.36](https://github.com/revanced/revanced-bots/compare/@revanced/discord-bot@1.0.0-dev.35...@revanced/discord-bot@1.0.0-dev.36) (2025-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bots/discord/scripts/build:** check if dist dir exists before cleaning ([c06033e](https://github.com/revanced/revanced-bots/commit/c06033e5730f82438e8052b9b519a8f8e2d25437))
|
||||||
|
* **bots/discord/utils/duration:** make second the default unit ([5d1af3c](https://github.com/revanced/revanced-bots/commit/5d1af3c31c3379b6a13684dfb07583737908c8aa))
|
||||||
|
* **bots/discord:** add GuildMember partial ([8e3946a](https://github.com/revanced/revanced-bots/commit/8e3946a66602838715787090008c7bfaf72b67e9))
|
||||||
|
* **bots/discord:** decrease length of an option in `ban` command ([22d3eea](https://github.com/revanced/revanced-bots/commit/22d3eea88d532792c1237d1a1ab18bc02e57816a))
|
||||||
|
* **bots/discord:** delete expired appliedPresets entries after unapplying ([14c98e8](https://github.com/revanced/revanced-bots/commit/14c98e87df1ec4fd762bbc48ca4c06470cb110a2))
|
||||||
|
* fix typings and formatting ([479812e](https://github.com/revanced/revanced-bots/commit/479812e199b52cdb295a5746e0767306afab3413))
|
||||||
|
* update repo url ([a21aa34](https://github.com/revanced/revanced-bots/commit/a21aa348d7f32cd0ee65b371e9594520c0a9d3f1))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **bots/discord:** add more month aliases to duration parser ([c2009ca](https://github.com/revanced/revanced-bots/commit/c2009ca6d42e4387bc5f375d76ecf72991b7fe32))
|
||||||
|
|
||||||
# @revanced/discord-bot [1.0.0-dev.35](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.34...@revanced/discord-bot@1.0.0-dev.35) (2024-10-17)
|
# @revanced/discord-bot [1.0.0-dev.35](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.34...@revanced/discord-bot@1.0.0-dev.35) (2024-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ COPY --from=build /build/bots/discord/dist /app
|
|||||||
|
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
|
|
||||||
ENTRYPOINT [ "bun", "run", "src/index.js" ]
|
ENTRYPOINT [ "bun", "--bun", "run", "src/index.js" ]
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ export default {
|
|||||||
},
|
},
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
forceSendTimeout: 300000,
|
forceSendTimeout: 300000,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
moderation: {
|
moderation: {
|
||||||
cure: {
|
cure: {
|
||||||
@@ -77,7 +77,7 @@ export default {
|
|||||||
attachments: {
|
attachments: {
|
||||||
scanAttachments: true,
|
scanAttachments: true,
|
||||||
allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp', 'text/plain'],
|
allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp', 'text/plain'],
|
||||||
maxTextFileSize: 512000
|
maxTextFileSize: 512000,
|
||||||
},
|
},
|
||||||
responses: [
|
responses: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.35",
|
"version": "1.0.0-dev.38",
|
||||||
"description": "🤖 Discord bot assisting ReVanced",
|
"description": "🤖 Discord bot assisting ReVanced",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/revanced/revanced-helper.git",
|
"url": "git+https://github.com/revanced/revanced-bots.git",
|
||||||
"directory": "bots/discord"
|
"directory": "bots/discord"
|
||||||
},
|
},
|
||||||
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
@@ -24,23 +24,23 @@
|
|||||||
],
|
],
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
"url": "https://github.com/revanced/revanced-bots/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
"homepage": "https://github.com/revanced/revanced-bots#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^1.9.0",
|
"@discordjs/builders": "^1.10.1",
|
||||||
"@discordjs/rest": "^2.4.0",
|
"@discordjs/rest": "^2.4.3",
|
||||||
"@revanced/bot-api": "workspace:*",
|
"@revanced/bot-api": "workspace:*",
|
||||||
"@revanced/bot-shared": "workspace:*",
|
"@revanced/bot-shared": "workspace:*",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.4.1",
|
||||||
"decancer": "^3.2.4",
|
"decancer": "^3.2.8",
|
||||||
"discord.js": "^14.16.3",
|
"discord.js": "^14.18.0",
|
||||||
"drizzle-orm": "^0.31.4",
|
"drizzle-orm": "^0.31.4",
|
||||||
"parse-duration": "^1.1.0"
|
"parse-duration": "^1.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@libsql/client": "^0.7.0",
|
"@libsql/client": "^0.7.0",
|
||||||
"discord-api-types": "^0.37.102",
|
"discord-api-types": "^0.37.119",
|
||||||
"drizzle-kit": "^0.22.8"
|
"drizzle-kit": "^0.22.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { createLogger } from '@revanced/bot-shared'
|
import { createLogger } from '@revanced/bot-shared'
|
||||||
import { cp, rm } from 'fs/promises'
|
import { cp, exists, rm } from 'fs/promises'
|
||||||
|
|
||||||
const logger = createLogger()
|
const logger = createLogger()
|
||||||
|
|
||||||
logger.warn('Cleaning previous build...')
|
logger.warn('Cleaning previous build...')
|
||||||
await rm('./dist', { recursive: true })
|
if (await exists('./dist')) await rm('./dist', { recursive: true })
|
||||||
|
|
||||||
logger.info('Building bot...')
|
logger.info('Building bot...')
|
||||||
await Bun.build({
|
await Bun.build({
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export default new ModerationCommand({
|
|||||||
},
|
},
|
||||||
dmt: {
|
dmt: {
|
||||||
description:
|
description:
|
||||||
'Time duration to delete messages (default time unit is days, must be from 0s to 7d, default value is 0s)',
|
'Time duration to delete messages (default time unit is days, must be from 0s to 7d, default is 0s)',
|
||||||
required: false,
|
required: false,
|
||||||
type: ModerationCommand.OptionType.String,
|
type: ModerationCommand.OptionType.String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import Command from '$/classes/Command'
|
import Command from '$/classes/Command'
|
||||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||||
import { config } from '../../../context'
|
|
||||||
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
|
|
||||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
|
||||||
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
||||||
|
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||||
|
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
|
||||||
|
import { config } from '../../../context'
|
||||||
|
|
||||||
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import Command from '$/classes/Command'
|
import Command from '$/classes/Command'
|
||||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||||
import { config } from '../../../context'
|
|
||||||
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
|
|
||||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||||
|
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
|
||||||
|
import { config } from '../../../context'
|
||||||
|
|
||||||
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export const discord = {
|
|||||||
parse: ['users'],
|
parse: ['users'],
|
||||||
repliedUser: true,
|
repliedUser: true,
|
||||||
},
|
},
|
||||||
partials: [Partials.Message, Partials.Reaction],
|
partials: [Partials.Message, Partials.Reaction, Partials.GuildMember],
|
||||||
}),
|
}),
|
||||||
commands: Object.fromEntries(Object.values(commands).map(cmd => [cmd.name, cmd])) as Record<
|
commands: Object.fromEntries(Object.values(commands).map(cmd => [cmd.name, cmd])) as Record<
|
||||||
string,
|
string,
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
const command = discord.commands[interaction.commandName]
|
const command = discord.commands[interaction.commandName]
|
||||||
|
|
||||||
logger.debug(`Command ${interaction.commandName} being invoked by ${interaction.user.tag} via chat`)
|
logger.debug(`Command ${interaction.commandName} being invoked by ${interaction.user.tag} via chat`)
|
||||||
if (!command)
|
if (!command) return void logger.error(`Chat command ${interaction.commandName} not implemented but registered!!!`)
|
||||||
return void logger.error(`Chat command ${interaction.commandName} not implemented but registered!!!`)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug(`Command ${interaction.commandName} being executed via chat`)
|
logger.debug(`Command ${interaction.commandName} being executed via chat`)
|
||||||
|
|||||||
@@ -8,28 +8,34 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => {
|
|||||||
if (!store) return
|
if (!store) return
|
||||||
|
|
||||||
if (store.timerActive) {
|
if (store.timerActive) {
|
||||||
if (!store.forceTimerActive && store.forceTimerMs) {
|
// Timer is already active, so we try to start the force timer
|
||||||
logger.debug(
|
if (store.forceTimerMs) {
|
||||||
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
// Force timer isn't active, so we start it
|
||||||
)
|
if (!store.forceTimerActive) {
|
||||||
|
logger.debug(
|
||||||
|
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
||||||
|
)
|
||||||
|
|
||||||
// Clear the timer
|
// Clear the timer
|
||||||
clearTimeout(store.timer)
|
clearTimeout(store.timer)
|
||||||
store.timerActive = false
|
store.timerActive = false
|
||||||
|
|
||||||
// (Re)start the force timer
|
// (Re)start the force timer
|
||||||
store.forceTimerActive = true
|
store.forceTimerActive = true
|
||||||
if (!store.forceTimer)
|
if (!store.forceTimer)
|
||||||
store.forceTimer = setTimeout(
|
store.forceTimer = setTimeout(
|
||||||
() =>
|
() =>
|
||||||
store.send(true).then(() => {
|
store.send(true).then(() => {
|
||||||
store.forceTimerActive = false
|
store.forceTimerActive = false
|
||||||
}),
|
}),
|
||||||
store.forceTimerMs,
|
store.forceTimerMs,
|
||||||
) as NodeJS.Timeout
|
) as NodeJS.Timeout
|
||||||
else store.forceTimer.refresh()
|
else store.forceTimer.refresh()
|
||||||
|
// Force timer is already active, so we force send
|
||||||
|
} else store.send()
|
||||||
}
|
}
|
||||||
} else if (!store.forceTimerActive) {
|
} else if (!store.forceTimerActive) {
|
||||||
|
// Both timers aren't active, so we start the timer
|
||||||
store.timerActive = true
|
store.timerActive = true
|
||||||
if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout
|
if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ const PossibleReactions = Object.values(Reactions) as string[]
|
|||||||
|
|
||||||
withContext(on, 'messageReactionAdd', async (context, rct, user) => {
|
withContext(on, 'messageReactionAdd', async (context, rct, user) => {
|
||||||
if (user.bot) return
|
if (user.bot) return
|
||||||
|
|
||||||
const { database: db, logger, config } = context
|
const { database: db, logger, config } = context
|
||||||
const { messageScan: msConfig } = config
|
const { messageScan: msConfig } = config
|
||||||
|
|
||||||
// If there's no config, we can't do anything
|
// If there's no config, we can't do anything
|
||||||
if (!msConfig?.humanCorrections) return
|
if (!msConfig?.humanCorrections) return
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { appliedPresets } from '$/database/schemas'
|
|||||||
import { applyCommonEmbedStyles } from '$/utils/discord/embeds'
|
import { applyCommonEmbedStyles } from '$/utils/discord/embeds'
|
||||||
import { on, withContext } from '$/utils/discord/events'
|
import { on, withContext } from '$/utils/discord/events'
|
||||||
import { removeRolePreset } from '$/utils/discord/rolePresets'
|
import { removeRolePreset } from '$/utils/discord/rolePresets'
|
||||||
import { lt } from 'drizzle-orm'
|
import { and, eq, lt } from 'drizzle-orm'
|
||||||
|
|
||||||
import type { Client } from 'discord.js'
|
import type { Client } from 'discord.js'
|
||||||
|
|
||||||
@@ -92,11 +92,15 @@ const removeExpiredPresets = async (client: Client) => {
|
|||||||
|
|
||||||
for (const expired of expireds)
|
for (const expired of expireds)
|
||||||
try {
|
try {
|
||||||
|
logger.debug(`Removing role preset for ${expired.memberId} in ${expired.guildId}`)
|
||||||
|
|
||||||
const guild = await client.guilds.fetch(expired.guildId)
|
const guild = await client.guilds.fetch(expired.guildId)
|
||||||
const member = await guild.members.fetch(expired.memberId)
|
const member = await guild.members.fetch(expired.memberId)
|
||||||
|
|
||||||
logger.debug(`Removing role preset for ${expired.memberId} in ${expired.guildId}`)
|
|
||||||
await removeRolePreset(member, expired.preset)
|
await removeRolePreset(member, expired.preset)
|
||||||
|
await database
|
||||||
|
.delete(appliedPresets)
|
||||||
|
.where(and(eq(appliedPresets.guildId, expired.guildId), eq(appliedPresets.memberId, expired.memberId)))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Error while removing role preset for ${expired.memberId} in ${expired.guildId}: ${e}`)
|
logger.error(`Error while removing role preset for ${expired.memberId} in ${expired.guildId}: ${e}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const cureNickname = async (member: GuildMember) => {
|
|||||||
cured =
|
cured =
|
||||||
member.user.username.length >= 3
|
member.user.username.length >= 3
|
||||||
? member.user.username
|
? member.user.username
|
||||||
: config.moderation?.cure?.defaultName ?? 'Server member'
|
: (config.moderation?.cure?.defaultName ?? 'Server member')
|
||||||
|
|
||||||
if (cured.toLowerCase() === name.toLowerCase()) return
|
if (cured.toLowerCase() === name.toLowerCase()) return
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import parse from 'parse-duration'
|
import parse from 'parse-duration'
|
||||||
|
|
||||||
const defaultUnitValue = parse['']!
|
parse[''] = parse['s']!
|
||||||
|
parse['mo'] = parse['M'] = parse['month']!
|
||||||
|
|
||||||
export const parseDuration = (duration: string, defaultUnit?: parse.Units) => {
|
export const parseDuration = (duration: string, defaultUnit?: parse.Units) => {
|
||||||
|
const defaultUnitValue = parse['']!
|
||||||
if (defaultUnit) parse[''] = parse[defaultUnit]!
|
if (defaultUnit) parse[''] = parse[defaultUnit]!
|
||||||
return (
|
const result = parse(duration, 'ms') ?? Number.NaN
|
||||||
// biome-ignore lint/suspicious/noAssignInExpressions: Expression is ignored
|
parse[''] = defaultUnitValue
|
||||||
// biome-ignore lint/style/noCommaOperator: The last expression (parse call) is returned, it is not confusing
|
return result
|
||||||
(parse[''] = defaultUnitValue), parse(duration, 'ms') ?? Number.NaN
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const durationToString = (duration: number) => {
|
export const durationToString = (duration: number) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# 🏗️ Setting up the development environment
|
# 🏗️ Setting up the development environment
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> **This project uses [Bun](https://bun.sh) to run and bundle the code.**
|
> **This project uses [Bun](https://bun.sh) to run and bundle the code.**
|
||||||
> Compatibility with other runtimes (Node.js, Deno, ...) are not guaranteed and most package scripts won't work.
|
> Compatibility with other runtimes (Node.js, Deno, ...) are not guaranteed and most package scripts won't work.
|
||||||
|
|
||||||
To start developing, you'll need to set up the development environment first.
|
To start developing, you'll need to set up the development environment first.
|
||||||
@@ -11,8 +11,8 @@ To start developing, you'll need to set up the development environment first.
|
|||||||
2. Clone the mono-repository
|
2. Clone the mono-repository
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/revanced/revanced-helper.git &&
|
git clone https://github.com/revanced/revanced-bots.git &&
|
||||||
cd revanced-helper
|
cd revanced-bots
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Install dependencies
|
3. Install dependencies
|
||||||
|
|||||||
28
package.json
28
package.json
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "revanced-helper",
|
"name": "revanced-bots",
|
||||||
"description": "🤖 Bots assisting ReVanced on multiple platforms",
|
"description": "🤖 Bots assisting ReVanced on multiple platforms",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
"flint:check": "biome check .",
|
"flint:check": "biome check .",
|
||||||
"clint": "commitlint --edit"
|
"clint": "commitlint --edit"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
"homepage": "https://github.com/revanced/revanced-bots#readme",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/revanced/revanced-helper.git"
|
"url": "git+https://github.com/revanced/revanced-bots.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
"url": "https://github.com/revanced/revanced-bots/issues"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
@@ -29,23 +29,23 @@
|
|||||||
],
|
],
|
||||||
"packageManager": "bun@1.1.20",
|
"packageManager": "bun@1.1.20",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@anolilab/multi-semantic-release": "^1.1.3",
|
"@anolilab/multi-semantic-release": "^1.1.10",
|
||||||
"@biomejs/biome": "^1.9.3",
|
"@biomejs/biome": "^1.9.4",
|
||||||
"@codedependant/semantic-release-docker": "^5.0.3",
|
"@codedependant/semantic-release-docker": "^5.1.0",
|
||||||
"@commitlint/cli": "^19.5.0",
|
"@commitlint/cli": "^19.8.0",
|
||||||
"@commitlint/config-conventional": "^19.5.0",
|
"@commitlint/config-conventional": "^19.8.0",
|
||||||
"@saithodev/semantic-release-backmerge": "^4.0.1",
|
"@saithodev/semantic-release-backmerge": "^4.0.1",
|
||||||
"@semantic-release/changelog": "^6.0.3",
|
"@semantic-release/changelog": "^6.0.3",
|
||||||
"@semantic-release/exec": "^6.0.3",
|
"@semantic-release/exec": "^6.0.3",
|
||||||
"@semantic-release/git": "^10.0.1",
|
"@semantic-release/git": "^10.0.1",
|
||||||
"@tsconfig/strictest": "^2.0.5",
|
"@tsconfig/strictest": "^2.0.5",
|
||||||
"@types/bun": "^1.1.11",
|
"@types/bun": "^1.2.8",
|
||||||
"conventional-changelog-conventionalcommits": "^7.0.2",
|
"conventional-changelog-conventionalcommits": "^7.0.2",
|
||||||
"lefthook": "^1.7.21",
|
"lefthook": "^1.11.6",
|
||||||
"portainer-service-webhook": "https://github.com/newarifrh/portainer-service-webhook#v1",
|
"portainer-service-webhook": "https://github.com/newarifrh/portainer-service-webhook#v1",
|
||||||
"semantic-release": "^24.1.2",
|
"semantic-release": "^24.2.3",
|
||||||
"turbo": "^2.1.3",
|
"turbo": "^2.5.0",
|
||||||
"typescript": "^5.6.3"
|
"typescript": "^5.8.2"
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
"@biomejs/biome",
|
"@biomejs/biome",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/revanced/revanced-helper.git",
|
"url": "git+https://github.com/revanced/revanced-bots.git",
|
||||||
"directory": "packages/api"
|
"directory": "packages/api"
|
||||||
},
|
},
|
||||||
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
@@ -23,15 +23,15 @@
|
|||||||
],
|
],
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
"url": "https://github.com/revanced/revanced-bots/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
"homepage": "https://github.com/revanced/revanced-bots#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@revanced/bot-shared": "workspace:*",
|
"@revanced/bot-shared": "workspace:*",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.18.1",
|
||||||
"typed-emitter": "^2.1.0"
|
"typed-emitter": "^2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ export class ClientWebSocketManager {
|
|||||||
protected _toBuffer(data: RawData) {
|
protected _toBuffer(data: RawData) {
|
||||||
if (data instanceof Buffer) return data
|
if (data instanceof Buffer) return data
|
||||||
if (data instanceof ArrayBuffer) return Buffer.from(data)
|
if (data instanceof ArrayBuffer) return Buffer.from(data)
|
||||||
return Buffer.concat(data)
|
return Buffer.concat(data as Uint8Array[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/revanced/revanced-helper.git",
|
"url": "git+https://github.com/revanced/revanced-bots.git",
|
||||||
"directory": "packages/shared"
|
"directory": "packages/shared"
|
||||||
},
|
},
|
||||||
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
@@ -26,12 +26,12 @@
|
|||||||
],
|
],
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
"url": "https://github.com/revanced/revanced-bots/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
"homepage": "https://github.com/revanced/revanced-bots#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": "^6.8.0",
|
"bson": "^6.10.3",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.4.1",
|
||||||
"tracer": "^1.3.0",
|
"tracer": "^1.3.0",
|
||||||
"valibot": "^0.30.0"
|
"valibot": "^0.30.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ export function serializePacket<TOp extends Operation>(packet: Packet<TOp>) {
|
|||||||
* @returns A packet
|
* @returns A packet
|
||||||
*/
|
*/
|
||||||
export function deserializePacket(buffer: Buffer) {
|
export function deserializePacket(buffer: Buffer) {
|
||||||
const data = BSON.deserialize(buffer)
|
const data = BSON.deserialize(buffer as Uint8Array)
|
||||||
return parse(PacketSchema, data) as Packet
|
return parse(PacketSchema, data) as Packet
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user