This commit is contained in:
手瓜一十雪 2024-04-24 12:00:13 +08:00
parent d6552ce333
commit f92a17c01b
4 changed files with 41 additions and 9 deletions

View File

@ -34,7 +34,7 @@ import SetGroupAdmin from './group/SetGroupAdmin';
import SetGroupCard from './group/SetGroupCard';
import GetImage from './file/GetImage';
import GetRecord from './file/GetRecord';
import GoCQHTTPMarkMsgAsRead from './msg/MarkMsgAsRead';
import { MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
import CleanCache from './system/CleanCache';
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
@ -86,7 +86,8 @@ export const actionHandlers = [
new GoCQHTTPGetStrangerInfo(),
new GoCQHTTPDownloadFile(),
new GetGuildList(),
new GoCQHTTPMarkMsgAsRead(),
new MarkGroupMsgAsRead(),
new MarkPrivateMsgAsRead(),
new GoCQHTTPUploadGroupFile(),
new GoCQHTTPGetGroupMsgHistory(),
new GoCQHTTGetForwardMsgAction(),

View File

@ -1,14 +1,44 @@
import { ChatType, Peer, RawMessage, SendMessageElement } from '@/core/qqnt/entities';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { NTQQMsgApi } from '@/core/qqnt/apis';
import { getFriend, getUidByUin } from '@/common/data';
interface Payload{
message_id: number
interface Payload {
uin: string,
}
export default class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null>{
actionName = ActionName.GoCQHTTP_MarkMsgAsRead;
class MarkMsgAsRead extends BaseAction<Payload, null> {
ReqChatType = 0;
protected async _handle(payload: Payload): Promise<null> {
let uid: string | undefined = payload.uin;
if (this.ReqChatType != ChatType.group) {
uid = getUidByUin(payload.uin.toString())
if (!uid) {
throw `记录${payload.uin}不存在`;
}
let friend = await getFriend(uid);
this.ReqChatType = friend ? ChatType.friend : ChatType.temp;//重写
}
// 获取UID 组装Peer
// GuildId: string 留空
let ReqPeer: Peer = { chatType: this.ReqChatType, peerUid: uid, guildId: "" };
// 调用API
let ret = await NTQQMsgApi.setMsgRead(ReqPeer);
if (ret.result != 0) {
throw ('设置已读失败');
}
return null;
}
}
export class MarkPrivateMsgAsRead extends MarkMsgAsRead {
actionName = ActionName.MarkPrivateMsgAsRead;
ReqChatType = ChatType.friend;
}
export class MarkGroupMsgAsRead extends MarkMsgAsRead {
actionName = ActionName.MarkGroupMsgAsRead;
ReqChatType = ChatType.group;
}

View File

@ -56,7 +56,8 @@ export enum ActionName {
GoCQHTTP_SendPrivateForwardMsg = 'send_private_forward_msg',
GoCQHTTP_GetStrangerInfo = 'get_stranger_info',
GetGuildList = 'get_guild_list',
GoCQHTTP_MarkMsgAsRead = 'mark_msg_as_read',
MarkPrivateMsgAsRead = 'mark_private_msg_as_read',
MarkGroupMsgAsRead = 'mark_group_msg_as_read',
GoCQHTTP_UploadGroupFile = 'upload_group_file',
GoCQHTTP_DownloadFile = 'download_file',
GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history',

View File

@ -1 +1 @@
export const version = '1.0.3';
export const version = '1.1.2';