Skip to content

Commit

Permalink
feat: support market emoticon
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed Apr 11, 2024
1 parent 6f9df7e commit 0791221
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/engine-chronocat-api/src/api/message/create/messager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,25 @@ export class Messager {
}

case `${this.ctx.chronocat.platform}:face`: {
const face = (await this.ctx.chronocat.api[
'chronocat.internal.qface.get'
](`${attrs['id']}`))!
if (attrs['unsafeMarketEmoticon']) {
this.children.push(r.marketEmoticon(Number(attrs['id'])))
} else {
const face = (await this.ctx.chronocat.api[
'chronocat.internal.qface.get'
](`${attrs['id']}`))!

this.children.push(
r.face(
face,
attrs['unsafeSuper']
? FaceType.Super
: face.QSid === face.IQLid && face.QSid === face.AQLid
? FaceType.Normal2
: FaceType.Normal1,
),
)
}

this.children.push(
r.face(
face,
attrs['unsafeSuper']
? FaceType.Super
: face.QSid === face.IQLid && face.QSid === face.AQLid
? FaceType.Normal2
: FaceType.Normal1,
),
)
this.isEndLine = false
return
}
Expand Down
11 changes: 11 additions & 0 deletions packages/engine-chronocat-api/src/api/message/create/r.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ const b = () => {
},
},

marketEmoticon: (faceIndex: number): O.Partial<Element, 'deep'> => ({
elementType: 6,
elementId: '',
faceElement: {
faceIndex,
faceText: '\n',
faceType: FaceType.MarketEmoticon,
imageType: 1,
},
}),

pcPoke: (pokeType: number): O.Partial<Element, 'deep'> => ({
elementId: '0',
elementType: 6,
Expand Down
11 changes: 11 additions & 0 deletions packages/engine-chronocat-event/src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,17 @@ async function parseElements(
)
break
}

case FaceType.MarketEmoticon: {
elements.push(
ctx.chronocat.h(`${ctx.chronocat.platform}:face`, {
id: m.faceElement!.faceIndex,
platform: ctx.chronocat.platform,
'unsafe-market-emoticon': true,
}),
)
break
}
}
break
}
Expand Down
10 changes: 10 additions & 0 deletions packages/red/src/redEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@ export enum FaceType {
*/
Super = 3,

/**
* MarketEmoticon
*
* faceIndex 为 uint32
*
* - epId (Emoticon Pack ID) : faceIndex >> 16
* - eId (Emoticon ID) : faceIndex & 0xFFFF
*/
MarketEmoticon = 4,

/**
* PC 戳一戳(窗口抖动)
*/
Expand Down

0 comments on commit 0791221

Please sign in to comment.