Skip to content

Commit

Permalink
fix: SendGroupAiRecord
Browse files Browse the repository at this point in the history
- smtx
  • Loading branch information
pk5ls20 committed Jan 4, 2025
1 parent 67afd95 commit 574c8c6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/onebot/action/group/SendGroupAiRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ export class SendGroupAiRecord extends GetPacketStatusDepends<Payload, {
payloadSchema = SchemaData;

async _handle(payload: Payload) {
const rawRsp = await this.core.apis.PacketApi.pkt.operation.GetAiVoice(+payload.group_id, payload.character, payload.text, AIVoiceChatType.Sound);
const url = await this.core.apis.PacketApi.pkt.operation.GetGroupPttUrl(+payload.group_id, rawRsp.msgInfoBody[0].index);
const { path, errMsg, success } = (await uriToLocalFile(this.core.NapCatTempPath, url));
if (!success) {
throw new Error(errMsg);
}
const peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() } as Peer;
const element = await this.core.apis.FileApi.createValidSendPttElement(path);
const sendRes = await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, [element], [path]);
return { message_id: sendRes.id ?? -1 };
await this.core.apis.PacketApi.pkt.operation.GetAiVoice(+payload.group_id, payload.character, payload.text, AIVoiceChatType.Sound);
return {
message_id: 0 // can't get message_id from GetAiVoice
};
}
}

0 comments on commit 574c8c6

Please sign in to comment.