mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-25 09:37:35 +00:00
refactor(event): use platform in ctx
This commit is contained in:
parent
dd93e1f125
commit
07f282420d
@ -1 +0,0 @@
|
|||||||
export const PLATFORM = 'chronocat'
|
|
@ -1 +0,0 @@
|
|||||||
export const PLATFORM = 'chronocat'
|
|
@ -7,7 +7,6 @@ import type {
|
|||||||
SatoriDispatchMessage,
|
SatoriDispatchMessage,
|
||||||
} from '@chronocat/shell'
|
} from '@chronocat/shell'
|
||||||
import type { O } from 'ts-toolbelt'
|
import type { O } from 'ts-toolbelt'
|
||||||
import { PLATFORM } from './consts'
|
|
||||||
import { buildParser } from './parser'
|
import { buildParser } from './parser'
|
||||||
|
|
||||||
export class MessageCreatedDispatchMessage implements SatoriDispatchMessage {
|
export class MessageCreatedDispatchMessage implements SatoriDispatchMessage {
|
||||||
@ -48,7 +47,7 @@ export class FriendRequestDispatchMessage implements SatoriDispatchMessage {
|
|||||||
type = 'satori' as const
|
type = 'satori' as const
|
||||||
|
|
||||||
toSatori = async (
|
toSatori = async (
|
||||||
_ctx: ChronocatContext,
|
ctx: ChronocatContext,
|
||||||
_config: O.Intersect<
|
_config: O.Intersect<
|
||||||
ChronocatLogCurrentConfig,
|
ChronocatLogCurrentConfig,
|
||||||
ChronocatSatoriEventsConfig
|
ChronocatSatoriEventsConfig
|
||||||
@ -58,7 +57,7 @@ export class FriendRequestDispatchMessage implements SatoriDispatchMessage {
|
|||||||
id: undefined as unknown as number,
|
id: undefined as unknown as number,
|
||||||
type: 'friend-request',
|
type: 'friend-request',
|
||||||
|
|
||||||
platform: PLATFORM,
|
platform: ctx.chronocat.platform,
|
||||||
self_id: undefined as unknown as string,
|
self_id: undefined as unknown as string,
|
||||||
timestamp: Number(this.buddyReq.reqTime) * 1000,
|
timestamp: Number(this.buddyReq.reqTime) * 1000,
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import type {
|
|||||||
import h from '@satorijs/element'
|
import h from '@satorijs/element'
|
||||||
import { Buffer } from 'node:buffer'
|
import { Buffer } from 'node:buffer'
|
||||||
import type { O } from 'ts-toolbelt'
|
import type { O } from 'ts-toolbelt'
|
||||||
import { PLATFORM } from '../consts'
|
|
||||||
import { parseMsgTypes } from './msgt'
|
import { parseMsgTypes } from './msgt'
|
||||||
|
|
||||||
export const buildParser =
|
export const buildParser =
|
||||||
@ -480,7 +479,7 @@ async function parseElements(
|
|||||||
switch (m.faceElement!.faceType) {
|
switch (m.faceElement!.faceType) {
|
||||||
case FaceType.PCPoke: {
|
case FaceType.PCPoke: {
|
||||||
elements.push(
|
elements.push(
|
||||||
h(`${PLATFORM}:pcpoke`, {
|
h(`${ctx.chronocat.platform}:pcpoke`, {
|
||||||
id: m.faceElement!.pokeType,
|
id: m.faceElement!.pokeType,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -490,10 +489,10 @@ async function parseElements(
|
|||||||
case FaceType.Normal:
|
case FaceType.Normal:
|
||||||
case FaceType.Super: {
|
case FaceType.Super: {
|
||||||
elements.push(
|
elements.push(
|
||||||
h(`${PLATFORM}:face`, {
|
h(`${ctx.chronocat.platform}:face`, {
|
||||||
id: m.faceElement!.faceIndex,
|
id: m.faceElement!.faceIndex,
|
||||||
name: `[${(await ctx.chronocat.api['chronocat.internal.qface.get'](`${m.faceElement!.faceIndex}`))!.QDes.slice(1)}]`,
|
name: `[${(await ctx.chronocat.api['chronocat.internal.qface.get'](`${m.faceElement!.faceIndex}`))!.QDes.slice(1)}]`,
|
||||||
platform: PLATFORM,
|
platform: ctx.chronocat.platform,
|
||||||
'unsafe-super': m.faceElement!.faceType === FaceType.Super,
|
'unsafe-super': m.faceElement!.faceType === FaceType.Super,
|
||||||
'unsafe-result-id': m.faceElement!.resultId,
|
'unsafe-result-id': m.faceElement!.resultId,
|
||||||
'unsafe-chain-count': m.faceElement!.chainCount,
|
'unsafe-chain-count': m.faceElement!.chainCount,
|
||||||
|
Loading…
Reference in New Issue
Block a user