mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: forward single msg
This commit is contained in:
parent
5562a3251d
commit
3ae2d2a1e6
@ -14,7 +14,11 @@ import GetVersionInfo from "./system/GetVersionInfo";
|
|||||||
import CanSendRecord from "./system/CanSendRecord";
|
import CanSendRecord from "./system/CanSendRecord";
|
||||||
import CanSendImage from "./system/CanSendImage";
|
import CanSendImage from "./system/CanSendImage";
|
||||||
import GetStatus from "./system/GetStatus";
|
import GetStatus from "./system/GetStatus";
|
||||||
import {GoCQHTTPSendForwardMsg, GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg";
|
import {
|
||||||
|
GoCQHTTPSendForwardMsg,
|
||||||
|
GoCQHTTPSendGroupForwardMsg,
|
||||||
|
GoCQHTTPSendPrivateForwardMsg
|
||||||
|
} from "./go-cqhttp/SendForwardMsg";
|
||||||
import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo";
|
import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo";
|
||||||
import SendLike from "./user/SendLike";
|
import SendLike from "./user/SendLike";
|
||||||
import SetGroupAddRequest from "./group/SetGroupAddRequest";
|
import SetGroupAddRequest from "./group/SetGroupAddRequest";
|
||||||
@ -32,7 +36,7 @@ import GetImage from "./file/GetImage";
|
|||||||
import GetRecord from "./file/GetRecord";
|
import GetRecord from "./file/GetRecord";
|
||||||
import GoCQHTTPMarkMsgAsRead from "./msg/MarkMsgAsRead";
|
import GoCQHTTPMarkMsgAsRead from "./msg/MarkMsgAsRead";
|
||||||
import CleanCache from "./system/CleanCache";
|
import CleanCache from "./system/CleanCache";
|
||||||
import GoCQHTTPUploadGroupFile from "./go-cqhttp/UploadGroupFile";
|
import {GoCQHTTPUploadGroupFile, GoCQHTTPUploadPrivateFile} from "./go-cqhttp/UploadGroupFile";
|
||||||
import {GetConfigAction, SetConfigAction} from "./llonebot/Config";
|
import {GetConfigAction, SetConfigAction} from "./llonebot/Config";
|
||||||
import GetGroupAddRequest from "./llonebot/GetGroupAddRequest";
|
import GetGroupAddRequest from "./llonebot/GetGroupAddRequest";
|
||||||
import SetQQAvatar from './llonebot/SetQQAvatar'
|
import SetQQAvatar from './llonebot/SetQQAvatar'
|
||||||
@ -41,6 +45,8 @@ import GoCQHTTPGetGroupMsgHistory from "./go-cqhttp/GetGroupMsgHistory";
|
|||||||
import GetFile from "./file/GetFile";
|
import GetFile from "./file/GetFile";
|
||||||
import {GoCQHTTGetForwardMsgAction} from "./go-cqhttp/GetForwardMsg";
|
import {GoCQHTTGetForwardMsgAction} from "./go-cqhttp/GetForwardMsg";
|
||||||
import {GetCookies} from "./user/GetCookie";
|
import {GetCookies} from "./user/GetCookie";
|
||||||
|
import {SetMsgEmojiLike} from "./msg/SetMsgEmojiLike";
|
||||||
|
import {ForwardFriendSingleMsg, ForwardSingleGroupMsg} from "./msg/ForwardSingleMsg";
|
||||||
|
|
||||||
export const actionHandlers = [
|
export const actionHandlers = [
|
||||||
new GetFile(),
|
new GetFile(),
|
||||||
@ -74,6 +80,9 @@ export const actionHandlers = [
|
|||||||
new GetRecord(),
|
new GetRecord(),
|
||||||
new CleanCache(),
|
new CleanCache(),
|
||||||
new GetCookies(),
|
new GetCookies(),
|
||||||
|
new SetMsgEmojiLike(),
|
||||||
|
new ForwardFriendSingleMsg(),
|
||||||
|
new ForwardSingleGroupMsg(),
|
||||||
//以下为go-cqhttp api
|
//以下为go-cqhttp api
|
||||||
new GoCQHTTPSendForwardMsg(),
|
new GoCQHTTPSendForwardMsg(),
|
||||||
new GoCQHTTPSendGroupForwardMsg(),
|
new GoCQHTTPSendGroupForwardMsg(),
|
||||||
@ -83,9 +92,9 @@ export const actionHandlers = [
|
|||||||
new GetGuildList(),
|
new GetGuildList(),
|
||||||
new GoCQHTTPMarkMsgAsRead(),
|
new GoCQHTTPMarkMsgAsRead(),
|
||||||
new GoCQHTTPUploadGroupFile(),
|
new GoCQHTTPUploadGroupFile(),
|
||||||
|
new GoCQHTTPUploadPrivateFile(),
|
||||||
new GoCQHTTPGetGroupMsgHistory(),
|
new GoCQHTTPGetGroupMsgHistory(),
|
||||||
new GoCQHTTGetForwardMsgAction(),
|
new GoCQHTTGetForwardMsgAction(),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
function initActionMap() {
|
function initActionMap() {
|
||||||
|
44
src/onebot11/action/msg/ForwardSingleMsg.ts
Normal file
44
src/onebot11/action/msg/ForwardSingleMsg.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import BaseAction from "../BaseAction";
|
||||||
|
import {NTQQMsgApi, Peer} from "../../../ntqqapi/api";
|
||||||
|
import {ChatType, RawMessage} from "../../../ntqqapi/types";
|
||||||
|
import {dbUtil} from "../../../common/db";
|
||||||
|
import {getUidByUin} from "../../../common/data";
|
||||||
|
import {ActionName} from "../types";
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
message_id: number
|
||||||
|
group_id: number
|
||||||
|
user_id?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ForwardSingleMsg extends BaseAction<Payload, null> {
|
||||||
|
|
||||||
|
protected async getTargetPeer(payload: Payload): Promise<Peer> {
|
||||||
|
if (payload.user_id){
|
||||||
|
return {chatType: ChatType.friend, peerUid: getUidByUin(payload.user_id.toString())}
|
||||||
|
}
|
||||||
|
return {chatType: ChatType.group, peerUid: payload.group_id.toString()}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
|
const msg = await dbUtil.getMsgByShortId(payload.message_id)
|
||||||
|
const peer = await this.getTargetPeer(payload);
|
||||||
|
await NTQQMsgApi.forwardMsg({
|
||||||
|
chatType: msg.chatType,
|
||||||
|
peerUid: msg.peerUid
|
||||||
|
},
|
||||||
|
peer,
|
||||||
|
[msg.msgId]
|
||||||
|
)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ForwardFriendSingleMsg extends ForwardSingleMsg {
|
||||||
|
actionName = ActionName.ForwardFriendSingleMsg
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ForwardSingleGroupMsg extends ForwardSingleMsg {
|
||||||
|
actionName = ActionName.ForwardGroupSingleMsg
|
||||||
|
}
|
@ -34,6 +34,7 @@ export enum ActionName {
|
|||||||
SendGroupMsg = "send_group_msg",
|
SendGroupMsg = "send_group_msg",
|
||||||
SendPrivateMsg = "send_private_msg",
|
SendPrivateMsg = "send_private_msg",
|
||||||
DeleteMsg = "delete_msg",
|
DeleteMsg = "delete_msg",
|
||||||
|
SetMsgEmojiLike = "set_msg_emoji_like",
|
||||||
SetGroupAddRequest = "set_group_add_request",
|
SetGroupAddRequest = "set_group_add_request",
|
||||||
SetFriendAddRequest = "set_friend_add_request",
|
SetFriendAddRequest = "set_friend_add_request",
|
||||||
SetGroupLeave = "set_group_leave",
|
SetGroupLeave = "set_group_leave",
|
||||||
@ -51,6 +52,8 @@ export enum ActionName {
|
|||||||
GetRecord = "get_record",
|
GetRecord = "get_record",
|
||||||
CleanCache = "clean_cache",
|
CleanCache = "clean_cache",
|
||||||
GetCookies = "get_cookies",
|
GetCookies = "get_cookies",
|
||||||
|
ForwardFriendSingleMsg = "forward_friend_single_msg",
|
||||||
|
ForwardGroupSingleMsg = "forward_group_single_msg",
|
||||||
// 以下为go-cqhttp api
|
// 以下为go-cqhttp api
|
||||||
GoCQHTTP_SendForwardMsg = "send_forward_msg",
|
GoCQHTTP_SendForwardMsg = "send_forward_msg",
|
||||||
GoCQHTTP_SendGroupForwardMsg = "send_group_forward_msg",
|
GoCQHTTP_SendGroupForwardMsg = "send_group_forward_msg",
|
||||||
@ -59,6 +62,7 @@ export enum ActionName {
|
|||||||
GetGuildList = "get_guild_list",
|
GetGuildList = "get_guild_list",
|
||||||
GoCQHTTP_MarkMsgAsRead = "mark_msg_as_read",
|
GoCQHTTP_MarkMsgAsRead = "mark_msg_as_read",
|
||||||
GoCQHTTP_UploadGroupFile = "upload_group_file",
|
GoCQHTTP_UploadGroupFile = "upload_group_file",
|
||||||
|
GoCQHTTP_UploadPrivateFile = "upload_private_file",
|
||||||
GoCQHTTP_DownloadFile = "download_file",
|
GoCQHTTP_DownloadFile = "download_file",
|
||||||
GoCQHTTP_GetGroupMsgHistory = "get_group_msg_history",
|
GoCQHTTP_GetGroupMsgHistory = "get_group_msg_history",
|
||||||
GoCQHTTP_GetForwardMsg = "get_forward_msg",
|
GoCQHTTP_GetForwardMsg = "get_forward_msg",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user