mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
Merge branch 'main' of https://github.com/NapNeko/NapCatQQ
This commit is contained in:
commit
fe5042f1c3
@ -50,6 +50,7 @@
|
|||||||
"commander": "^12.0.0",
|
"commander": "^12.0.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^5.0.0-beta.2",
|
"express": "^5.0.0-beta.2",
|
||||||
|
"fast-xml-parser": "^4.3.6",
|
||||||
"file-type": "^19.0.0",
|
"file-type": "^19.0.0",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
"image-size": "^1.1.1",
|
"image-size": "^1.1.1",
|
||||||
|
@ -46,6 +46,7 @@ import GetFile from './file/GetFile';
|
|||||||
import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg';
|
import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg';
|
||||||
import GetFriendMsgHistory from './go-cqhttp/GetFriendMsgHistory';
|
import GetFriendMsgHistory from './go-cqhttp/GetFriendMsgHistory';
|
||||||
import { GetCookies } from './user/GetCookies';
|
import { GetCookies } from './user/GetCookies';
|
||||||
|
import { SetMsgEmojiLike } from '@/onebot11/action/msg/SetMsgEmojiLike';
|
||||||
|
|
||||||
export const actionHandlers = [
|
export const actionHandlers = [
|
||||||
new GetFile(),
|
new GetFile(),
|
||||||
@ -80,6 +81,7 @@ export const actionHandlers = [
|
|||||||
new SetGroupCard(),
|
new SetGroupCard(),
|
||||||
new GetImage(),
|
new GetImage(),
|
||||||
new GetRecord(),
|
new GetRecord(),
|
||||||
|
new SetMsgEmojiLike(),
|
||||||
// new CleanCache(),
|
// new CleanCache(),
|
||||||
new GetCookies(),
|
new GetCookies(),
|
||||||
//以下为go-cqhttp api
|
//以下为go-cqhttp api
|
||||||
|
27
src/onebot11/action/msg/SetMsgEmojiLike.ts
Normal file
27
src/onebot11/action/msg/SetMsgEmojiLike.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { ActionName } from '../types';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { dbUtil } from '@/common/utils/db';
|
||||||
|
import { NTQQMsgApi } from '@/core/apis';
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
message_id: number,
|
||||||
|
emoji_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SetMsgEmojiLike extends BaseAction<Payload, any> {
|
||||||
|
actionName = ActionName.SetMsgEmojiLike;
|
||||||
|
|
||||||
|
protected async _handle(payload: Payload) {
|
||||||
|
const msg = await dbUtil.getMsgByShortId(payload.message_id);
|
||||||
|
if (!msg) {
|
||||||
|
throw new Error('msg not found');
|
||||||
|
}
|
||||||
|
if (!payload.emoji_id){
|
||||||
|
throw new Error('emojiId not found');
|
||||||
|
}
|
||||||
|
return await NTQQMsgApi.setEmojiLike({
|
||||||
|
chatType: msg.chatType,
|
||||||
|
peerUid: msg.peerUid
|
||||||
|
}, msg.msgSeq, payload.emoji_id, true);
|
||||||
|
}
|
||||||
|
}
|
@ -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,7 @@ export enum ActionName {
|
|||||||
GetRecord = 'get_record',
|
GetRecord = 'get_record',
|
||||||
CleanCache = 'clean_cache',
|
CleanCache = 'clean_cache',
|
||||||
GetCookies = "get_cookies",
|
GetCookies = "get_cookies",
|
||||||
|
|
||||||
// 以下为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',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import fastXmlParser, { XMLParser } from 'fast-xml-parser';
|
||||||
import {
|
import {
|
||||||
OB11Group,
|
OB11Group,
|
||||||
OB11GroupMember,
|
OB11GroupMember,
|
||||||
@ -42,6 +43,7 @@ import { ob11Config } from '@/onebot11/config';
|
|||||||
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/common/data';
|
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/common/data';
|
||||||
import { NTQQFileApi, NTQQGroupApi, NTQQUserApi } from '../core/src/apis';
|
import { NTQQFileApi, NTQQGroupApi, NTQQUserApi } from '../core/src/apis';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
|
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
||||||
|
|
||||||
|
|
||||||
export class OB11Constructor {
|
export class OB11Constructor {
|
||||||
@ -320,6 +322,38 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (grayTipElement) {
|
if (grayTipElement) {
|
||||||
|
const xmlElement = grayTipElement.xmlElement;
|
||||||
|
|
||||||
|
if (xmlElement?.templId === '10382') {
|
||||||
|
// 表情回应消息
|
||||||
|
// "content":
|
||||||
|
// "<gtip align=\"center\">
|
||||||
|
// <qq uin=\"u_snYxnEfja-Po_\" col=\"3\" jp=\"3794\"/>
|
||||||
|
// <nor txt=\"回应了你的\"/>
|
||||||
|
// <url jp= \"\" msgseq=\"74711\" col=\"3\" txt=\"消息:\"/>
|
||||||
|
// <face type=\"1\" id=\"76\"> </face>
|
||||||
|
// </gtip>",
|
||||||
|
const emojiLikeData = new fastXmlParser.XMLParser({
|
||||||
|
ignoreAttributes: false,
|
||||||
|
attributeNamePrefix: ''
|
||||||
|
}).parse(xmlElement.content);
|
||||||
|
logDebug('收到表情回应我的消息', emojiLikeData);
|
||||||
|
try {
|
||||||
|
const senderUin = emojiLikeData.gtip.qq.jp;
|
||||||
|
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
||||||
|
const emojiId = emojiLikeData.gtip.face.id;
|
||||||
|
const replyMsg = await dbUtil.getMsgBySeq(msg.peerUid, msgSeq);
|
||||||
|
if (!replyMsg) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return new OB11GroupMsgEmojiLikeEvent(parseInt(msg.peerUid), parseInt(senderUin), replyMsg.id!, [{
|
||||||
|
emoji_id: emojiId,
|
||||||
|
count: 1
|
||||||
|
}]);
|
||||||
|
} catch (e: any) {
|
||||||
|
logError('解析表情回应消息失败', e.stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER) {
|
if (grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER) {
|
||||||
logDebug('收到新人被邀请进群消息', grayTipElement);
|
logDebug('收到新人被邀请进群消息', grayTipElement);
|
||||||
const xmlElement = grayTipElement.xmlElement;
|
const xmlElement = grayTipElement.xmlElement;
|
||||||
|
21
src/onebot11/event/notice/OB11MsgEmojiLikeEvent.ts
Normal file
21
src/onebot11/event/notice/OB11MsgEmojiLikeEvent.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
|
||||||
|
|
||||||
|
export interface MsgEmojiLike {
|
||||||
|
emoji_id: string,
|
||||||
|
count: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export class OB11GroupMsgEmojiLikeEvent extends OB11GroupNoticeEvent {
|
||||||
|
notice_type = "group_msg_emoji_like";
|
||||||
|
message_id: number;
|
||||||
|
sub_type: "ban" | "lift_ban";
|
||||||
|
likes: MsgEmojiLike[]
|
||||||
|
|
||||||
|
constructor(groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[]) {
|
||||||
|
super();
|
||||||
|
this.group_id = groupId;
|
||||||
|
this.user_id = userId; // 可为空,表示是对别人的消息操作,如果是对bot自己的消息则不为空
|
||||||
|
this.message_id = messageId;
|
||||||
|
this.likes = likes;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user