mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +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
|
1. 修复图片URL,支持Win X64获取Rkey
|
||||||
2. 支持了设置已读群/私聊消息接口
|
2. 支持了设置已读群/私聊消息接口
|
||||||
3. 支持了好友添加上报事件
|
3. 支持了好友添加上报事件
|
||||||
|
4. 重构了商城表情URL拼接
|
||||||
|
@ -34,7 +34,7 @@ import SetGroupAdmin from './group/SetGroupAdmin';
|
|||||||
import SetGroupCard from './group/SetGroupCard';
|
import SetGroupCard from './group/SetGroupCard';
|
||||||
import GetImage from './file/GetImage';
|
import GetImage from './file/GetImage';
|
||||||
import GetRecord from './file/GetRecord';
|
import GetRecord from './file/GetRecord';
|
||||||
import { MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
|
import { GoCQHTTPMarkMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
|
||||||
import CleanCache from './system/CleanCache';
|
import CleanCache from './system/CleanCache';
|
||||||
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
||||||
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
|
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
|
||||||
@ -52,6 +52,8 @@ export const actionHandlers = [
|
|||||||
// new GetConfigAction(),
|
// new GetConfigAction(),
|
||||||
// new SetConfigAction(),
|
// new SetConfigAction(),
|
||||||
// new GetGroupAddRequest(),
|
// new GetGroupAddRequest(),
|
||||||
|
new MarkGroupMsgAsRead(),
|
||||||
|
new MarkPrivateMsgAsRead(),
|
||||||
new SetQQAvatar(),
|
new SetQQAvatar(),
|
||||||
// onebot11
|
// onebot11
|
||||||
new SendLike(),
|
new SendLike(),
|
||||||
@ -86,8 +88,7 @@ export const actionHandlers = [
|
|||||||
new GoCQHTTPGetStrangerInfo(),
|
new GoCQHTTPGetStrangerInfo(),
|
||||||
new GoCQHTTPDownloadFile(),
|
new GoCQHTTPDownloadFile(),
|
||||||
new GetGuildList(),
|
new GetGuildList(),
|
||||||
new MarkGroupMsgAsRead(),
|
new GoCQHTTPMarkMsgAsRead(),
|
||||||
new MarkPrivateMsgAsRead(),
|
|
||||||
new GoCQHTTPUploadGroupFile(),
|
new GoCQHTTPUploadGroupFile(),
|
||||||
new GoCQHTTPGetGroupMsgHistory(),
|
new GoCQHTTPGetGroupMsgHistory(),
|
||||||
new GoCQHTTGetForwardMsgAction(),
|
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 BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQMsgApi } from '@/core/qqnt/apis';
|
import { NTQQMsgApi } from '@/core/qqnt/apis';
|
||||||
import { getFriend, getUidByUin } from '@/common/data';
|
import { getFriend, getUidByUin } from '@/common/data';
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
uin: string,
|
user_id: number;
|
||||||
|
group_id?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MarkMsgAsRead extends BaseAction<Payload, null> {
|
class MarkMsgAsRead extends BaseAction<Payload, null> {
|
||||||
ReqChatType = 0;
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
async getPeer(payload: Payload): Promise<Peer> {
|
||||||
let uid: string | undefined = payload.uin;
|
if (payload.user_id) {
|
||||||
if (this.ReqChatType != ChatType.group) {
|
const peerUid = getUidByUin(payload.user_id.toString());
|
||||||
uid = getUidByUin(payload.uin.toString());
|
if (!peerUid) {
|
||||||
if (!uid) {
|
throw `私聊${payload.user_id}不存在`;
|
||||||
throw `记录${payload.uin}不存在`;
|
|
||||||
}
|
}
|
||||||
const friend = await getFriend(uid);
|
const friend = await getFriend(peerUid);
|
||||||
this.ReqChatType = friend ? ChatType.friend : ChatType.temp;//重写
|
return { chatType: friend ? ChatType.friend: ChatType.temp, peerUid };
|
||||||
}
|
}
|
||||||
// 获取UID 组装Peer
|
if (!payload.group_id) {
|
||||||
// GuildId: string 留空
|
throw '缺少参数 group_id 或 user_id';
|
||||||
const ReqPeer: Peer = { chatType: this.ReqChatType, peerUid: uid, guildId: '' };
|
}
|
||||||
|
return { chatType: ChatType.group, peerUid: payload.group_id.toString() };
|
||||||
|
}
|
||||||
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
// 调用API
|
// 调用API
|
||||||
const ret = await NTQQMsgApi.setMsgRead(ReqPeer);
|
const ret = await NTQQMsgApi.setMsgRead(await this.getPeer(payload));
|
||||||
if (ret.result != 0) {
|
if (ret.result != 0) {
|
||||||
throw ('设置已读失败');
|
throw ('设置已读失败,' + ret.errMsg);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class MarkPrivateMsgAsRead extends MarkMsgAsRead {
|
export class MarkPrivateMsgAsRead extends MarkMsgAsRead {
|
||||||
actionName = ActionName.MarkPrivateMsgAsRead;
|
actionName = ActionName.MarkPrivateMsgAsRead;
|
||||||
ReqChatType = ChatType.friend;
|
|
||||||
}
|
}
|
||||||
export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
||||||
actionName = ActionName.MarkGroupMsgAsRead;
|
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_SendGroupForwardMsg = 'send_group_forward_msg',
|
||||||
GoCQHTTP_SendPrivateForwardMsg = 'send_private_forward_msg',
|
GoCQHTTP_SendPrivateForwardMsg = 'send_private_forward_msg',
|
||||||
GoCQHTTP_GetStrangerInfo = 'get_stranger_info',
|
GoCQHTTP_GetStrangerInfo = 'get_stranger_info',
|
||||||
|
GoCQHTTP_MarkMsgAsRead = 'mark_msg_as_read',
|
||||||
GetGuildList = 'get_guild_list',
|
GetGuildList = 'get_guild_list',
|
||||||
MarkPrivateMsgAsRead = 'mark_private_msg_as_read',
|
MarkPrivateMsgAsRead = 'mark_private_msg_as_read',
|
||||||
MarkGroupMsgAsRead = 'mark_group_msg_as_read',
|
MarkGroupMsgAsRead = 'mark_group_msg_as_read',
|
||||||
|
@ -217,7 +217,8 @@ export class OB11Constructor {
|
|||||||
// 取md5的前两位
|
// 取md5的前两位
|
||||||
const dir = md5.substring(0, 2);
|
const dir = md5.substring(0, 2);
|
||||||
// 获取组装url
|
// 获取组装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;
|
message_data['data']['url'] = url;
|
||||||
} else if (element.markdownElement) {
|
} else if (element.markdownElement) {
|
||||||
message_data['type'] = OB11MessageDataType.markdown;
|
message_data['type'] = OB11MessageDataType.markdown;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { rkeyHook as rkeyManager } from '@/core/qqnt/extends/rkey';
|
|
||||||
import { napCatCore } from '@/core';
|
import { napCatCore } from '@/core';
|
||||||
import { MsgListener } from '@/core/qqnt/listeners';
|
import { MsgListener } from '@/core/qqnt/listeners';
|
||||||
import { NapCatOnebot11 } from '@/onebot11/main';
|
import { NapCatOnebot11 } from '@/onebot11/main';
|
||||||
@ -39,15 +38,12 @@ checkVersion().then((remoteVersion: string) => {
|
|||||||
new NapCatOnebot11();
|
new NapCatOnebot11();
|
||||||
napCatCore.addLoginSuccessCallback(() => {
|
napCatCore.addLoginSuccessCallback(() => {
|
||||||
console.log('login success');
|
console.log('login success');
|
||||||
try{
|
|
||||||
|
|
||||||
console.log(rkeyManager.HookRkey());
|
|
||||||
}catch (e) {
|
|
||||||
console.error();
|
|
||||||
}
|
|
||||||
postLoginStatus();
|
postLoginStatus();
|
||||||
const msgListener = new MsgListener();
|
const msgListener = new MsgListener();
|
||||||
msgListener.onRecvMsg = (msg) => {
|
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)
|
// console.log("onRecvMsg", msg)
|
||||||
};
|
};
|
||||||
// napCatCore.getGroupService().getGroupExtList(true).then((res) => {
|
// napCatCore.getGroupService().getGroupExtList(true).then((res) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user