mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
Merge branch 'main' of https://github.com/NapNeko/NapCatQQ
This commit is contained in:
commit
20dec19bfe
@ -1,3 +1,4 @@
|
||||
1. 修复图片URL,支持Win X64获取Rkey
|
||||
2. 支持了设置已读群/私聊消息接口
|
||||
3. 支持了好友添加上报事件
|
||||
4. 重构了商城表情URL拼接
|
||||
|
@ -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 { MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
|
||||
import { GoCQHTTPMarkMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
|
||||
import CleanCache from './system/CleanCache';
|
||||
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
||||
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
|
||||
@ -52,6 +52,8 @@ export const actionHandlers = [
|
||||
// new GetConfigAction(),
|
||||
// new SetConfigAction(),
|
||||
// new GetGroupAddRequest(),
|
||||
new MarkGroupMsgAsRead(),
|
||||
new MarkPrivateMsgAsRead(),
|
||||
new SetQQAvatar(),
|
||||
// onebot11
|
||||
new SendLike(),
|
||||
@ -86,8 +88,7 @@ export const actionHandlers = [
|
||||
new GoCQHTTPGetStrangerInfo(),
|
||||
new GoCQHTTPDownloadFile(),
|
||||
new GetGuildList(),
|
||||
new MarkGroupMsgAsRead(),
|
||||
new MarkPrivateMsgAsRead(),
|
||||
new GoCQHTTPMarkMsgAsRead(),
|
||||
new GoCQHTTPUploadGroupFile(),
|
||||
new GoCQHTTPGetGroupMsgHistory(),
|
||||
new GoCQHTTGetForwardMsgAction(),
|
||||
|
@ -1,41 +1,55 @@
|
||||
import { ChatType, Peer, RawMessage, SendMessageElement } from '@/core/qqnt/entities';
|
||||
import { ChatType, Peer } 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 {
|
||||
uin: string,
|
||||
user_id: number;
|
||||
group_id?: number;
|
||||
}
|
||||
|
||||
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}不存在`;
|
||||
|
||||
async getPeer(payload: Payload): Promise<Peer> {
|
||||
if (payload.user_id) {
|
||||
const peerUid = getUidByUin(payload.user_id.toString());
|
||||
if (!peerUid) {
|
||||
throw `私聊${payload.user_id}不存在`;
|
||||
}
|
||||
const friend = await getFriend(uid);
|
||||
this.ReqChatType = friend ? ChatType.friend : ChatType.temp;//重写
|
||||
const friend = await getFriend(peerUid);
|
||||
return { chatType: friend ? ChatType.friend: ChatType.temp, peerUid };
|
||||
}
|
||||
// 获取UID 组装Peer
|
||||
// GuildId: string 留空
|
||||
const ReqPeer: Peer = { chatType: this.ReqChatType, peerUid: uid, guildId: '' };
|
||||
if (!payload.group_id) {
|
||||
throw '缺少参数 group_id 或 user_id';
|
||||
}
|
||||
return { chatType: ChatType.group, peerUid: payload.group_id.toString() };
|
||||
}
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
// 调用API
|
||||
const ret = await NTQQMsgApi.setMsgRead(ReqPeer);
|
||||
const ret = await NTQQMsgApi.setMsgRead(await this.getPeer(payload));
|
||||
if (ret.result != 0) {
|
||||
throw ('设置已读失败');
|
||||
throw ('设置已读失败,' + ret.errMsg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export class MarkPrivateMsgAsRead extends MarkMsgAsRead {
|
||||
actionName = ActionName.MarkPrivateMsgAsRead;
|
||||
ReqChatType = ChatType.friend;
|
||||
}
|
||||
export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
||||
actionName = ActionName.MarkGroupMsgAsRead;
|
||||
ReqChatType = ChatType.group;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Payload{
|
||||
message_id: number
|
||||
}
|
||||
|
||||
export class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null>{
|
||||
actionName = ActionName.GoCQHTTP_MarkMsgAsRead;
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ export enum ActionName {
|
||||
GoCQHTTP_SendGroupForwardMsg = 'send_group_forward_msg',
|
||||
GoCQHTTP_SendPrivateForwardMsg = 'send_private_forward_msg',
|
||||
GoCQHTTP_GetStrangerInfo = 'get_stranger_info',
|
||||
GoCQHTTP_MarkMsgAsRead = 'mark_msg_as_read',
|
||||
GetGuildList = 'get_guild_list',
|
||||
MarkPrivateMsgAsRead = 'mark_private_msg_as_read',
|
||||
MarkGroupMsgAsRead = 'mark_group_msg_as_read',
|
||||
@ -63,4 +64,4 @@ export enum ActionName {
|
||||
GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history',
|
||||
GoCQHTTP_GetForwardMsg = 'get_forward_msg',
|
||||
GetFriendMsgHistory = 'get_friend_msg_history'
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,8 @@ export class OB11Constructor {
|
||||
// 取md5的前两位
|
||||
const dir = md5.substring(0, 2);
|
||||
// 获取组装url
|
||||
const url = `https://p.qpic.cn/CDN_STATIC/0/data/imgcache/htdocs/club/item/parcel/item/${dir}/${md5}/300x300.png?max_age=31536000`;
|
||||
// const url = `https://p.qpic.cn/CDN_STATIC/0/data/imgcache/htdocs/club/item/parcel/item/${dir}/${md5}/300x300.gif?max_age=31536000`;
|
||||
const url = `https://gxh.vip.qq.com/club/item/parcel/item/${dir}/${md5}/raw300.gif`;
|
||||
message_data['data']['url'] = url;
|
||||
} else if (element.markdownElement) {
|
||||
message_data['type'] = OB11MessageDataType.markdown;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { rkeyHook as rkeyManager } from '@/core/qqnt/extends/rkey';
|
||||
import { napCatCore } from '@/core';
|
||||
import { MsgListener } from '@/core/qqnt/listeners';
|
||||
import { NapCatOnebot11 } from '@/onebot11/main';
|
||||
@ -39,15 +38,12 @@ checkVersion().then((remoteVersion: string) => {
|
||||
new NapCatOnebot11();
|
||||
napCatCore.addLoginSuccessCallback(() => {
|
||||
console.log('login success');
|
||||
try{
|
||||
|
||||
console.log(rkeyManager.HookRkey());
|
||||
}catch (e) {
|
||||
console.error();
|
||||
}
|
||||
postLoginStatus();
|
||||
const msgListener = new MsgListener();
|
||||
msgListener.onRecvMsg = (msg) => {
|
||||
// console.log(JSON.stringify(Array.from(msg[0].msgAttrs.values())));
|
||||
// napCatCore.service.msg.kernelService?.getMsgsByMsgId(msg[0].msgId, 20).then(res=>console.log(res));
|
||||
|
||||
// console.log("onRecvMsg", msg)
|
||||
};
|
||||
// napCatCore.getGroupService().getGroupExtList(true).then((res) => {
|
||||
|
Loading…
Reference in New Issue
Block a user