Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Apr 24, 2024
1 parent d6552ce commit f92a17c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/onebot11/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(),
Expand Down
40 changes: 35 additions & 5 deletions src/onebot11/action/msg/MarkMsgAsRead.ts
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 2 additions & 1 deletion src/onebot11/action/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/onebot11/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '1.0.3';
export const version = '1.1.2';

0 comments on commit f92a17c

Please sign in to comment.