mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
sync
This commit is contained in:
@@ -11,11 +11,7 @@ interface Payload {
|
||||
user_id?: number | string
|
||||
}
|
||||
|
||||
interface Response {
|
||||
message_id: number
|
||||
}
|
||||
|
||||
abstract class ForwardSingleMsg extends BaseAction<Payload, Response> {
|
||||
abstract class ForwardSingleMsg extends BaseAction<Payload, null> {
|
||||
protected async getTargetPeer(payload: Payload): Promise<Peer> {
|
||||
if (payload.user_id) {
|
||||
const peerUid = await NTQQUserApi.getUidByUin(payload.user_id.toString())
|
||||
@@ -27,13 +23,13 @@ abstract class ForwardSingleMsg extends BaseAction<Payload, Response> {
|
||||
return { chatType: ChatType.group, peerUid: payload.group_id!.toString() }
|
||||
}
|
||||
|
||||
protected async _handle(payload: Payload): Promise<Response> {
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
const msg = await dbUtil.getMsgByShortId(payload.message_id)
|
||||
if (!msg) {
|
||||
throw new Error(`无法找到消息${payload.message_id}`)
|
||||
}
|
||||
const peer = await this.getTargetPeer(payload)
|
||||
const sentMsg = await NTQQMsgApi.forwardMsg(
|
||||
const ret = await NTQQMsgApi.forwardMsg(
|
||||
{
|
||||
chatType: msg.chatType,
|
||||
peerUid: msg.peerUid,
|
||||
@@ -41,8 +37,10 @@ abstract class ForwardSingleMsg extends BaseAction<Payload, Response> {
|
||||
peer,
|
||||
[msg.msgId],
|
||||
)
|
||||
const ob11MsgId = await dbUtil.addMsg(sentMsg)
|
||||
return { message_id: ob11MsgId! }
|
||||
if (ret.result !== 0) {
|
||||
throw new Error(`转发消息失败 ${ret.errMsg}`)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user