refactor: action folder

feat: group card event
feat: group title event
This commit is contained in:
linyuchen 2024-03-23 00:00:43 +08:00
parent baf35d5496
commit 983d2462d4
49 changed files with 337 additions and 251 deletions

View File

@ -6,7 +6,7 @@ import path from "node:path";
import {selfInfo} from "./data";
import {DATA_DIR} from "./utils";
export const HOOK_LOG = false;
export const HOOK_LOG = true;
export const ALLOW_SEND_TEMP_MSG = false;

View File

@ -2,6 +2,7 @@ import {callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod} from "../nt
import {SelfInfo, User} from "../types";
import {ReceiveCmdS} from "../hook";
import {uidMaps} from "../../common/data";
import {NTQQWindowApi, NTQQWindows} from "./window";
export class NTQQUserApi{
@ -53,4 +54,50 @@ export class NTQQUserApi{
return info
}
static async getPSkey() {
return await callNTQQApi<string>({
className: NTQQApiClass.GROUP_HOME_WORK,
methodName: NTQQApiMethod.UPDATE_SKEY,
args: [
{
domain: "qun.qq.com"
}
]
})
}
static async getSkey(groupName: string, groupCode: string): Promise<{data: string}> {
return await NTQQWindowApi.openWindow<{data: string}>(NTQQWindows.GroupHomeWorkWindow, [{
groupName,
groupCode,
"source": "funcbar"
}], ReceiveCmdS.SKEY_UPDATE, 1);
// return await callNTQQApi<string>({
// className: NTQQApiClass.GROUP_HOME_WORK,
// methodName: NTQQApiMethod.UPDATE_SKEY,
// args: [
// {
// domain: "qun.qq.com"
// }
// ]
// })
// return await callNTQQApi<GeneralCallResult>({
// methodName: NTQQApiMethod.GET_SKEY,
// args: [
// {
// "domains": [
// "qzone.qq.com",
// "qlive.qq.com",
// "qun.qq.com",
// "gamecenter.qq.com",
// "vip.qq.com",
// "qianbao.qq.com",
// "qidian.qq.com"
// ],
// "isForNewPCQQ": false
// },
// null
// ]
// })
}
}

View File

