mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 21:56:17 +00:00
Compare commits
5 Commits
@revanced/
...
@revanced/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95a122a225 | ||
|
|
d234d79310 | ||
|
|
3188f8dbed | ||
|
|
9b9bb1e1e6 | ||
|
|
d31616ebcb |
@@ -1,3 +1,10 @@
|
||||
# @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.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",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"version": "1.0.0-dev.5",
|
||||
"version": "1.0.0-dev.6",
|
||||
"description": "🧦 WebSocket API server for bots assisting ReVanced",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
},
|
||||
"useNodejsImportProtocol": {
|
||||
"level": "off"
|
||||
},
|
||||
"useNumberNamespace": {
|
||||
"level": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# @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)
|
||||
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("my-command")
|
||||
.setDescription("My cool command")
|
||||
// Allowing this command to be used in DMs
|
||||
.setDMPermission(true)
|
||||
// DO NOT forget this line!
|
||||
.toJSON(),
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@revanced/discord-bot",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"version": "1.0.0-dev.9",
|
||||
"version": "1.0.0-dev.11",
|
||||
"description": "🤖 Discord bot assisting ReVanced",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -16,7 +16,7 @@ withContext(on, 'disconnect', ({ api, config, logger }, reason, msg) => {
|
||||
)
|
||||
|
||||
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
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
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')
|
||||
})
|
||||
|
||||
@@ -113,15 +113,24 @@ export const messageMatchesFilter = (message: Message, filter: NonNullable<Confi
|
||||
if (!filter) return true
|
||||
|
||||
const memberRoles = new Set(message.member?.roles.cache.keys())
|
||||
const blFilter = filter.blacklist
|
||||
const { blacklist, whitelist } = filter
|
||||
|
||||
// If matches blacklist, will return false
|
||||
// Any other case, will return true
|
||||
return !(
|
||||
blFilter &&
|
||||
(blFilter.channels?.includes(message.channelId) ||
|
||||
blFilter.roles?.some(role => memberRoles.has(role)) ||
|
||||
blFilter.users?.includes(message.author.id))
|
||||
// If matches only blacklist, will return false
|
||||
// If matches whitelist but also matches blacklist, will return false
|
||||
// If matches only whitelist, will return true
|
||||
// If matches neither, will return true
|
||||
return (
|
||||
(whitelist
|
||||
? 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))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -49,19 +49,13 @@ export class ClientWebSocketManager {
|
||||
const timeout = setTimeout(() => {
|
||||
if (!this.ready) {
|
||||
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)
|
||||
|
||||
const errorBeforeReadyHandler = (err: Error) => {
|
||||
cleanup()
|
||||
throw err
|
||||
}
|
||||
|
||||
const closeBeforeReadyHandler = (code: number, reason: Buffer) => {
|
||||
clearTimeout(timeout)
|
||||
this._handleDisconnect(code, reason.toString())
|
||||
throw new Error('WebSocket connection closed before ready')
|
||||
cleanup()
|
||||
}
|
||||
|
||||
const readyHandler = () => {
|
||||
@@ -71,15 +65,14 @@ export class ClientWebSocketManager {
|
||||
rs()
|
||||
}
|
||||
|
||||
const socket = this.#socket
|
||||
const cleanup = () => {
|
||||
this.#socket.off('open', readyHandler)
|
||||
this.#socket.off('close', closeBeforeReadyHandler)
|
||||
this.#socket.off('error', errorBeforeReadyHandler)
|
||||
socket.off('open', readyHandler)
|
||||
socket.off('close', closeBeforeReadyHandler)
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
|
||||
this.#socket.on('open', readyHandler)
|
||||
this.#socket.on('error', errorBeforeReadyHandler)
|
||||
this.#socket.on('close', closeBeforeReadyHandler)
|
||||
} catch (e) {
|
||||
rj(e)
|
||||
|
||||
@@ -25,8 +25,8 @@ const Options = {
|
||||
[
|
||||
'@semantic-release/npm',
|
||||
{
|
||||
npmPublish: false,
|
||||
}
|
||||
npmPublish: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
'@semantic-release/git',
|
||||
|
||||
Reference in New Issue
Block a user