mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ecd64529a4 | ||
![]() |
016482c9e5 | ||
![]() |
23be081d29 | ||
![]() |
33688e9e5c | ||
![]() |
de8c2e1168 | ||
![]() |
2a1fc07b94 | ||
![]() |
c1b6daaf32 | ||
![]() |
02c973fe5e | ||
![]() |
d6b44053de | ||
![]() |
1d69764952 | ||
![]() |
d9377e4684 | ||
![]() |
f30dd81455 | ||
![]() |
0116f8d384 | ||
![]() |
88d68f4360 | ||
![]() |
ea0f5a9f80 | ||
![]() |
4591c1b659 | ||
![]() |
97a424f62e | ||
![]() |
410ef5a050 | ||
![]() |
128091dff9 | ||
![]() |
c7b6fd89fd | ||
![]() |
b55f35549d | ||
![]() |
ca0a6cfb22 | ||
![]() |
3303b30c4c | ||
![]() |
429d8deb5c | ||
![]() |
48f12fc30b | ||
![]() |
41f0e8f574 | ||
![]() |
cd50df3a56 | ||
![]() |
4461c7ed47 | ||
![]() |
e5f4992eb3 | ||
![]() |
468f1710b9 | ||
![]() |
626d445dc3 | ||
![]() |
b413a224be | ||
![]() |
6542f2e63b | ||
![]() |
94c928905e | ||
![]() |
c14f8b21c2 |
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 4,
|
"manifest_version": 4,
|
||||||
"type": "extension",
|
"type": "extension",
|
||||||
"name": "LLOneBot v3.19.1",
|
"name": "LLOneBot v3.20.5",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "LiteLoaderQQNT的OneBotApi,不支持商店在线更新",
|
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
||||||
"version": "3.19.1",
|
"version": "3.20.5",
|
||||||
"icon": "./icon.jpg",
|
"icon": "./icon.jpg",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@@ -14,7 +14,7 @@
|
|||||||
"file-type": "^19.0.0",
|
"file-type": "^19.0.0",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
"level": "^8.0.1",
|
"level": "^8.0.1",
|
||||||
"silk-wasm": "^3.3.3",
|
"silk-wasm": "^3.3.4",
|
||||||
"utf-8-validate": "^6.0.3",
|
"utf-8-validate": "^6.0.3",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"ws": "^8.16.0"
|
"ws": "^8.16.0"
|
||||||
@@ -5895,9 +5895,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/silk-wasm": {
|
"node_modules/silk-wasm": {
|
||||||
"version": "3.3.3",
|
"version": "3.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/silk-wasm/-/silk-wasm-3.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/silk-wasm/-/silk-wasm-3.3.4.tgz",
|
||||||
"integrity": "sha512-9Qj93EtiIuBNkDyEwlPntabEtrm6Xu6LE4y9qZvomvo5+IsXFcXSy+N55kV22OehUTBYlZqOZYtRggA8G9IDGg=="
|
"integrity": "sha512-cvjp9Zw50uPB46EfifHlO8gIh6buZOUKQaL+9BbPoLgH4bAp8wEEzVmPI34gIiltOUyeuEknm4DDGnE3kEEQ/A=="
|
||||||
},
|
},
|
||||||
"node_modules/slash": {
|
"node_modules/slash": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
"file-type": "^19.0.0",
|
"file-type": "^19.0.0",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
"level": "^8.0.1",
|
"level": "^8.0.1",
|
||||||
"silk-wasm": "^3.3.3",
|
"silk-wasm": "^3.3.4",
|
||||||
"utf-8-validate": "^6.0.3",
|
"utf-8-validate": "^6.0.3",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"ws": "^8.16.0"
|
"ws": "^8.16.0"
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import fsPromise from "fs/promises";
|
||||||
import {Config, OB11Config} from './types';
|
import {Config, OB11Config} from './types';
|
||||||
|
|
||||||
import {mergeNewProperties} from "./utils/helper";
|
import {mergeNewProperties} from "./utils/helper";
|
||||||
@@ -76,7 +77,7 @@ export class ConfigUtil {
|
|||||||
|
|
||||||
setConfig(config: Config) {
|
setConfig(config: Config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2), "utf-8")
|
fsPromise.writeFile(this.configPath, JSON.stringify(config, null, 2), "utf-8").then()
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkOldConfig(currentConfig: Config | OB11Config,
|
private checkOldConfig(currentConfig: Config | OB11Config,
|
||||||
|
@@ -94,9 +94,9 @@ export async function refreshGroupMembers(groupQQ: string) {
|
|||||||
export const uidMaps: Record<string, string> = {} // 一串加密的字符串(uid) -> qq号
|
export const uidMaps: Record<string, string> = {} // 一串加密的字符串(uid) -> qq号
|
||||||
|
|
||||||
export function getUidByUin(uin: string) {
|
export function getUidByUin(uin: string) {
|
||||||
for (const key in uidMaps) {
|
for (const uid in uidMaps) {
|
||||||
if (uidMaps[key] === uin) {
|
if (uidMaps[uid] === uin) {
|
||||||
return key
|
return uid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ export interface CheckVersion {
|
|||||||
version: string
|
version: string
|
||||||
}
|
}
|
||||||
export interface Config {
|
export interface Config {
|
||||||
|
imageRKey?: string;
|
||||||
ob11: OB11Config
|
ob11: OB11Config
|
||||||
token?: string
|
token?: string
|
||||||
heartInterval?: number // ms
|
heartInterval?: number // ms
|
||||||
|
@@ -4,28 +4,36 @@ import {BrowserWindow, dialog, ipcMain} from 'electron';
|
|||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import {Config} from "../common/types";
|
import {Config} from "../common/types";
|
||||||
import {
|
import {
|
||||||
|
CHANNEL_CHECK_VERSION,
|
||||||
CHANNEL_ERROR,
|
CHANNEL_ERROR,
|
||||||
CHANNEL_GET_CONFIG,
|
CHANNEL_GET_CONFIG,
|
||||||
CHANNEL_LOG,
|
CHANNEL_LOG,
|
||||||
CHANNEL_CHECK_VERSION,
|
|
||||||
CHANNEL_SELECT_FILE,
|
CHANNEL_SELECT_FILE,
|
||||||
CHANNEL_SET_CONFIG,
|
CHANNEL_SET_CONFIG,
|
||||||
CHANNEL_UPDATE,
|
CHANNEL_UPDATE,
|
||||||
} from "../common/channels";
|
} from "../common/channels";
|
||||||
import {ob11WebsocketServer} from "../onebot11/server/ws/WebsocketServer";
|
import {ob11WebsocketServer} from "../onebot11/server/ws/WebsocketServer";
|
||||||
import {DATA_DIR, wrapText} from "../common/utils";
|
import {DATA_DIR} from "../common/utils";
|
||||||
import {
|
import {
|
||||||
friendRequests,
|
friendRequests,
|
||||||
getFriend,
|
getFriend,
|
||||||
getGroup,
|
getGroup,
|
||||||
getGroupMember,
|
getGroupMember, groups,
|
||||||
llonebotError,
|
llonebotError,
|
||||||
refreshGroupMembers,
|
refreshGroupMembers,
|
||||||
selfInfo, uidMaps
|
selfInfo,
|
||||||
|
uidMaps
|
||||||
} from "../common/data";
|
} from "../common/data";
|
||||||
import {hookNTQQApiCall, hookNTQQApiReceive, ReceiveCmdS, registerReceiveHook} from "../ntqqapi/hook";
|
import {hookNTQQApiCall, hookNTQQApiReceive, ReceiveCmdS, registerReceiveHook} from "../ntqqapi/hook";
|
||||||
import {OB11Constructor} from "../onebot11/constructor";
|
import {OB11Constructor} from "../onebot11/constructor";
|
||||||
import {ChatType, FriendRequestNotify, GroupNotifies, GroupNotifyTypes, RawMessage} from "../ntqqapi/types";
|
import {
|
||||||
|
ChatType,
|
||||||
|
FriendRequestNotify,
|
||||||
|
GroupMemberRole,
|
||||||
|
GroupNotifies,
|
||||||
|
GroupNotifyTypes,
|
||||||
|
RawMessage
|
||||||
|
} from "../ntqqapi/types";
|
||||||
import {ob11HTTPServer} from "../onebot11/server/http";
|
import {ob11HTTPServer} from "../onebot11/server/http";
|
||||||
import {OB11FriendRecallNoticeEvent} from "../onebot11/event/notice/OB11FriendRecallNoticeEvent";
|
import {OB11FriendRecallNoticeEvent} from "../onebot11/event/notice/OB11FriendRecallNoticeEvent";
|
||||||
import {OB11GroupRecallNoticeEvent} from "../onebot11/event/notice/OB11GroupRecallNoticeEvent";
|
import {OB11GroupRecallNoticeEvent} from "../onebot11/event/notice/OB11GroupRecallNoticeEvent";
|
||||||
@@ -45,7 +53,7 @@ import {checkNewVersion, upgradeLLOneBot} from "../common/utils/upgrade";
|
|||||||
import {log} from "../common/utils/log";
|
import {log} from "../common/utils/log";
|
||||||
import {getConfigUtil} from "../common/config";
|
import {getConfigUtil} from "../common/config";
|
||||||
import {checkFfmpeg} from "../common/utils/video";
|
import {checkFfmpeg} from "../common/utils/video";
|
||||||
|
import {GroupDecreaseSubType, OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
|
||||||
|
|
||||||
let running = false;
|
let running = false;
|
||||||
|
|
||||||
@@ -55,7 +63,6 @@ let mainWindow: BrowserWindow | null = null;
|
|||||||
function onLoad() {
|
function onLoad() {
|
||||||
log("llonebot main onLoad");
|
log("llonebot main onLoad");
|
||||||
ipcMain.handle(CHANNEL_CHECK_VERSION, async (event, arg) => {
|
ipcMain.handle(CHANNEL_CHECK_VERSION, async (event, arg) => {
|
||||||
|
|
||||||
return checkNewVersion();
|
return checkNewVersion();
|
||||||
});
|
});
|
||||||
ipcMain.handle(CHANNEL_UPDATE, async (event, arg) => {
|
ipcMain.handle(CHANNEL_UPDATE, async (event, arg) => {
|
||||||
@@ -107,8 +114,8 @@ function onLoad() {
|
|||||||
const config = getConfigUtil().getConfig()
|
const config = getConfigUtil().getConfig()
|
||||||
return config;
|
return config;
|
||||||
})
|
})
|
||||||
ipcMain.on(CHANNEL_SET_CONFIG, (event, ask:boolean, config: Config) => {
|
ipcMain.on(CHANNEL_SET_CONFIG, (event, ask: boolean, config: Config) => {
|
||||||
if (!ask){
|
if (!ask) {
|
||||||
setConfig(config).then();
|
setConfig(config).then();
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -285,15 +292,28 @@ function onLoad() {
|
|||||||
log("变动管理员获取成功")
|
log("变动管理员获取成功")
|
||||||
groupAdminNoticeEvent.user_id = parseInt(member1.uin);
|
groupAdminNoticeEvent.user_id = parseInt(member1.uin);
|
||||||
groupAdminNoticeEvent.sub_type = notify.type == GroupNotifyTypes.ADMIN_UNSET ? "unset" : "set";
|
groupAdminNoticeEvent.sub_type = notify.type == GroupNotifyTypes.ADMIN_UNSET ? "unset" : "set";
|
||||||
|
// member1.role = notify.type == GroupNotifyTypes.ADMIN_SET ? GroupMemberRole.admin : GroupMemberRole.normal;
|
||||||
postOB11Event(groupAdminNoticeEvent, true);
|
postOB11Event(groupAdminNoticeEvent, true);
|
||||||
} else {
|
} else {
|
||||||
log("获取群通知的成员信息失败", notify, getGroup(notify.group.groupCode));
|
log("获取群通知的成员信息失败", notify, getGroup(notify.group.groupCode));
|
||||||
}
|
}
|
||||||
} else if (notify.type == GroupNotifyTypes.MEMBER_EXIT) {
|
} else if (notify.type == GroupNotifyTypes.MEMBER_EXIT || notify.type == GroupNotifyTypes.KICK_MEMBER) {
|
||||||
// log("有成员退出通知");
|
log("有成员退出通知", notify);
|
||||||
// const member1 = await getGroupMember(notify.group.groupCode, null, notify.user1.uid);
|
try {
|
||||||
// let groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(notify.group.groupCode), parseInt(member1.uin))
|
const member1 = await NTQQUserApi.getUserDetailInfo(notify.user1.uid);
|
||||||
// postEvent(groupDecreaseEvent, true);
|
let operatorId = member1.uin;
|
||||||
|
let subType: GroupDecreaseSubType = "leave";
|
||||||
|
if (notify.user2.uid) {
|
||||||
|
// 是被踢的
|
||||||
|
const member2 = await getGroupMember(notify.group.groupCode, notify.user2.uid);
|
||||||
|
operatorId = member2.uin;
|
||||||
|
subType = "kick";
|
||||||
|
}
|
||||||
|
let groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(notify.group.groupCode), parseInt(member1.uin), parseInt(operatorId), subType)
|
||||||
|
postOB11Event(groupDecreaseEvent, true);
|
||||||
|
} catch (e) {
|
||||||
|
log("获取群通知的成员信息失败", notify, e.stack.toString())
|
||||||
|
}
|
||||||
} else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
} else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
||||||
log("有加群请求");
|
log("有加群请求");
|
||||||
let groupRequestEvent = new OB11GroupRequestEvent();
|
let groupRequestEvent = new OB11GroupRequestEvent();
|
||||||
@@ -334,8 +354,9 @@ function onLoad() {
|
|||||||
|
|
||||||
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
|
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
|
||||||
for (const req of payload.data.buddyReqs) {
|
for (const req of payload.data.buddyReqs) {
|
||||||
if (req.isUnread && !friendRequests[req.sourceId] && (parseInt(req.reqTime) > startTime / 1000)) {
|
let flag = req.friendUid + req.reqTime;
|
||||||
friendRequests[req.sourceId] = req;
|
if (req.isUnread && (parseInt(req.reqTime) > startTime / 1000)) {
|
||||||
|
friendRequests[flag] = req;
|
||||||
log("有新的好友请求", req);
|
log("有新的好友请求", req);
|
||||||
let friendRequestEvent = new OB11FriendRequestEvent();
|
let friendRequestEvent = new OB11FriendRequestEvent();
|
||||||
try {
|
try {
|
||||||
@@ -344,7 +365,7 @@ function onLoad() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("获取加好友者QQ号失败", e);
|
log("获取加好友者QQ号失败", e);
|
||||||
}
|
}
|
||||||
friendRequestEvent.flag = req.sourceId.toString();
|
friendRequestEvent.flag = flag;
|
||||||
friendRequestEvent.comment = req.extWords;
|
friendRequestEvent.comment = req.extWords;
|
||||||
postOB11Event(friendRequestEvent);
|
postOB11Event(friendRequestEvent);
|
||||||
}
|
}
|
||||||
@@ -358,7 +379,7 @@ function onLoad() {
|
|||||||
log("llonebot pid", process.pid)
|
log("llonebot pid", process.pid)
|
||||||
llonebotError.otherError = "";
|
llonebotError.otherError = "";
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
dbUtil.getReceivedTempUinMap().then(m=>{
|
dbUtil.getReceivedTempUinMap().then(m => {
|
||||||
for (const [key, value] of Object.entries(m)) {
|
for (const [key, value] of Object.entries(m)) {
|
||||||
uidMaps[value] = key;
|
uidMaps[value] = key;
|
||||||
}
|
}
|
||||||
@@ -389,13 +410,15 @@ function onLoad() {
|
|||||||
selfInfo.nick = selfInfo.uin;
|
selfInfo.nick = selfInfo.uin;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("retry get self info", e);
|
log("retry get self info", e);
|
||||||
|
}
|
||||||
|
if (!selfInfo.uin) {
|
||||||
selfInfo.uin = globalThis.authData?.uin;
|
selfInfo.uin = globalThis.authData?.uin;
|
||||||
selfInfo.uid = globalThis.authData?.uid;
|
selfInfo.uid = globalThis.authData?.uid;
|
||||||
selfInfo.nick = selfInfo.uin;
|
selfInfo.nick = selfInfo.uin;
|
||||||
}
|
}
|
||||||
log("self info", selfInfo, globalThis.authData);
|
log("self info", selfInfo, globalThis.authData);
|
||||||
if (selfInfo.uin) {
|
if (selfInfo.uin) {
|
||||||
async function getUserNick(){
|
async function getUserNick() {
|
||||||
try {
|
try {
|
||||||
getSelfNickCount++;
|
getSelfNickCount++;
|
||||||
const userInfo = (await NTQQUserApi.getUserDetailInfo(selfInfo.uid));
|
const userInfo = (await NTQQUserApi.getUserDetailInfo(selfInfo.uid));
|
||||||
@@ -411,6 +434,7 @@ function onLoad() {
|
|||||||
return setTimeout(getUserNick, 1000);
|
return setTimeout(getUserNick, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserNick().then()
|
getUserNick().then()
|
||||||
start().then();
|
start().then();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -47,7 +47,7 @@ export class NTQQFileApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 上传文件到QQ的文件夹
|
// 上传文件到QQ的文件夹
|
||||||
static async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC) {
|
static async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC, elementSubType: number = 0) {
|
||||||
const md5 = await NTQQFileApi.getFileMd5(filePath);
|
const md5 = await NTQQFileApi.getFileMd5(filePath);
|
||||||
let ext = (await NTQQFileApi.getFileType(filePath))?.ext
|
let ext = (await NTQQFileApi.getFileType(filePath))?.ext
|
||||||
if (ext) {
|
if (ext) {
|
||||||
@@ -66,7 +66,7 @@ export class NTQQFileApi {
|
|||||||
md5HexStr: md5,
|
md5HexStr: md5,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
elementType: elementType,
|
elementType: elementType,
|
||||||
elementSubType: 0,
|
elementSubType,
|
||||||
thumbSize: 0,
|
thumbSize: 0,
|
||||||
needCreate: true,
|
needCreate: true,
|
||||||
downloadType: 1,
|
downloadType: 1,
|
||||||
@@ -81,7 +81,8 @@ export class NTQQFileApi {
|
|||||||
md5,
|
md5,
|
||||||
fileName,
|
fileName,
|
||||||
path: mediaPath,
|
path: mediaPath,
|
||||||
fileSize
|
fileSize,
|
||||||
|
ext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,10 +37,10 @@ export class NTQQFriendApi{
|
|||||||
}, null]
|
}, null]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
static async handleFriendRequest(sourceId: number, accept: boolean,) {
|
static async handleFriendRequest(flag: string, accept: boolean,) {
|
||||||
const request: FriendRequest = friendRequests[sourceId]
|
const request: FriendRequest = friendRequests[flag]
|
||||||
if (!request) {
|
if (!request) {
|
||||||
throw `sourceId ${sourceId}, 对应的好友请求不存在`
|
throw `flat: ${flag}, 对应的好友请求不存在`
|
||||||
}
|
}
|
||||||
const result = await callNTQQApi<GeneralCallResult>({
|
const result = await callNTQQApi<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST,
|
methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST,
|
||||||
@@ -54,7 +54,7 @@ export class NTQQFriendApi{
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
delete friendRequests[sourceId];
|
delete friendRequests[flag];
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ export class NTQQGroupApi{
|
|||||||
static async getGroups(forced = false) {
|
static async getGroups(forced = false) {
|
||||||
let cbCmd = ReceiveCmdS.GROUPS
|
let cbCmd = ReceiveCmdS.GROUPS
|
||||||
if (process.platform != "win32") {
|
if (process.platform != "win32") {
|
||||||
cbCmd = ReceiveCmdS.GROUPS_UNIX
|
cbCmd = ReceiveCmdS.GROUPS_STORE
|
||||||
}
|
}
|
||||||
const result = await callNTQQApi<{
|
const result = await callNTQQApi<{
|
||||||
updateType: number,
|
updateType: number,
|
||||||
|
@@ -16,6 +16,17 @@ export interface Peer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQMsgApi {
|
export class NTQQMsgApi {
|
||||||
|
static async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) {
|
||||||
|
return await callNTQQApi<GeneralCallResult & {msgList: RawMessage[]}>({
|
||||||
|
methodName: NTQQApiMethod.GET_MULTI_MSG,
|
||||||
|
args: [{
|
||||||
|
peer,
|
||||||
|
rootMsgId,
|
||||||
|
parentMsgId
|
||||||
|
}, null]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
static async activateGroupChat(groupCode: string) {
|
static async activateGroupChat(groupCode: string) {
|
||||||
// await this.fetchRecentContact();
|
// await this.fetchRecentContact();
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
|
@@ -3,7 +3,9 @@ import {SelfInfo, User} from "../types";
|
|||||||
import {ReceiveCmdS} from "../hook";
|
import {ReceiveCmdS} from "../hook";
|
||||||
import {uidMaps} from "../../common/data";
|
import {uidMaps} from "../../common/data";
|
||||||
import {NTQQWindowApi, NTQQWindows} from "./window";
|
import {NTQQWindowApi, NTQQWindows} from "./window";
|
||||||
|
import {isQQ998, sleep} from "../../common/utils";
|
||||||
|
|
||||||
|
let userInfoCache: Record<string, User> = {}; // uid: User
|
||||||
|
|
||||||
export class NTQQUserApi{
|
export class NTQQUserApi{
|
||||||
static async setQQAvatar(filePath: string) {
|
static async setQQAvatar(filePath: string) {
|
||||||
@@ -30,28 +32,40 @@ export class NTQQUserApi{
|
|||||||
})
|
})
|
||||||
return result.profiles.get(uid)
|
return result.profiles.get(uid)
|
||||||
}
|
}
|
||||||
static async getUserDetailInfo(uid: string) {
|
static async getUserDetailInfo(uid: string, getLevel=false) {
|
||||||
const result = await callNTQQApi<{ info: User }>({
|
// this.getUserInfo(uid);
|
||||||
methodName: NTQQApiMethod.USER_DETAIL_INFO,
|
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
|
||||||
cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
|
const fetchInfo = async ()=>{
|
||||||
afterFirstCmd: false,
|
const result = await callNTQQApi<{ info: User }>({
|
||||||
cmdCB: (payload) => {
|
methodName,
|
||||||
const success = payload.info.uid == uid
|
cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
|
||||||
// log("get user detail info", success, uid, payload)
|
afterFirstCmd: false,
|
||||||
return success
|
cmdCB: (payload) => {
|
||||||
},
|
const success = payload.info.uid == uid
|
||||||
args: [
|
// log("get user detail info", success, uid, payload)
|
||||||
{
|
return success
|
||||||
uid
|
|
||||||
},
|
},
|
||||||
null
|
args: [
|
||||||
]
|
{
|
||||||
})
|
uid
|
||||||
const info = result.info
|
},
|
||||||
if (info?.uin) {
|
null
|
||||||
uidMaps[info.uid] = info.uin
|
]
|
||||||
|
})
|
||||||
|
const info = result.info
|
||||||
|
if (info?.uin) {
|
||||||
|
uidMaps[info.uid] = info.uin
|
||||||
|
}
|
||||||
|
return info
|
||||||
}
|
}
|
||||||
return info
|
// 首次请求两次才能拿到的等级信息
|
||||||
|
if (!userInfoCache[uid] && getLevel) {
|
||||||
|
await fetchInfo()
|
||||||
|
await sleep(1000);
|
||||||
|
}
|
||||||
|
let userInfo = await fetchInfo()
|
||||||
|
userInfoCache[uid] = userInfo
|
||||||
|
return userInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getPSkey() {
|
static async getPSkey() {
|
||||||
|
@@ -62,32 +62,32 @@ export class SendMsgElementConstructor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async pic(picPath: string, summary: string = ""): Promise<SendPicElement> {
|
static async pic(picPath: string, summary: string = "", subType: 0|1=0): Promise<SendPicElement> {
|
||||||
const {md5, fileName, path, fileSize} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC);
|
const {md5, fileName, path, fileSize} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC, subType);
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
throw "文件异常,大小为0";
|
throw "文件异常,大小为0";
|
||||||
}
|
}
|
||||||
const imageSize = await NTQQFileApi.getImageSize(picPath);
|
const imageSize = await NTQQFileApi.getImageSize(picPath);
|
||||||
const picElement = {
|
const picElement = {
|
||||||
md5HexStr: md5,
|
md5HexStr: md5,
|
||||||
fileSize: fileSize,
|
fileSize: fileSize.toString(),
|
||||||
picWidth: imageSize.width,
|
picWidth: imageSize.width,
|
||||||
picHeight: imageSize.height,
|
picHeight: imageSize.height,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
sourcePath: path,
|
sourcePath: path,
|
||||||
original: true,
|
original: true,
|
||||||
picType: isGIF(picPath) ? PicType.gif : PicType.jpg,
|
picType: isGIF(picPath) ? PicType.gif : PicType.jpg,
|
||||||
picSubType: 0,
|
picSubType: subType,
|
||||||
fileUuid: "",
|
fileUuid: "",
|
||||||
fileSubId: "",
|
fileSubId: "",
|
||||||
thumbFileSize: 0,
|
thumbFileSize: 0,
|
||||||
summary,
|
summary
|
||||||
};
|
};
|
||||||
|
log("图片信息", picElement)
|
||||||
return {
|
return {
|
||||||
elementType: ElementType.PIC,
|
elementType: ElementType.PIC,
|
||||||
elementId: "",
|
elementId: "",
|
||||||
picElement
|
picElement,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ export class SendMsgElementConstructor {
|
|||||||
let thumb = path.replace(`${pathLib.sep}Ori${pathLib.sep}`, `${pathLib.sep}Thumb${pathLib.sep}`)
|
let thumb = path.replace(`${pathLib.sep}Ori${pathLib.sep}`, `${pathLib.sep}Thumb${pathLib.sep}`)
|
||||||
thumb = pathLib.dirname(thumb)
|
thumb = pathLib.dirname(thumb)
|
||||||
// log("thumb 目录", thumb)
|
// log("thumb 目录", thumb)
|
||||||
let videoInfo ={
|
let videoInfo = {
|
||||||
width: 1920, height: 1080,
|
width: 1920, height: 1080,
|
||||||
time: 15,
|
time: 15,
|
||||||
format: "mp4",
|
format: "mp4",
|
||||||
@@ -128,7 +128,7 @@ export class SendMsgElementConstructor {
|
|||||||
try {
|
try {
|
||||||
videoInfo = await getVideoInfo(path);
|
videoInfo = await getVideoInfo(path);
|
||||||
log("视频信息", videoInfo)
|
log("视频信息", videoInfo)
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
log("获取视频信息失败", e)
|
log("获取视频信息失败", e)
|
||||||
}
|
}
|
||||||
const createThumb = new Promise<string>((resolve, reject) => {
|
const createThumb = new Promise<string>((resolve, reject) => {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import {BrowserWindow} from 'electron';
|
import {BrowserWindow} from 'electron';
|
||||||
import {NTQQApiClass} from "./ntcall";
|
import {NTQQApiClass} from "./ntcall";
|
||||||
import {NTQQMsgApi, sendMessagePool} from "./api/msg"
|
import {NTQQMsgApi, sendMessagePool} from "./api/msg"
|
||||||
import {ChatType, Group, GroupMember, RawMessage, User} from "./types";
|
import {ChatType, Group, GroupMember, GroupMemberRole, RawMessage, User} from "./types";
|
||||||
import {friends, groups, selfInfo, tempGroupCodeMap, uidMaps} from "../common/data";
|
import {friends, getGroupMember, groups, selfInfo, tempGroupCodeMap, uidMaps} from "../common/data";
|
||||||
import {OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
|
import {OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
|
||||||
import {v4 as uuidv4} from "uuid"
|
import {v4 as uuidv4} from "uuid"
|
||||||
import {postOB11Event} from "../onebot11/server/postOB11Event";
|
import {postOB11Event} from "../onebot11/server/postOB11Event";
|
||||||
@@ -12,7 +12,6 @@ import {dbUtil} from "../common/db";
|
|||||||
import {NTQQGroupApi} from "./api/group";
|
import {NTQQGroupApi} from "./api/group";
|
||||||
import {log} from "../common/utils/log";
|
import {log} from "../common/utils/log";
|
||||||
import {sleep} from "../common/utils/helper";
|
import {sleep} from "../common/utils/helper";
|
||||||
import {OB11GroupCardEvent} from "../onebot11/event/notice/OB11GroupCardEvent";
|
|
||||||
|
|
||||||
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ export let ReceiveCmdS = {
|
|||||||
USER_INFO: "nodeIKernelProfileListener/onProfileSimpleChanged",
|
USER_INFO: "nodeIKernelProfileListener/onProfileSimpleChanged",
|
||||||
USER_DETAIL_INFO: "nodeIKernelProfileListener/onProfileDetailInfoChanged",
|
USER_DETAIL_INFO: "nodeIKernelProfileListener/onProfileDetailInfoChanged",
|
||||||
GROUPS: "nodeIKernelGroupListener/onGroupListUpdate",
|
GROUPS: "nodeIKernelGroupListener/onGroupListUpdate",
|
||||||
GROUPS_UNIX: "onGroupListUpdate",
|
GROUPS_STORE: "onGroupListUpdate",
|
||||||
GROUP_MEMBER_INFO_UPDATE: "nodeIKernelGroupListener/onMemberInfoChange",
|
GROUP_MEMBER_INFO_UPDATE: "nodeIKernelGroupListener/onMemberInfoChange",
|
||||||
FRIENDS: "onBuddyListChange",
|
FRIENDS: "onBuddyListChange",
|
||||||
MEDIA_DOWNLOAD_COMPLETE: "nodeIKernelMsgListener/onRichMediaDownloadComplete",
|
MEDIA_DOWNLOAD_COMPLETE: "nodeIKernelMsgListener/onRichMediaDownloadComplete",
|
||||||
@@ -229,7 +228,6 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
|
|||||||
for (const group of newGroupList) {
|
for (const group of newGroupList) {
|
||||||
let existGroup = groups.find(g => g.groupCode == group.groupCode);
|
let existGroup = groups.find(g => g.groupCode == group.groupCode);
|
||||||
if (existGroup) {
|
if (existGroup) {
|
||||||
|
|
||||||
if (existGroup.memberCount > group.memberCount) {
|
if (existGroup.memberCount > group.memberCount) {
|
||||||
log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
|
log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
|
||||||
const oldMembers = existGroup.members;
|
const oldMembers = existGroup.members;
|
||||||
@@ -244,9 +242,14 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
|
|||||||
newMembersSet.add(member.uin);
|
newMembersSet.add(member.uin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
||||||
|
let bot = await getGroupMember(group.groupCode, selfInfo.uin)
|
||||||
|
if (bot.role == GroupMemberRole.admin || bot.role == GroupMemberRole.owner) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for (const member of oldMembers) {
|
for (const member of oldMembers) {
|
||||||
if (!newMembersSet.has(member.uin)) {
|
if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
||||||
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin)));
|
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), "leave"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,19 +266,39 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 群列表变动
|
// 群列表变动
|
||||||
registerReceiveHook<{ groupList: Group[], updateType: number }>(process.platform == "win32" ? ReceiveCmdS.GROUPS : ReceiveCmdS.GROUPS_UNIX, (payload) => {
|
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS, (payload) => {
|
||||||
log("群列表变动", payload)
|
// updateType 3是群列表变动,2是群成员变动
|
||||||
|
// log("群列表变动", payload.updateType, payload.groupList)
|
||||||
if (payload.updateType != 2) {
|
if (payload.updateType != 2) {
|
||||||
updateGroups(payload.groupList).then();
|
updateGroups(payload.groupList).then();
|
||||||
} else {
|
} else {
|
||||||
processGroupEvent(payload).then();
|
if (process.platform == "win32") {
|
||||||
|
processGroupEvent(payload).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS_STORE, (payload) => {
|
||||||
|
// updateType 3是群列表变动,2是群成员变动
|
||||||
|
// log("群列表变动", payload.updateType, payload.groupList)
|
||||||
|
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) => {
|
registerReceiveHook<{groupCode: string, dataSource: number, members: Set<GroupMember>}>(ReceiveCmdS.GROUP_MEMBER_INFO_UPDATE, async (payload) => {
|
||||||
const groupCode = payload.groupCode;
|
const groupCode = payload.groupCode;
|
||||||
const members = Array.from(payload.members.values());
|
const members = Array.from(payload.members.values());
|
||||||
// log("群成员变动", groupCode, payload.members.keys(), payload.members.values())
|
// log("群成员信息变动", groupCode, members)
|
||||||
|
for(const member of members) {
|
||||||
|
const existMember = await getGroupMember(groupCode, member.uin);
|
||||||
|
if (existMember){
|
||||||
|
Object.assign(existMember, member);
|
||||||
|
}
|
||||||
|
}
|
||||||
// const existGroup = groups.find(g => g.groupCode == groupCode);
|
// const existGroup = groups.find(g => g.groupCode == groupCode);
|
||||||
// if (existGroup) {
|
// if (existGroup) {
|
||||||
// log("对比群成员", existGroup.members, members)
|
// log("对比群成员", existGroup.members, members)
|
||||||
|
@@ -25,6 +25,8 @@ export enum NTQQApiMethod {
|
|||||||
ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息
|
ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息
|
||||||
HISTORY_MSG_998 = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
|
HISTORY_MSG_998 = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
|
||||||
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelf",
|
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelf",
|
||||||
|
GET_MULTI_MSG = "nodeIKernelMsgService/getMultiMsg",
|
||||||
|
|
||||||
LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike",
|
LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike",
|
||||||
SELF_INFO = "fetchAuthData",
|
SELF_INFO = "fetchAuthData",
|
||||||
FRIENDS = "nodeIKernelBuddyService/getBuddyList",
|
FRIENDS = "nodeIKernelBuddyService/getBuddyList",
|
||||||
@@ -33,6 +35,7 @@ export enum NTQQApiMethod {
|
|||||||
GROUP_MEMBERS = "nodeIKernelGroupService/getNextMemberList",
|
GROUP_MEMBERS = "nodeIKernelGroupService/getNextMemberList",
|
||||||
USER_INFO = "nodeIKernelProfileService/getUserSimpleInfo",
|
USER_INFO = "nodeIKernelProfileService/getUserSimpleInfo",
|
||||||
USER_DETAIL_INFO = "nodeIKernelProfileService/getUserDetailInfo",
|
USER_DETAIL_INFO = "nodeIKernelProfileService/getUserDetailInfo",
|
||||||
|
USER_DETAIL_INFO_WITH_BIZ_INFO = "nodeIKernelProfileService/getUserDetailInfoWithBizInfo",
|
||||||
FILE_TYPE = "getFileType",
|
FILE_TYPE = "getFileType",
|
||||||
FILE_MD5 = "getFileMd5",
|
FILE_MD5 = "getFileMd5",
|
||||||
FILE_COPY = "copyFile",
|
FILE_COPY = "copyFile",
|
||||||
@@ -162,7 +165,12 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
|
|
||||||
ipcMain.emit(
|
ipcMain.emit(
|
||||||
channel,
|
channel,
|
||||||
{},
|
{
|
||||||
|
sender: {
|
||||||
|
send: (..._args: unknown[]) => {
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{type: 'request', callbackId: uuid, eventName},
|
{type: 'request', callbackId: uuid, eventName},
|
||||||
apiArgs
|
apiArgs
|
||||||
)
|
)
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import {GroupMemberRole} from "./group";
|
import {GroupMemberRole} from "./group";
|
||||||
|
import exp from "constants";
|
||||||
|
|
||||||
export enum ElementType {
|
export enum ElementType {
|
||||||
TEXT = 1,
|
TEXT = 1,
|
||||||
@@ -48,24 +49,29 @@ export enum PicType {
|
|||||||
jpg = 1000
|
jpg = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum PicSubType {
|
||||||
|
normal = 0, // 普通图片,大图
|
||||||
|
face = 1 // 表情包小图
|
||||||
|
}
|
||||||
|
|
||||||
export interface SendPicElement {
|
export interface SendPicElement {
|
||||||
elementType: ElementType.PIC,
|
elementType: ElementType.PIC,
|
||||||
elementId: "",
|
elementId: "",
|
||||||
picElement: {
|
picElement: {
|
||||||
md5HexStr: string,
|
md5HexStr: string,
|
||||||
fileSize: number,
|
fileSize: number | string,
|
||||||
picWidth: number,
|
picWidth: number,
|
||||||
picHeight: number,
|
picHeight: number,
|
||||||
fileName: string,
|
fileName: string,
|
||||||
sourcePath: string,
|
sourcePath: string,
|
||||||
original: boolean,
|
original: boolean,
|
||||||
picType: PicType,
|
picType: PicType,
|
||||||
picSubType: number,
|
picSubType: PicSubType,
|
||||||
fileUuid: string,
|
fileUuid: string,
|
||||||
fileSubId: string,
|
fileSubId: string,
|
||||||
thumbFileSize: number,
|
thumbFileSize: number,
|
||||||
summary: string,
|
summary: string,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SendReplyElement {
|
export interface SendReplyElement {
|
||||||
@@ -166,9 +172,11 @@ export interface ArkElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const IMAGE_HTTP_HOST = "https://gchat.qpic.cn"
|
export const IMAGE_HTTP_HOST = "https://gchat.qpic.cn"
|
||||||
|
export const IMAGE_HTTP_HOST_NT = "https://multimedia.nt.qq.com.cn"
|
||||||
|
|
||||||
export interface PicElement {
|
export interface PicElement {
|
||||||
originImageUrl: string; // http url, 没有host,host是https://gchat.qpic.cn/
|
originImageUrl: string; // http url, 没有host,host是https://gchat.qpic.cn/, 带download参数的是https://multimedia.nt.qq.com.cn
|
||||||
|
originImageMd5?: string;
|
||||||
sourcePath: string; // 图片本地路径
|
sourcePath: string; // 图片本地路径
|
||||||
thumbPath: Map<number, string>;
|
thumbPath: Map<number, string>;
|
||||||
picWidth: number;
|
picWidth: number;
|
||||||
@@ -199,7 +207,7 @@ export interface GrayTipElement {
|
|||||||
xmlElement: {
|
xmlElement: {
|
||||||
content: string;
|
content: string;
|
||||||
},
|
},
|
||||||
jsonGrayTipElement:{
|
jsonGrayTipElement: {
|
||||||
jsonStr: string;
|
jsonStr: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,6 +217,45 @@ export interface FaceElement {
|
|||||||
faceType: 1
|
faceType: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MarketFaceElement {
|
||||||
|
"itemType": 6,
|
||||||
|
"faceInfo": 1,
|
||||||
|
"emojiPackageId": 203875,
|
||||||
|
"subType": 3,
|
||||||
|
"mediaType": 0,
|
||||||
|
"imageWidth": 200,
|
||||||
|
"imageHeight": 200,
|
||||||
|
"faceName": string,
|
||||||
|
"emojiId": "094d53bd1c9ac5d35d04b08e8a6c992c",
|
||||||
|
"key": "a8b1dd0aebc8d910",
|
||||||
|
"param": null,
|
||||||
|
"mobileParam": null,
|
||||||
|
"sourceType": null,
|
||||||
|
"startTime": null,
|
||||||
|
"endTime": null,
|
||||||
|
"emojiType": 1,
|
||||||
|
"hasIpProduct": null,
|
||||||
|
"voiceItemHeightArr": null,
|
||||||
|
"sourceName": null,
|
||||||
|
"sourceJumpUrl": null,
|
||||||
|
"sourceTypeName": null,
|
||||||
|
"backColor": null,
|
||||||
|
"volumeColor": null,
|
||||||
|
"staticFacePath": "E:\\SystemDocuments\\QQ\\721011692\\nt_qq\\nt_data\\Emoji\\marketface\\203875\\094d53bd1c9ac5d35d04b08e8a6c992c_aio.png",
|
||||||
|
"dynamicFacePath": "E:\\SystemDocuments\\QQ\\721011692\\nt_qq\\nt_data\\Emoji\\marketface\\203875\\094d53bd1c9ac5d35d04b08e8a6c992c",
|
||||||
|
"supportSize": [
|
||||||
|
{
|
||||||
|
"width": 300,
|
||||||
|
"height": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"width": 200,
|
||||||
|
"height": 200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"apngSupportSize": null
|
||||||
|
}
|
||||||
|
|
||||||
export interface VideoElement {
|
export interface VideoElement {
|
||||||
"filePath": string,
|
"filePath": string,
|
||||||
"fileName": string,
|
"fileName": string,
|
||||||
@@ -234,6 +281,34 @@ export interface VideoElement {
|
|||||||
"sourceVideoCodecFormat"?: number
|
"sourceVideoCodecFormat"?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MarkdownElement {
|
||||||
|
content: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InlineKeyboardElementRowButton{
|
||||||
|
"id": "",
|
||||||
|
"label": string,
|
||||||
|
"visitedLabel": string,
|
||||||
|
"style": 1, // 未知
|
||||||
|
"type": 2, // 未知
|
||||||
|
"clickLimit": 0, // 未知
|
||||||
|
"unsupportTips": "请升级新版手机QQ",
|
||||||
|
"data": string,
|
||||||
|
"atBotShowChannelList": false,
|
||||||
|
"permissionType": 2,
|
||||||
|
"specifyRoleIds": [],
|
||||||
|
"specifyTinyids": [],
|
||||||
|
"isReply": false,
|
||||||
|
"anchor": 0,
|
||||||
|
"enter": false,
|
||||||
|
"subscribeDataTemplateIds": []
|
||||||
|
}
|
||||||
|
export interface InlineKeyboardElement {
|
||||||
|
rows: [{
|
||||||
|
buttons: InlineKeyboardElementRowButton[]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
export interface TipAioOpGrayTipElement { // 这是什么提示来着?
|
export interface TipAioOpGrayTipElement { // 这是什么提示来着?
|
||||||
operateType: number,
|
operateType: number,
|
||||||
peerUid: string,
|
peerUid: string,
|
||||||
@@ -242,6 +317,7 @@ export interface TipAioOpGrayTipElement { // 这是什么提示来着?
|
|||||||
|
|
||||||
export enum TipGroupElementType {
|
export enum TipGroupElementType {
|
||||||
memberIncrease = 1,
|
memberIncrease = 1,
|
||||||
|
kicked = 3, // 被移出群
|
||||||
ban = 8
|
ban = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +328,7 @@ export interface TipGroupElement {
|
|||||||
"memberUid": string,
|
"memberUid": string,
|
||||||
"memberNick": string,
|
"memberNick": string,
|
||||||
"memberRemark": string,
|
"memberRemark": string,
|
||||||
"adminUid": string, // 同意加群的管理员uid
|
"adminUid": string,
|
||||||
"adminNick": string,
|
"adminNick": string,
|
||||||
"adminRemark": string,
|
"adminRemark": string,
|
||||||
"createGroup": null,
|
"createGroup": null,
|
||||||
@@ -284,6 +360,11 @@ export interface TipGroupElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MultiForwardMsgElement{
|
||||||
|
xmlContent: string, // xml格式的消息内容
|
||||||
|
resId: string,
|
||||||
|
fileName: string,
|
||||||
|
}
|
||||||
|
|
||||||
export interface RawMessage {
|
export interface RawMessage {
|
||||||
msgId: string;
|
msgId: string;
|
||||||
@@ -321,5 +402,9 @@ export interface RawMessage {
|
|||||||
faceElement: FaceElement;
|
faceElement: FaceElement;
|
||||||
videoElement: VideoElement;
|
videoElement: VideoElement;
|
||||||
fileElement: FileElement;
|
fileElement: FileElement;
|
||||||
|
marketFaceElement: MarketFaceElement;
|
||||||
|
inlineKeyboardElement: InlineKeyboardElement;
|
||||||
|
markdownElement: MarkdownElement;
|
||||||
|
multiForwardMsgElement: MultiForwardMsgElement;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
@@ -4,8 +4,9 @@ export enum GroupNotifyTypes {
|
|||||||
INVITED_JOIN = 4, // 有人接受了邀请入群
|
INVITED_JOIN = 4, // 有人接受了邀请入群
|
||||||
JOIN_REQUEST = 7,
|
JOIN_REQUEST = 7,
|
||||||
ADMIN_SET = 8,
|
ADMIN_SET = 8,
|
||||||
|
KICK_MEMBER = 9,
|
||||||
|
MEMBER_EXIT = 11, // 主动退出
|
||||||
ADMIN_UNSET = 12,
|
ADMIN_UNSET = 12,
|
||||||
MEMBER_EXIT = 11, // 主动退出?
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
src/onebot11/action/go-cqhttp/GetForwardMsg.ts
Normal file
39
src/onebot11/action/go-cqhttp/GetForwardMsg.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import BaseAction from "../BaseAction";
|
||||||
|
import {OB11ForwardMessage, OB11Message, OB11MessageData} from "../../types";
|
||||||
|
import {NTQQMsgApi, Peer} from "../../../ntqqapi/api";
|
||||||
|
import {dbUtil} from "../../../common/db";
|
||||||
|
import {OB11Constructor} from "../../constructor";
|
||||||
|
import {ActionName} from "../types";
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
message_id: string; // long msg id
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Response{
|
||||||
|
messages: (OB11Message & {content: OB11MessageData})[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any>{
|
||||||
|
actionName = ActionName.GoCQHTTP_GetForwardMsg
|
||||||
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
|
const rootMsg = await dbUtil.getMsgByLongId(payload.message_id)
|
||||||
|
if (!rootMsg){
|
||||||
|
throw Error("msg not found")
|
||||||
|
}
|
||||||
|
let data = await NTQQMsgApi.getMultiMsg({chatType: rootMsg.chatType, peerUid: rootMsg.peerUid}, rootMsg.msgId, rootMsg.msgId)
|
||||||
|
if (data.result !== 0){
|
||||||
|
throw Error("找不到相关的聊天记录" + data.errMsg)
|
||||||
|
}
|
||||||
|
let msgList = data.msgList
|
||||||
|
let messages = await Promise.all(msgList.map(async msg => {
|
||||||
|
let resMsg = await OB11Constructor.message(msg)
|
||||||
|
resMsg.message_id = await dbUtil.addMsg(msg);
|
||||||
|
return resMsg
|
||||||
|
}))
|
||||||
|
messages.map(msg => {
|
||||||
|
(<OB11ForwardMessage>msg).content = msg.message;
|
||||||
|
delete msg.message;
|
||||||
|
})
|
||||||
|
return {messages}
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,6 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<{ user_id: numbe
|
|||||||
if (!uid) {
|
if (!uid) {
|
||||||
throw new Error("查无此人")
|
throw new Error("查无此人")
|
||||||
}
|
}
|
||||||
return OB11Constructor.stranger(await NTQQUserApi.getUserDetailInfo(uid))
|
return OB11Constructor.stranger(await NTQQUserApi.getUserDetailInfo(uid, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,18 +1,20 @@
|
|||||||
import SendMsg from "../msg/SendMsg";
|
import SendMsg, {convertMessage2List} from "../msg/SendMsg";
|
||||||
import {OB11PostSendMsg} from "../../types";
|
import {OB11PostSendMsg} from "../../types";
|
||||||
import {ActionName} from "../types";
|
import {ActionName} from "../types";
|
||||||
|
|
||||||
export class GoCQHTTPSendGroupForwardMsg extends SendMsg {
|
export class GoCQHTTPSendForwardMsg extends SendMsg {
|
||||||
actionName = ActionName.GoCQHTTP_SendGroupForwardMsg;
|
actionName = ActionName.GoCQHTTP_SendForwardMsg;
|
||||||
|
|
||||||
protected async check(payload: OB11PostSendMsg) {
|
protected async check(payload: OB11PostSendMsg) {
|
||||||
if (payload.messages){
|
if (payload.messages) payload.message = convertMessage2List(payload.messages);
|
||||||
payload.message = this.convertMessage2List(payload.messages);
|
|
||||||
}
|
|
||||||
return super.check(payload);
|
return super.check(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendGroupForwardMsg {
|
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsg {
|
||||||
actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
|
actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsg {
|
||||||
|
actionName = ActionName.GoCQHTTP_SendGroupForwardMsg;
|
||||||
}
|
}
|
@@ -3,12 +3,18 @@ import {OB11Constructor} from "../../constructor";
|
|||||||
import {groups} from "../../../common/data";
|
import {groups} from "../../../common/data";
|
||||||
import BaseAction from "../BaseAction";
|
import BaseAction from "../BaseAction";
|
||||||
import {ActionName} from "../types";
|
import {ActionName} from "../types";
|
||||||
|
import {NTQQGroupApi} from "../../../ntqqapi/api";
|
||||||
|
import {log} from "../../../common/utils";
|
||||||
|
|
||||||
|
|
||||||
class GetGroupList extends BaseAction<null, OB11Group[]> {
|
class GetGroupList extends BaseAction<null, OB11Group[]> {
|
||||||
actionName = ActionName.GetGroupList
|
actionName = ActionName.GetGroupList
|
||||||
|
|
||||||
protected async _handle(payload: null) {
|
protected async _handle(payload: null) {
|
||||||
|
// if (groups.length === 0) {
|
||||||
|
// const groups = await NTQQGroupApi.getGroups(true)
|
||||||
|
// log("get groups", groups)
|
||||||
|
// }
|
||||||
return OB11Constructor.groups(groups);
|
return OB11Constructor.groups(groups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
|||||||
if (member) {
|
if (member) {
|
||||||
if (isNull(member.sex)){
|
if (isNull(member.sex)){
|
||||||
log("获取群成员详细信息")
|
log("获取群成员详细信息")
|
||||||
let info = (await NTQQUserApi.getUserDetailInfo(member.uid))
|
let info = (await NTQQUserApi.getUserDetailInfo(member.uid, true))
|
||||||
log("群成员详细信息结果", info)
|
log("群成员详细信息结果", info)
|
||||||
Object.assign(member, info);
|
Object.assign(member, info);
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ import GetVersionInfo from "./system/GetVersionInfo";
|
|||||||
import CanSendRecord from "./system/CanSendRecord";
|
import CanSendRecord from "./system/CanSendRecord";
|
||||||
import CanSendImage from "./system/CanSendImage";
|
import CanSendImage from "./system/CanSendImage";
|
||||||
import GetStatus from "./system/GetStatus";
|
import GetStatus from "./system/GetStatus";
|
||||||
import {GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg";
|
import {GoCQHTTPSendForwardMsg, GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg";
|
||||||
import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo";
|
import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo";
|
||||||
import SendLike from "./user/SendLike";
|
import SendLike from "./user/SendLike";
|
||||||
import SetGroupAddRequest from "./group/SetGroupAddRequest";
|
import SetGroupAddRequest from "./group/SetGroupAddRequest";
|
||||||
@@ -39,6 +39,7 @@ import SetQQAvatar from './llonebot/SetQQAvatar'
|
|||||||
import GoCQHTTPDownloadFile from "./go-cqhttp/DownloadFile";
|
import GoCQHTTPDownloadFile from "./go-cqhttp/DownloadFile";
|
||||||
import GoCQHTTPGetGroupMsgHistory from "./go-cqhttp/GetGroupMsgHistory";
|
import GoCQHTTPGetGroupMsgHistory from "./go-cqhttp/GetGroupMsgHistory";
|
||||||
import GetFile from "./file/GetFile";
|
import GetFile from "./file/GetFile";
|
||||||
|
import {GoCQHTTGetForwardMsgAction} from "./go-cqhttp/GetForwardMsg";
|
||||||
|
|
||||||
export const actionHandlers = [
|
export const actionHandlers = [
|
||||||
new GetFile(),
|
new GetFile(),
|
||||||
@@ -73,6 +74,7 @@ export const actionHandlers = [
|
|||||||
new CleanCache(),
|
new CleanCache(),
|
||||||
|
|
||||||
//以下为go-cqhttp api
|
//以下为go-cqhttp api
|
||||||
|
new GoCQHTTPSendForwardMsg(),
|
||||||
new GoCQHTTPSendGroupForwardMsg(),
|
new GoCQHTTPSendGroupForwardMsg(),
|
||||||
new GoCQHTTPSendPrivateForwardMsg(),
|
new GoCQHTTPSendPrivateForwardMsg(),
|
||||||
new GoCQHTTPGetStrangerInfo(),
|
new GoCQHTTPGetStrangerInfo(),
|
||||||
@@ -81,6 +83,7 @@ export const actionHandlers = [
|
|||||||
new GoCQHTTPMarkMsgAsRead(),
|
new GoCQHTTPMarkMsgAsRead(),
|
||||||
new GoCQHTTPUploadGroupFile(),
|
new GoCQHTTPUploadGroupFile(),
|
||||||
new GoCQHTTPGetGroupMsgHistory(),
|
new GoCQHTTPGetGroupMsgHistory(),
|
||||||
|
new GoCQHTTGetForwardMsgAction(),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import {
|
|||||||
AtType,
|
AtType,
|
||||||
ChatType,
|
ChatType,
|
||||||
ElementType,
|
ElementType,
|
||||||
Group,
|
Group, PicSubType,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SendArkElement,
|
SendArkElement,
|
||||||
SendMessageElement
|
SendMessageElement
|
||||||
@@ -188,7 +188,7 @@ export async function createSendElements(messageData: OB11MessageData[], group:
|
|||||||
} else if (sendMsg.type === OB11MessageDataType.voice) {
|
} else if (sendMsg.type === OB11MessageDataType.voice) {
|
||||||
sendElements.push(await SendMsgElementConstructor.ptt(path));
|
sendElements.push(await SendMsgElementConstructor.ptt(path));
|
||||||
} else if (sendMsg.type === OB11MessageDataType.image) {
|
} else if (sendMsg.type === OB11MessageDataType.image) {
|
||||||
sendElements.push(await SendMsgElementConstructor.pic(path, sendMsg.data.summary || ""));
|
sendElements.push(await SendMsgElementConstructor.pic(path, sendMsg.data.summary || "", <PicSubType>parseInt(sendMsg.data?.subType?.toString()) || 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
message: "转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素"
|
message: "转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (payload.group_id && !(await getGroup(payload.group_id))) {
|
if (payload.message_type !== "private" && payload.group_id &&!(await getGroup(payload.group_id))) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: `群${payload.group_id}不存在`
|
message: `群${payload.group_id}不存在`
|
||||||
|
@@ -51,6 +51,7 @@ export enum ActionName {
|
|||||||
GetRecord = "get_record",
|
GetRecord = "get_record",
|
||||||
CleanCache = "clean_cache",
|
CleanCache = "clean_cache",
|
||||||
// 以下为go-cqhttp api
|
// 以下为go-cqhttp api
|
||||||
|
GoCQHTTP_SendForwardMsg = "send_forward_msg",
|
||||||
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",
|
||||||
@@ -59,4 +60,5 @@ export enum ActionName {
|
|||||||
GoCQHTTP_UploadGroupFile = "upload_group_file",
|
GoCQHTTP_UploadGroupFile = "upload_group_file",
|
||||||
GoCQHTTP_DownloadFile = "download_file",
|
GoCQHTTP_DownloadFile = "download_file",
|
||||||
GoCQHTTP_GetGroupMsgHistory = "get_group_msg_history",
|
GoCQHTTP_GetGroupMsgHistory = "get_group_msg_history",
|
||||||
|
GoCQHTTP_GetForwardMsg = "get_forward_msg",
|
||||||
}
|
}
|
@@ -13,7 +13,7 @@ export default class SetFriendAddRequest extends BaseAction<Payload, null> {
|
|||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const approve = payload.approve.toString() === "true";
|
const approve = payload.approve.toString() === "true";
|
||||||
await NTQQFriendApi.handleFriendRequest(parseInt(payload.flag), approve)
|
await NTQQFriendApi.handleFriendRequest(payload.flag, approve)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -14,12 +14,13 @@ import {
|
|||||||
GrayTipElementSubType,
|
GrayTipElementSubType,
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
IMAGE_HTTP_HOST,
|
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NT,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SelfInfo,
|
SelfInfo,
|
||||||
Sex,
|
Sex,
|
||||||
TipGroupElementType,
|
TipGroupElementType,
|
||||||
User, VideoElement
|
User,
|
||||||
|
VideoElement
|
||||||
} from '../ntqqapi/types';
|
} from '../ntqqapi/types';
|
||||||
import {getFriend, getGroupMember, selfInfo, tempGroupCodeMap} from '../common/data';
|
import {getFriend, getGroupMember, selfInfo, tempGroupCodeMap} from '../common/data';
|
||||||
import {EventType} from "./event/OB11BaseEvent";
|
import {EventType} from "./event/OB11BaseEvent";
|
||||||
@@ -37,12 +38,14 @@ import {sleep} from "../common/utils/helper";
|
|||||||
import {getConfigUtil} from "../common/config";
|
import {getConfigUtil} from "../common/config";
|
||||||
import {OB11GroupTitleEvent} from "./event/notice/OB11GroupTitleEvent";
|
import {OB11GroupTitleEvent} from "./event/notice/OB11GroupTitleEvent";
|
||||||
import {OB11GroupCardEvent} from "./event/notice/OB11GroupCardEvent";
|
import {OB11GroupCardEvent} from "./event/notice/OB11GroupCardEvent";
|
||||||
|
import {OB11GroupDecreaseEvent} from "./event/notice/OB11GroupDecreaseEvent";
|
||||||
|
|
||||||
|
let lastRKeyUpdateTime = 0;
|
||||||
|
|
||||||
export class OB11Constructor {
|
export class OB11Constructor {
|
||||||
static async message(msg: RawMessage): Promise<OB11Message> {
|
static async message(msg: RawMessage): Promise<OB11Message> {
|
||||||
|
let config = getConfigUtil().getConfig();
|
||||||
const {enableLocalFile2Url, ob11: {messagePostFormat}} = getConfigUtil().getConfig()
|
const {enableLocalFile2Url, ob11: {messagePostFormat}} = config;
|
||||||
const message_type = msg.chatType == ChatType.group ? "group" : "private";
|
const message_type = msg.chatType == ChatType.group ? "group" : "private";
|
||||||
const resMsg: OB11Message = {
|
const resMsg: OB11Message = {
|
||||||
self_id: parseInt(selfInfo.uin),
|
self_id: parseInt(selfInfo.uin),
|
||||||
@@ -138,9 +141,32 @@ export class OB11Constructor {
|
|||||||
// message_data["data"]["path"] = element.picElement.sourcePath
|
// message_data["data"]["path"] = element.picElement.sourcePath
|
||||||
const url = element.picElement.originImageUrl
|
const url = element.picElement.originImageUrl
|
||||||
const fileMd5 = element.picElement.md5HexStr
|
const fileMd5 = element.picElement.md5HexStr
|
||||||
|
const fileUuid = element.picElement.fileUuid
|
||||||
|
// let currentRKey = config.imageRKey || "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
||||||
|
let currentRKey = "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
||||||
if (url) {
|
if (url) {
|
||||||
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
if (url.startsWith("/download")) {
|
||||||
} else if (fileMd5 && element.picElement.fileUuid.indexOf("_") === -1) { // fileuuid有下划线的是Linux发送的,这个url是另外的格式,目前尚未得知如何组装
|
if (url.includes("&rkey=")) {
|
||||||
|
// 正则提取rkey
|
||||||
|
// const rkey = url.match(/&rkey=([^&]+)/)[1]
|
||||||
|
// // log("图片url已有rkey", rkey)
|
||||||
|
// if (rkey != currentRKey){
|
||||||
|
// config.imageRKey = rkey
|
||||||
|
// if (Date.now() - lastRKeyUpdateTime > 1000 * 60) {
|
||||||
|
// lastRKeyUpdateTime = Date.now()
|
||||||
|
// getConfigUtil().setConfig(config)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// 有可能会碰到appid为1406的,这个不能使用新的NT域名,并且需要把appid改为1407才可访问
|
||||||
|
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/download?appid=1407&fileid=${fileUuid}&rkey=${currentRKey}&spec=0`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
||||||
|
}
|
||||||
|
} else if (fileMd5) {
|
||||||
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0`
|
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0`
|
||||||
}
|
}
|
||||||
// message_data["data"]["file_id"] = element.picElement.fileUuid
|
// message_data["data"]["file_id"] = element.picElement.fileUuid
|
||||||
@@ -203,6 +229,15 @@ export class OB11Constructor {
|
|||||||
} else if (element.faceElement) {
|
} else if (element.faceElement) {
|
||||||
message_data["type"] = OB11MessageDataType.face;
|
message_data["type"] = OB11MessageDataType.face;
|
||||||
message_data["data"]["id"] = element.faceElement.faceIndex.toString();
|
message_data["data"]["id"] = element.faceElement.faceIndex.toString();
|
||||||
|
} else if (element.marketFaceElement) {
|
||||||
|
message_data["type"] = OB11MessageDataType.mface;
|
||||||
|
message_data["data"]["text"] = element.marketFaceElement.faceName;
|
||||||
|
} else if (element.markdownElement){
|
||||||
|
message_data["type"] = OB11MessageDataType.markdown;
|
||||||
|
message_data["data"]["data"] = element.markdownElement.content;
|
||||||
|
} else if (element.multiForwardMsgElement){
|
||||||
|
message_data["type"] = OB11MessageDataType.forward;
|
||||||
|
message_data["data"]["id"] = msg.msgId
|
||||||
}
|
}
|
||||||
if (message_data.type !== "unknown" && message_data.data) {
|
if (message_data.type !== "unknown" && message_data.data) {
|
||||||
const cqCode = encodeCQCode(message_data);
|
const cqCode = encodeCQCode(message_data);
|
||||||
@@ -224,8 +259,9 @@ export class OB11Constructor {
|
|||||||
if (msg.senderUin){
|
if (msg.senderUin){
|
||||||
let member = await getGroupMember(msg.peerUid, msg.senderUin);
|
let member = await getGroupMember(msg.peerUid, msg.senderUin);
|
||||||
if (member && member.cardName !== msg.sendMemberName) {
|
if (member && member.cardName !== msg.sendMemberName) {
|
||||||
|
const event = new OB11GroupCardEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), msg.sendMemberName, member.cardName)
|
||||||
member.cardName = msg.sendMemberName;
|
member.cardName = msg.sendMemberName;
|
||||||
return new OB11GroupCardEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), msg.sendMemberName, member.cardName)
|
return event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// log("group msg", msg);
|
// log("group msg", msg);
|
||||||
@@ -271,6 +307,13 @@ export class OB11Constructor {
|
|||||||
return new OB11GroupBanEvent(parseInt(msg.peerUid), parseInt(memberUin), parseInt(adminUin), duration, sub_type);
|
return new OB11GroupBanEvent(parseInt(msg.peerUid), parseInt(memberUin), parseInt(adminUin), duration, sub_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (groupElement.type == TipGroupElementType.kicked){
|
||||||
|
log("收到我被踢出提示", groupElement)
|
||||||
|
const adminUin = (await getGroupMember(msg.peerUid, groupElement.adminUid))?.uin || (await NTQQUserApi.getUserDetailInfo(groupElement.adminUid))?.uin
|
||||||
|
if (adminUin) {
|
||||||
|
return new OB11GroupDecreaseEvent(parseInt(msg.peerUid), parseInt(selfInfo.uin), parseInt(adminUin), "kick_me");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (element.fileElement) {
|
} else if (element.fileElement) {
|
||||||
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {
|
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {
|
||||||
id: element.fileElement.fileUuid,
|
id: element.fileElement.fileUuid,
|
||||||
@@ -293,6 +336,7 @@ export class OB11Constructor {
|
|||||||
while ((match = regex.exec(xmlElement.content)) !== null) {
|
while ((match = regex.exec(xmlElement.content)) !== null) {
|
||||||
matches.push(match[1]);
|
matches.push(match[1]);
|
||||||
}
|
}
|
||||||
|
// log("新人进群匹配到的QQ号", matches)
|
||||||
if (matches.length === 2) {
|
if (matches.length === 2) {
|
||||||
const [inviter, invitee] = matches;
|
const [inviter, invitee] = matches;
|
||||||
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(invitee), parseInt(inviter), "invite");
|
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(invitee), parseInt(inviter), "invite");
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
|
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
|
||||||
|
|
||||||
|
export type GroupDecreaseSubType = "leave" | "kick" | "kick_me";
|
||||||
|
|
||||||
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
||||||
notice_type = "group_decrease";
|
notice_type = "group_decrease";
|
||||||
sub_type: "leave" | "kick" | "kick_me" = "leave"; // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
|
sub_type: GroupDecreaseSubType = "leave"; // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
|
||||||
operator_id: number;
|
operator_id: number;
|
||||||
|
|
||||||
constructor(groupId: number, userId: number) {
|
constructor(groupId: number, userId: number, operatorId: number, subType: GroupDecreaseSubType = "leave") {
|
||||||
super();
|
super();
|
||||||
this.group_id = groupId;
|
this.group_id = groupId;
|
||||||
this.operator_id = userId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
|
this.operator_id = operatorId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
|
||||||
this.user_id = userId;
|
this.user_id = userId;
|
||||||
|
this.sub_type = subType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -73,7 +73,7 @@ export function postOB11Event(msg: PostEventType, reportSelf = false) {
|
|||||||
const config = getConfigUtil().getConfig();
|
const config = getConfigUtil().getConfig();
|
||||||
// 判断msg是否是event
|
// 判断msg是否是event
|
||||||
if (!config.reportSelfMessage && !reportSelf) {
|
if (!config.reportSelfMessage && !reportSelf) {
|
||||||
if ((msg as OB11Message).user_id.toString() == selfInfo.uin) {
|
if (msg.post_type === "message" && (msg as OB11Message).user_id.toString() == selfInfo.uin) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import {RawMessage} from "../ntqqapi/types";
|
import {PicSubType, RawMessage} from "../ntqqapi/types";
|
||||||
import {EventType} from "./event/OB11BaseEvent";
|
import {EventType} from "./event/OB11BaseEvent";
|
||||||
|
|
||||||
export interface OB11User {
|
export interface OB11User {
|
||||||
@@ -88,6 +88,10 @@ export interface OB11Message {
|
|||||||
raw?: RawMessage
|
raw?: RawMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OB11ForwardMessage extends OB11Message {
|
||||||
|
content: OB11MessageData[] | string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface OB11Return<DataType> {
|
export interface OB11Return<DataType> {
|
||||||
status: string
|
status: string
|
||||||
retcode: number
|
retcode: number
|
||||||
@@ -108,10 +112,19 @@ export enum OB11MessageDataType {
|
|||||||
reply = "reply",
|
reply = "reply",
|
||||||
json = "json",
|
json = "json",
|
||||||
face = "face",
|
face = "face",
|
||||||
mface = "face", // 商城表情
|
mface = "mface", // 商城表情
|
||||||
node = "node", // 合并转发消息
|
markdown = "markdown",
|
||||||
|
node = "node", // 合并转发消息节点
|
||||||
|
forward = "forward", // 合并转发消息,用于上报
|
||||||
|
xml = "xml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OB11MessageMFace{
|
||||||
|
type: OB11MessageDataType.mface,
|
||||||
|
data: {
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
}
|
||||||
export interface OB11MessageText {
|
export interface OB11MessageText {
|
||||||
type: OB11MessageDataType.text,
|
type: OB11MessageDataType.text,
|
||||||
data: {
|
data: {
|
||||||
@@ -128,11 +141,13 @@ interface OB11MessageFileBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface OB11MessageImage extends OB11MessageFileBase {
|
export interface OB11MessageImage extends OB11MessageFileBase {
|
||||||
type: OB11MessageDataType.image
|
type: OB11MessageDataType.image
|
||||||
data: OB11MessageFileBase['data'] & {
|
data: OB11MessageFileBase['data'] & {
|
||||||
summary ? : string; // 图片摘要
|
summary ? : string; // 图片摘要
|
||||||
}
|
subType?: PicSubType
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OB11MessageRecord extends OB11MessageFileBase {
|
export interface OB11MessageRecord extends OB11MessageFileBase {
|
||||||
@@ -199,7 +214,7 @@ export interface OB11MessageJson {
|
|||||||
|
|
||||||
export type OB11MessageData =
|
export type OB11MessageData =
|
||||||
OB11MessageText |
|
OB11MessageText |
|
||||||
OB11MessageFace |
|
OB11MessageFace | OB11MessageMFace |
|
||||||
OB11MessageAt | OB11MessageReply |
|
OB11MessageAt | OB11MessageReply |
|
||||||
OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo |
|
OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo |
|
||||||
OB11MessageNode | OB11MessageCustomMusic | OB11MessageJson
|
OB11MessageNode | OB11MessageCustomMusic | OB11MessageJson
|
||||||
|
@@ -150,7 +150,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
),
|
),
|
||||||
SettingItem(
|
SettingItem(
|
||||||
'日志文件目录',
|
'日志文件目录',
|
||||||
`${window.LiteLoader.plugins['LLOneBot'].path.data}`,
|
`${window.LiteLoader.plugins['LLOneBot'].path.data}/logs`,
|
||||||
SettingButton('打开', 'config-open-log-path'),
|
SettingButton('打开', 'config-open-log-path'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const version = "3.19.1"
|
export const version = "3.20.5"
|
Reference in New Issue
Block a user