@ -1,7 +1,6 @@
import {net, session} from "electron";
import {NTQQApi} from "../ntcall";
import {groups} from "../../common/data";
import {log} from "../../common/utils";
import {NTQQUserApi} from "./user";
export class WebApi{
private static bkn: string;
@ -43,9 +42,9 @@ export class WebApi{
private async init(){
if (!WebApi.bkn) {
const group = groups[0];
WebApi.skey = (await NTQQApi.getSkey(group.groupName, group.groupCode)).data;
WebApi.skey = (await NTQQUserApi.getSkey(group.groupName, group.groupCode)).data;
WebApi.bkn = this.genBkn(WebApi.skey);
let cookie = await NTQQApi.getPSkey();
let cookie = await NTQQUserApi.getPSkey();
const pskeyRegex = /p_skey=([^;]+)/;
const match = cookie.match(pskeyRegex);
const pskeyValue = match ? match[1] : null;

View File

@ -1,7 +1,7 @@
import {BrowserWindow} from 'electron';
import {NTQQApiClass} from "./ntcall";
import {NTQQMsgApi, sendMessagePool} from "./api/msg"
import {ChatType, Group, RawMessage, User} from "./types";
import {ChatType, Group, GroupMember, RawMessage, User} from "./types";
import {friends, groups, selfInfo, tempGroupCodeMap, uidMaps} from "../common/data";
import {OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
import {v4 as uuidv4} from "uuid"
@ -12,6 +12,7 @@ import {dbUtil} from "../common/db";
import {NTQQGroupApi} from "./api/group";
import {log} from "../common/utils/log";
import {sleep} from "../common/utils/helper";
import {OB11GroupCardEvent} from "../onebot11/event/notice/OB11GroupCardEvent";
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
@ -25,6 +26,7 @@ export let ReceiveCmdS = {
USER_DETAIL_INFO: "nodeIKernelProfileListener/onProfileDetailInfoChanged",
GROUPS: "nodeIKernelGroupListener/onGroupListUpdate",
GROUPS_UNIX: "onGroupListUpdate",
GROUP_MEMBER_INFO_UPDATE: "nodeIKernelGroupListener/onMemberInfoChange",
FRIENDS: "onBuddyListChange",
MEDIA_DOWNLOAD_COMPLETE: "nodeIKernelMsgListener/onRichMediaDownloadComplete",
UNREAD_GROUP_NOTIFY: "nodeIKernelGroupListener/onGroupNotifiesUnreadCountUpdated",
@ -192,7 +194,7 @@ export function removeReceiveHook(id: string) {
let activatedGroups: string[] = [];
async function updateGroups(_groups: Group[], needUpdate: boolean = true) {
for (let group of _groups) {
// log("update group", group)
log("update group", group)
if (!activatedGroups.includes(group.groupCode)) {
NTQQMsgApi.activateGroupChat(group.groupCode).then((r) => {
activatedGroups.push(group.groupCode);
@ -221,12 +223,13 @@ async function updateGroups(_groups: Group[], needUpdate: boolean = true) {
}
}
async function processGroupEvent(payload) {
async function processGroupEvent(payload: {groupList: Group[]}) {
try {
const newGroupList = payload.groupList;
for (const group of newGroupList) {
let existGroup = groups.find(g => g.groupCode == group.groupCode);
if (existGroup) {
if (existGroup.memberCount > group.memberCount) {
const oldMembers = existGroup.members;
@ -242,39 +245,50 @@ async function processGroupEvent(payload) {
for (const member of oldMembers) {
if (!newMembersSet.has(member.uin)) {
postOB11Event(new OB11GroupDecreaseEvent(group.groupCode, parseInt(member.uin)));
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin)));
break;
}
}
}
}
}
updateGroups(newGroupList, false).then();
} catch (e) {
updateGroups(payload.groupList).then();
console.log(e);
log("更新群信息错误", e.stack.toString());
}
}
// 群列表变动
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS, (payload) => {
registerReceiveHook<{ groupList: Group[], updateType: number }>([ReceiveCmdS.GROUPS, ReceiveCmdS.GROUPS_UNIX], (payload) => {
log("群列表变动", payload)
if (payload.updateType != 2) {
updateGroups(payload.groupList).then();
} else {
if (process.platform == "win32") {
processGroupEvent(payload).then();
}
processGroupEvent(payload).then();
}
})
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS_UNIX, (payload) => {
if (payload.updateType != 2) {
updateGroups(payload.groupList).then();
} else {
if (process.platform != "win32") {
processGroupEvent(payload).then();
}
}
registerReceiveHook<{groupCode: string, dataSource: number, members: Set<GroupMember>}>(ReceiveCmdS.GROUP_MEMBER_INFO_UPDATE, (payload) => {
const groupCode = payload.groupCode;
const members = Array.from(payload.members.values());
// log("群成员变动", groupCode, payload.members.keys(), payload.members.values())
// const existGroup = groups.find(g => g.groupCode == groupCode);
// if (existGroup) {
// log("对比群成员", existGroup.members, members)
// for (const member of members) {
// const existMember = existGroup.members.find(m => m.uin == member.uin);
// if (existMember) {
// log("对比群名片", existMember.cardName, member.cardName)
// if (existMember.cardName != member.cardName) {
// postOB11Event(new OB11GroupCardEvent(parseInt(existGroup.groupCode), parseInt(member.uin), member.cardName, existMember.cardName));
// }
// Object.assign(existMember, member);
// }
// }
// }
})
// 好友列表变动

View File

@ -186,59 +186,4 @@ export class NTQQApi {
]
})
}
static async getSkey(groupName: string, groupCode: string): Promise<{data: string}> {
return await NTQQWindowApi.openWindow<{data: string}>(NTQQWindows.GroupHomeWorkWindow, [{
groupName,
groupCode,
"source": "funcbar"
}], ReceiveCmdS.SKEY_UPDATE, 1);
// return await callNTQQApi<string>({
// className: NTQQApiClass.GROUP_HOME_WORK,
// methodName: NTQQApiMethod.UPDATE_SKEY,
// args: [
// {
// domain: "qun.qq.com"
// }
// ]
// })
// return await callNTQQApi<GeneralCallResult>({
// methodName: NTQQApiMethod.GET_SKEY,
// args: [
// {
// "domains": [
// "qzone.qq.com",
// "qlive.qq.com",
// "qun.qq.com",
// "gamecenter.qq.com",
// "vip.qq.com",
// "qianbao.qq.com",
// "qidian.qq.com"
// ],
// "isForNewPCQQ": false
// },
// null
// ]
// })
}
static async getPSkey() {
return await callNTQQApi<string>({
className: NTQQApiClass.GROUP_HOME_WORK,
methodName: NTQQApiMethod.UPDATE_SKEY,
args: [
{
domain: "qun.qq.com"
}
]
})
}
static async addGroupDigest(groupCode: string, msgSeq: string) {
return await new WebApi().addGroupDigest(groupCode, msgSeq);
}
static async getGroupDigest(groupCode: string) {
return await new WebApi().getGroupDigest(groupCode);
}
}

View File

@ -180,6 +180,7 @@ export interface PicElement {
export enum GrayTipElementSubType {
INVITE_NEW_MEMBER = 12,
MEMBER_NEW_TITLE = 17
}
export interface GrayTipElement {
@ -196,6 +197,9 @@ export interface GrayTipElement {
groupElement: TipGroupElement,
xmlElement: {
content: string;
},
jsonGrayTipElement:{
jsonStr: string;
}
}

View File

@ -1,5 +1,5 @@
import {ActionName, BaseCheckResult} from "./types"
import {OB11Response} from "./utils"
import {OB11Response} from "./OB11Response"
import {OB11Return} from "../types";
import {log} from "../../common/utils/log";

View File

@ -1,10 +1,11 @@
import BaseAction from "./BaseAction";
import BaseAction from "../BaseAction";
import fs from "fs/promises";
import {dbUtil} from "../../common/db";
import {getConfigUtil} from "../../common/config";
import {log, sleep, uri2local} from "../../common/utils";
import {NTQQFileApi} from "../../ntqqapi/api/file";
import {ActionName} from "./types";
import {dbUtil} from "../../../common/db";
import {getConfigUtil} from "../../../common/config";
import {log, sleep, uri2local} from "../../../common/utils";
import {NTQQFileApi} from "../../../ntqqapi/api/file";
import {ActionName} from "../types";
import {FileElement, RawMessage, VideoElement} from "../../../ntqqapi/types";
export interface GetFilePayload {
file: string // 文件名或者fileUuid
@ -20,6 +21,14 @@ export interface GetFileResponse {
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
private getElement(msg: RawMessage): {id: string, element: VideoElement | FileElement}{
let element = msg.elements.find(e=>e.fileElement)
if (!element){
element = msg.elements.find(e=>e.videoElement)
return {id: element.elementId, element: element.videoElement}
}
return {id: element.elementId, element: element.fileElement}
}
protected async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
const cache = await dbUtil.getFileCache(payload.file)
const {autoDeleteFile, enableLocalFile2Url, autoDeleteFileSecond} = getConfigUtil().getConfig()
@ -49,18 +58,17 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
let msg = await dbUtil.getMsgByLongId(cache.msgId)
if (msg){
log("找到了文件 msg", msg)
const element = msg.elements.find(e=>e.fileElement)
let element = this.getElement(msg);
log("找到了文件 element", element);
// 构建下载函数
await NTQQFileApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid,
element.elementId, "", "", true)
element.id, "", "", true)
await sleep(1000);
msg = await dbUtil.getMsgByLongId(cache.msgId)
log("下载完成后的msg", msg)
cache.filePath = msg?.elements.find(e=>e.fileElement)?.fileElement?.filePath
cache.filePath = this.getElement(msg).element.filePath
dbUtil.addFileCache(payload.file, cache).then()
}
}
}

View File

@ -1,5 +1,5 @@
import {GetFileBase} from "./GetFile";
import {ActionName} from "./types";
import {ActionName} from "../types";
export default class GetImage extends GetFileBase {

View File

@ -1,5 +1,5 @@
import {GetFileBase, GetFilePayload, GetFileResponse} from "./GetFile";
import {ActionName} from "./types";
import {ActionName} from "../types";
interface Payload extends GetFilePayload {
out_format: 'mp3' | 'amr' | 'wma' | 'm4a' | 'spx' | 'ogg' | 'wav' | 'flac'

View File

@ -1,4 +1,4 @@
import SendMsg from "../SendMsg";
import SendMsg from "../msg/SendMsg";
import {OB11PostSendMsg} from "../../types";
import {ActionName} from "../types";

View File

@ -1,8 +1,8 @@
import {OB11Group} from '../types';
import {getGroup} from "../../common/data";
import {OB11Constructor} from "../constructor";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {OB11Group} from '../../types';
import {getGroup} from "../../../common/data";
import {OB11Constructor} from "../../constructor";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
interface PayloadType {
group_id: number

View File

@ -1,8 +1,8 @@
import {OB11Group} from '../types';
import {OB11Constructor} from "../constructor";
import {groups} from "../../common/data";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {OB11Group} from '../../types';
import {OB11Constructor} from "../../constructor";
import {groups} from "../../../common/data";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
class GetGroupList extends BaseAction<null, OB11Group[]> {

View File

@ -1,11 +1,11 @@
import {OB11GroupMember} from '../types';
import {getGroupMember} from "../../common/data";
import {OB11Constructor} from "../constructor";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {NTQQUserApi} from "../../ntqqapi/api/user";
import {log} from "../../common/utils/log";
import {isNull} from "../../common/utils/helper";
import {OB11GroupMember} from '../../types';
import {getGroupMember} from "../../../common/data";
import {OB11Constructor} from "../../constructor";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQUserApi} from "../../../ntqqapi/api/user";
import {log} from "../../../common/utils/log";
import {isNull} from "../../../common/utils/helper";
export interface PayloadType {

View File

@ -1,9 +1,9 @@
import {OB11GroupMember} from '../types';
import {getGroup} from "../../common/data";
import {OB11Constructor} from "../constructor";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import {OB11GroupMember} from '../../types';
import {getGroup} from "../../../common/data";
import {OB11Constructor} from "../../constructor";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
export interface PayloadType {
group_id: number

View File

@ -1,5 +1,5 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
export default class GetGuildList extends BaseAction<null, null> {
actionName = ActionName.GetGuildList

View File

@ -1,8 +1,8 @@
import SendMsg from "./SendMsg";
import {ActionName, BaseCheckResult} from "./types";
import {OB11PostSendMsg} from "../types";
import SendMsg from "../msg/SendMsg";
import {ActionName, BaseCheckResult} from "../types";
import {OB11PostSendMsg} from "../../types";
import {log} from "../../common/utils/log";
import {log} from "../../../common/utils/log";
class SendGroupMsg extends SendMsg {

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {GroupRequestOperateTypes} from "../../ntqqapi/types";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {GroupRequestOperateTypes} from "../../../ntqqapi/types";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
flag: string,

View File

@ -1,8 +1,8 @@
import BaseAction from "./BaseAction";
import {getGroupMember} from "../../common/data";
import {GroupMemberRole} from "../../ntqqapi/types";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {getGroupMember} from "../../../common/data";
import {GroupMemberRole} from "../../../ntqqapi/types";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
group_id: number,

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {getGroupMember} from "../../common/data";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {getGroupMember} from "../../../common/data";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
group_id: number,

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {getGroupMember} from "../../common/data";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {getGroupMember} from "../../../common/data";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
group_id: number,

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {getGroupMember} from "../../common/data";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {getGroupMember} from "../../../common/data";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
group_id: number,

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import {log} from "../../common/utils/log";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
import {log} from "../../../common/utils/log";
interface Payload {
group_id: number,

View File

@ -1,6 +1,6 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
group_id: number,

View File

@ -1,6 +1,6 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {NTQQGroupApi} from "../../ntqqapi/api/group";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api/group";
interface Payload {
group_id: number,

View File

@ -1,44 +1,44 @@
import GetMsg from './GetMsg'
import GetLoginInfo from './GetLoginInfo'
import GetFriendList from './GetFriendList'
import GetGroupList from './GetGroupList'
import GetGroupInfo from './GetGroupInfo'
import GetGroupMemberList from './GetGroupMemberList'
import GetGroupMemberInfo from './GetGroupMemberInfo'
import SendGroupMsg from './SendGroupMsg'
import SendPrivateMsg from './SendPrivateMsg'
import SendMsg from './SendMsg'
import DeleteMsg from "./DeleteMsg";
import GetMsg from './msg/GetMsg'
import GetLoginInfo from './system/GetLoginInfo'
import GetFriendList from './user/GetFriendList'
import GetGroupList from './group/GetGroupList'
import GetGroupInfo from './group/GetGroupInfo'
import GetGroupMemberList from './group/GetGroupMemberList'
import GetGroupMemberInfo from './group/GetGroupMemberInfo'
import SendGroupMsg from './group/SendGroupMsg'
import SendPrivateMsg from './msg/SendPrivateMsg'
import SendMsg from './msg/SendMsg'
import DeleteMsg from "./msg/DeleteMsg";
import BaseAction from "./BaseAction";
import GetVersionInfo from "./GetVersionInfo";
import CanSendRecord from "./CanSendRecord";
import CanSendImage from "./CanSendImage";
import GetStatus from "./GetStatus";
import GetVersionInfo from "./system/GetVersionInfo";
import CanSendRecord from "./system/CanSendRecord";
import CanSendImage from "./system/CanSendImage";
import GetStatus from "./system/GetStatus";
import {GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg";
import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo";
import SendLike from "./SendLike";
import SetGroupAddRequest from "./SetGroupAddRequest";
import SetGroupLeave from "./SetGroupLeave";
import GetGuildList from "./GetGuildList";
import SendLike from "./user/SendLike";
import SetGroupAddRequest from "./group/SetGroupAddRequest";
import SetGroupLeave from "./group/SetGroupLeave";
import GetGuildList from "./group/GetGuildList";
import Debug from "./llonebot/Debug";
import SetFriendAddRequest from "./SetFriendAddRequest";
import SetGroupWholeBan from "./SetGroupWholeBan";
import SetGroupName from "./SetGroupName";
import SetGroupBan from "./SetGroupBan";
import SetGroupKick from "./SetGroupKick";
import SetGroupAdmin from "./SetGroupAdmin";
import SetGroupCard from "./SetGroupCard";
import GetImage from "./GetImage";
import GetRecord from "./GetRecord";
import GoCQHTTPMarkMsgAsRead from "./MarkMsgAsRead";
import CleanCache from "./CleanCache";
import SetFriendAddRequest from "./user/SetFriendAddRequest";
import SetGroupWholeBan from "./group/SetGroupWholeBan";
import SetGroupName from "./group/SetGroupName";
import SetGroupBan from "./group/SetGroupBan";
import SetGroupKick from "./group/SetGroupKick";
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 CleanCache from "./system/CleanCache";
import GoCQHTTPUploadGroupFile from "./go-cqhttp/UploadGroupFile";
import {GetConfigAction, SetConfigAction} from "./llonebot/Config";
import GetGroupAddRequest from "./llonebot/GetGroupAddRequest";
import SetQQAvatar from './llonebot/SetQQAvatar'
import GoCQHTTPDownloadFile from "./go-cqhttp/DownloadFile";
import GoCQHTTPGetGroupMsgHistory from "./go-cqhttp/GetGroupMsgHistory";
import GetFile from "./GetFile";
import GetFile from "./file/GetFile";
export const actionHandlers = [
new GetFile(),

View File

@ -1,7 +1,7 @@
import {ActionName} from "./types";
import BaseAction from "./BaseAction";
import {dbUtil} from "../../common/db";
import {NTQQMsgApi} from "../../ntqqapi/api/msg";
import {ActionName} from "../types";
import BaseAction from "../BaseAction";
import {dbUtil} from "../../../common/db";
import {NTQQMsgApi} from "../../../ntqqapi/api/msg";
interface Payload {
message_id: number

View File

@ -1,8 +1,8 @@
import {OB11Message} from '../types';
import {OB11Constructor} from "../constructor";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {dbUtil} from "../../common/db";
import {OB11Message} from '../../types';
import {OB11Constructor} from "../../constructor";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {dbUtil} from "../../../common/db";
export interface PayloadType {

View File

@ -1,5 +1,5 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
interface Payload{
message_id: number

View File

@ -6,7 +6,7 @@ import {
RawMessage,
SendArkElement,
SendMessageElement
} from "../../ntqqapi/types";
} from "../../../ntqqapi/types";
import {
friends,
getFriend,
@ -14,7 +14,7 @@ import {
getGroupMember,
getUidByUin,
selfInfo,
} from "../../common/data";
} from "../../../common/data";
import {
OB11MessageCustomMusic,
OB11MessageData,
@ -22,19 +22,19 @@ import {
OB11MessageMixType,
OB11MessageNode,
OB11PostSendMsg
} from '../types';
import {Peer} from "../../ntqqapi/api/msg";
import {SendMsgElementConstructor} from "../../ntqqapi/constructor";
import BaseAction from "./BaseAction";
import {ActionName, BaseCheckResult} from "./types";
} from '../../types';
import {Peer} from "../../../ntqqapi/api/msg";
import {SendMsgElementConstructor} from "../../../ntqqapi/constructor";
import BaseAction from "../BaseAction";
import {ActionName, BaseCheckResult} from "../types";
import * as fs from "node:fs";
import {decodeCQCode} from "../cqcode";
import {dbUtil} from "../../common/db";
import {ALLOW_SEND_TEMP_MSG} from "../../common/config";
import {NTQQMsgApi} from "../../ntqqapi/api/msg";
import {log} from "../../common/utils/log";
import {sleep} from "../../common/utils/helper";
import {uri2local} from "../../common/utils";
import {decodeCQCode} from "../../cqcode";
import {dbUtil} from "../../../common/db";
import {ALLOW_SEND_TEMP_MSG} from "../../../common/config";
import {NTQQMsgApi} from "../../../ntqqapi/api/msg";
import {log} from "../../../common/utils/log";
import {sleep} from "../../../common/utils/helper";
import {uri2local} from "../../../common/utils";
function checkSendMessage(sendMsgList: OB11MessageData[]) {
function checkUri(uri: string): boolean {

View File

@ -1,6 +1,6 @@
import SendMsg from "./SendMsg";
import {ActionName, BaseCheckResult} from "./types";
import {OB11PostSendMsg} from "../types";
import {ActionName, BaseCheckResult} from "../types";
import {OB11PostSendMsg} from "../../types";
class SendPrivateMsg extends SendMsg {
actionName = ActionName.SendPrivateMsg

View File

@ -1,4 +1,4 @@
import {ActionName} from "./types";
import {ActionName} from "../types";
import CanSendRecord from "./CanSendRecord";
interface ReturnType {

View File

@ -1,5 +1,5 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
interface ReturnType {
yes: boolean

View File

@ -1,14 +1,14 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import fs from "fs";
import Path from "path";
import {
ChatType,
ChatCacheListItemBasic,
CacheFileType
} from '../../ntqqapi/types';
import {dbUtil} from "../../common/db";
import {NTQQFileApi, NTQQFileCacheApi} from "../../ntqqapi/api/file";
} from '../../../ntqqapi/types';
import {dbUtil} from "../../../common/db";
import {NTQQFileApi, NTQQFileCacheApi} from "../../../ntqqapi/api/file";
export default class CleanCache extends BaseAction<void, void> {
actionName = ActionName.CleanCache

View File

@ -1,8 +1,8 @@
import {OB11User} from '../types';
import {OB11Constructor} from "../constructor";
import {selfInfo} from "../../common/data";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {OB11User} from '../../types';
import {OB11Constructor} from "../../constructor";
import {selfInfo} from "../../../common/data";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
class GetLoginInfo extends BaseAction<null, OB11User> {

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {OB11Status} from "../types";
import {ActionName} from "./types";
import {selfInfo} from "../../common/data";
import BaseAction from "../BaseAction";
import {OB11Status} from "../../types";
import {ActionName} from "../types";
import {selfInfo} from "../../../common/data";
export default class GetStatus extends BaseAction<any, OB11Status> {

View File

@ -1,7 +1,7 @@
import BaseAction from "./BaseAction";
import {OB11Version} from "../types";
import {ActionName} from "./types";
import {version} from "../../version";
import BaseAction from "../BaseAction";
import {OB11Version} from "../../types";
import {ActionName} from "../types";
import {version} from "../../../version";
export default class GetVersionInfo extends BaseAction<any, OB11Version> {
actionName = ActionName.GetVersionInfo

View File

@ -1,8 +1,8 @@
import {OB11User} from '../types';
import {OB11Constructor} from "../constructor";
import {friends} from "../../common/data";
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {OB11User} from '../../types';
import {OB11Constructor} from "../../constructor";
import {friends} from "../../../common/data";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
class GetFriendList extends BaseAction<null, OB11User[]> {

View File

@ -1,8 +1,8 @@
import BaseAction from "./BaseAction";
import {getFriend, getUidByUin, uidMaps} from "../../common/data";
import {ActionName} from "./types";
import {NTQQFriendApi} from "../../ntqqapi/api/friend";
import {log} from "../../common/utils/log";
import BaseAction from "../BaseAction";
import {getFriend, getUidByUin, uidMaps} from "../../../common/data";
import {ActionName} from "../types";
import {NTQQFriendApi} from "../../../ntqqapi/api/friend";
import {log} from "../../../common/utils/log";
interface Payload {
user_id: number,

View File

@ -1,6 +1,6 @@
import BaseAction from "./BaseAction";
import {ActionName} from "./types";
import {NTQQFriendApi} from "../../ntqqapi/api/friend";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQFriendApi} from "../../../ntqqapi/api/friend";
interface Payload {
flag: string,

View File

@ -35,6 +35,8 @@ import {calcQQLevel} from "../common/utils/qqlevel";
import {log} from "../common/utils/log";
import {sleep} from "../common/utils/helper";
import {getConfigUtil} from "../common/config";
import {OB11GroupTitleEvent} from "./event/notice/OB11GroupTitleEvent";
import {OB11GroupCardEvent} from "./event/notice/OB11GroupCardEvent";
export class OB11Constructor {
@ -159,9 +161,10 @@ export class OB11Constructor {
message_data["type"] = OB11MessageDataType.video;
message_data["data"]["file"] = element.videoElement.fileName
message_data["data"]["path"] = element.videoElement.filePath
// message_data["data"]["file_id"] = element.videoElement.fileUuid
message_data["data"]["file_id"] = element.videoElement.fileUuid
message_data["data"]["file_size"] = element.videoElement.fileSize
dbUtil.addFileCache(element.videoElement.fileName, {
dbUtil.addFileCache(element.videoElement.fileUuid, {
msgId: msg.msgId,
fileName: element.videoElement.fileName,
filePath: element.videoElement.filePath,
fileSize: element.videoElement.fileSize,
@ -231,6 +234,12 @@ export class OB11Constructor {
if (msg.chatType !== ChatType.group) {
return;
}
if (msg.senderUin){
const member = await getGroupMember(msg.peerUid, msg.senderUin);
if (member && member.cardName !== msg.sendMemberName) {
return new OB11GroupCardEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), msg.sendMemberName, member.cardName)
}
}
// log("group msg", msg);
for (let element of msg.elements) {
const grayTipElement = element.grayTipElement
@ -300,6 +309,36 @@ export class OB11Constructor {
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(invitee), parseInt(inviter), "invite");
}
}
} else if (grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr)
/*
{
align: 'center',
items: [
{ txt: '恭喜', type: 'nor' },
{
col: '3',
jp: '5',
param: ["QQ号"],
txt: '林雨辰',
type: 'url'
},
{ txt: '获得群主授予的', type: 'nor' },
{
col: '3',
jp: '',
txt: '好好好',
type: 'url'
},
{ txt: '头衔', type: 'nor' }
]
}
* */
const memberUin = json.items[1].param[0]
const title = json.items[3].txt
log("收到群成员新头衔消息", json)
return new OB11GroupTitleEvent(parseInt(msg.peerUid), parseInt(memberUin), title)
}
}
}

View File

@ -0,0 +1,16 @@
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
export class OB11GroupCardEvent extends OB11GroupNoticeEvent {
notice_type = "group_card";
card_new: string;
card_old: string;
constructor(groupId: number, userId: number, cardNew: string, cardOld: string) {
super();
this.group_id = groupId;
this.user_id = userId;
this.card_new = cardNew;
this.card_old = cardOld;
}
}

View File

@ -0,0 +1,15 @@
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
export class OB11GroupTitleEvent extends OB11GroupNoticeEvent {
notice_type = "notify";
sub_type = "title";
title: string
constructor(groupId: number, userId: number, title: string) {
super();
this.group_id = groupId;
this.user_id = userId;
this.title = title;
}
}

View File

@ -7,7 +7,6 @@ class OB11PokeEvent extends OB11BaseNoticeEvent{
sub_type = "poke"
target_id = parseInt(selfInfo.uin)
user_id: number
}
export class OB11FriendPokeEvent extends OB11PokeEvent{

View File

@ -1,5 +1,5 @@
import {Response} from "express";
import {OB11Response} from "../action/utils";
import {OB11Response} from "../action/OB11Response";
import {HttpServerBase} from "../../common/server/http";
import {actionHandlers} from "../action";
import {getConfigUtil} from "../../common/config";

View File

@ -1,7 +1,7 @@
import {selfInfo} from "../../../common/data";
import {LifeCycleSubType, OB11LifeCycleEvent} from "../../event/meta/OB11LifeCycleEvent";
import {ActionName} from "../../action/types";
import {OB11Response} from "../../action/utils";
import {OB11Response} from "../../action/OB11Response";
import BaseAction from "../../action/BaseAction";
import {actionMap} from "../../action";
import {postWsEvent, registerWsEventSender, unregisterWsEventSender} from "../postOB11Event";

View File

@ -1,6 +1,6 @@
import {WebSocket} from "ws";
import {actionMap} from "../../action";
import {OB11Response} from "../../action/utils";
import {OB11Response} from "../../action/OB11Response";
import {postWsEvent, registerWsEventSender, unregisterWsEventSender} from "../postOB11Event";
import {ActionName} from "../../action/types";
import BaseAction from "../../action/BaseAction";

View File

@ -1,5 +1,5 @@
import {WebSocket as WebSocketClass} from "ws";
import {OB11Response} from "../../action/utils";
import {OB11Response} from "../../action/OB11Response";
import {PostEventType} from "../postOB11Event";
import {log} from "../../../common/utils/log";
import {isNull} from "../../../common/utils/helper";