mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
feat(apis/websocket): return true for data on a TrainedMessage packet
This commit is contained in:
@@ -18,7 +18,7 @@ const trainMessageEventHandler: EventHandler<ClientOperation.TrainMessage> = asy
|
|||||||
client.send(
|
client.send(
|
||||||
{
|
{
|
||||||
op: ServerOperation.TrainedMessage,
|
op: ServerOperation.TrainedMessage,
|
||||||
d: null,
|
d: true,
|
||||||
},
|
},
|
||||||
nextSeq,
|
nextSeq,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
url,
|
|
||||||
type AnySchema,
|
type AnySchema,
|
||||||
type NullSchema,
|
type NullSchema,
|
||||||
type ObjectSchema,
|
type ObjectSchema,
|
||||||
type Output,
|
type Output,
|
||||||
|
type BooleanSchema,
|
||||||
array,
|
array,
|
||||||
enum_,
|
enum_,
|
||||||
null_,
|
null_,
|
||||||
@@ -11,6 +11,8 @@ import {
|
|||||||
parse,
|
parse,
|
||||||
special,
|
special,
|
||||||
string,
|
string,
|
||||||
|
boolean,
|
||||||
|
url,
|
||||||
// merge
|
// merge
|
||||||
} from 'valibot'
|
} from 'valibot'
|
||||||
import DisconnectReason from '../constants/DisconnectReason'
|
import DisconnectReason from '../constants/DisconnectReason'
|
||||||
@@ -26,8 +28,7 @@ export const PacketSchema = special<Packet>(input => {
|
|||||||
'op' in input &&
|
'op' in input &&
|
||||||
typeof input.op === 'number' &&
|
typeof input.op === 'number' &&
|
||||||
input.op in Operation &&
|
input.op in Operation &&
|
||||||
'd' in input &&
|
'd' in input
|
||||||
typeof input.d === 'object'
|
|
||||||
) {
|
) {
|
||||||
if (input.op in ServerOperation && !('s' in input && typeof input.s === 'number')) return false
|
if (input.op in ServerOperation && !('s' in input && typeof input.s === 'number')) return false
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ export const PacketDataSchemas = {
|
|||||||
[ServerOperation.Disconnect]: object({
|
[ServerOperation.Disconnect]: object({
|
||||||
reason: enum_(DisconnectReason),
|
reason: enum_(DisconnectReason),
|
||||||
}),
|
}),
|
||||||
[ServerOperation.TrainedMessage]: null_(),
|
[ServerOperation.TrainedMessage]: boolean(),
|
||||||
[ServerOperation.TrainMessageFailed]: null_(),
|
[ServerOperation.TrainMessageFailed]: null_(),
|
||||||
|
|
||||||
[ClientOperation.ParseText]: object({
|
[ClientOperation.ParseText]: object({
|
||||||
@@ -78,7 +79,7 @@ export const PacketDataSchemas = {
|
|||||||
} as const satisfies Record<
|
} as const satisfies Record<
|
||||||
Operation,
|
Operation,
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: This is a schema, it's not possible to type it
|
// biome-ignore lint/suspicious/noExplicitAny: This is a schema, it's not possible to type it
|
||||||
ObjectSchema<any> | AnySchema | NullSchema
|
ObjectSchema<any> | AnySchema | NullSchema | BooleanSchema
|
||||||
>
|
>
|
||||||
|
|
||||||
export type Packet<TOp extends Operation = Operation> = TOp extends ServerOperation
|
export type Packet<TOp extends Operation = Operation> = TOp extends ServerOperation
|
||||||
|
|||||||
Reference in New Issue
Block a user