diff --git a/src/ntqqapi/constructor.ts b/src/ntqqapi/constructor.ts index ad802c2..0be0f05 100644 --- a/src/ntqqapi/constructor.ts +++ b/src/ntqqapi/constructor.ts @@ -1,6 +1,7 @@ import { AtType, ElementType, + FaceType, PicType, SendArkElement, SendFaceElement, @@ -18,6 +19,7 @@ import {calculateFileMD5, isGIF} from "../common/utils/file"; import {log} from "../common/utils/log"; import {defaultVideoThumb, getVideoInfo} from "../common/utils/video"; import {encodeSilk} from "../common/utils/audio"; +import {isNull} from "../common/utils"; export class SendMsgElementConstructor { @@ -237,7 +239,52 @@ export class SendMsgElementConstructor { elementId: "", faceElement: { faceIndex: faceId, - faceType: 1 + faceType: FaceType.normal + } + } + } + + static dice(resultId: number|null): SendFaceElement{ + // 实际测试并不能控制结果 + + // 随机1到6 + if (isNull(resultId)) resultId = Math.floor(Math.random() * 6) + 1; + return { + elementType: ElementType.FACE, + elementId: "", + faceElement: { + faceIndex: 358, + faceType: FaceType.dice, + "faceText": "[骰子]", + "packId": "1", + "stickerId": "33", + "sourceType": 1, + "stickerType": 2, + resultId: resultId.toString(), + "surpriseId": "", + // "randomType": 1, + } + } + } + + // 猜拳(石头剪刀布)表情 + static rps(resultId: number | null): SendFaceElement{ + // 实际测试并不能控制结果 + if (isNull(resultId)) resultId = Math.floor(Math.random() * 3) + 1; + return { + elementType: ElementType.FACE, + elementId: "", + faceElement: { + "faceIndex": 359, + "faceText": "[包剪锤]", + "faceType": 3, + "packId": "1", + "stickerId": "34", + "sourceType": 1, + "stickerType": 2, + "resultId": resultId.toString(), + "surpriseId": "", + // "randomType": 1, } } } diff --git a/src/ntqqapi/types/msg.ts b/src/ntqqapi/types/msg.ts index a6a46ac..8fe07c2 100644 --- a/src/ntqqapi/types/msg.ts +++ b/src/ntqqapi/types/msg.ts @@ -212,9 +212,22 @@ export interface GrayTipElement { } } +export enum FaceType { + normal=1, // 小黄脸 + dice=3 // 骰子 +} + export interface FaceElement { faceIndex: number, - faceType: 1 + faceType: FaceType, + faceText?: string, + packId?: string, + stickerId?: string, + sourceType?: number, + stickerType?: number, + resultId?: string, + surpriseId?: string, + randomType?: number } export interface MarketFaceElement { diff --git a/src/onebot11/action/msg/SendMsg.ts b/src/onebot11/action/msg/SendMsg.ts index a421c33..cb03f8a 100644 --- a/src/onebot11/action/msg/SendMsg.ts +++ b/src/onebot11/action/msg/SendMsg.ts @@ -224,6 +224,14 @@ export async function createSendElements(messageData: OB11MessageData[], target: } } break; + case OB11MessageDataType.dice:{ + const resultId = sendMsg.data?.result + sendElements.push(SendMsgElementConstructor.dice(resultId)); + }break; + case OB11MessageDataType.RPS:{ + const resultId = sendMsg.data?.result + sendElements.push(SendMsgElementConstructor.rps(resultId)); + }break; } } diff --git a/src/onebot11/types.ts b/src/onebot11/types.ts index 289f959..8dd8aa4 100644 --- a/src/onebot11/types.ts +++ b/src/onebot11/types.ts @@ -117,7 +117,9 @@ export enum OB11MessageDataType { node = "node", // 合并转发消息节点 forward = "forward", // 合并转发消息,用于上报 xml = "xml", - poke = "poke" + poke = "poke", + dice = "dice", + RPS = "rps" } export interface OB11MessageMFace{ @@ -126,6 +128,20 @@ export interface OB11MessageMFace{ text: string } } + +export interface OB11MessageDice{ + type: OB11MessageDataType.dice, + data: { + result: number + } +} +export interface OB11MessageRPS{ + type: OB11MessageDataType.RPS, + data: { + result: number + } +} + export interface OB11MessageText { type: OB11MessageDataType.text, data: { @@ -226,7 +242,8 @@ export type OB11MessageData = OB11MessageFace | OB11MessageMFace | OB11MessageAt | OB11MessageReply | OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo | - OB11MessageNode | OB11MessageCustomMusic | OB11MessageJson | OB11MessagePoke + OB11MessageNode | OB11MessageCustomMusic | OB11MessageJson | OB11MessagePoke | + OB11MessageDice | OB11MessageRPS export interface OB11PostSendMsg { message_type?: "private" | "group"