mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: get group list
fix: 兼容 cc
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
|||||||
friendRequests,
|
friendRequests,
|
||||||
getFriend,
|
getFriend,
|
||||||
getGroup,
|
getGroup,
|
||||||
getGroupMember,
|
getGroupMember, groups,
|
||||||
llonebotError,
|
llonebotError,
|
||||||
refreshGroupMembers,
|
refreshGroupMembers,
|
||||||
selfInfo, uidMaps
|
selfInfo, uidMaps
|
||||||
@@ -107,8 +107,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
|
||||||
}
|
}
|
||||||
@@ -358,13 +358,19 @@ 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;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
startReceiveHook().then();
|
startReceiveHook().then();
|
||||||
NTQQGroupApi.getGroups(true).then()
|
// NTQQGroupApi.getGroups(true).then(_groups => {
|
||||||
|
// _groups.map(group => {
|
||||||
|
// if (!groups.find(g => g.groupCode == group.groupCode)) {
|
||||||
|
// groups.push(group)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// })
|
||||||
const config = getConfigUtil().getConfig()
|
const config = getConfigUtil().getConfig()
|
||||||
if (config.ob11.enableHttp) {
|
if (config.ob11.enableHttp) {
|
||||||
ob11HTTPServer.start(config.ob11.httpPort)
|
ob11HTTPServer.start(config.ob11.httpPort)
|
||||||
@@ -397,7 +403,7 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
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));
|
||||||
@@ -413,6 +419,7 @@ function onLoad() {
|
|||||||
return setTimeout(getUserNick, 1000);
|
return setTimeout(getUserNick, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserNick().then()
|
getUserNick().then()
|
||||||
start().then();
|
start().then();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -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,
|
||||||
|
@@ -25,7 +25,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 +229,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;
|
||||||
@@ -263,12 +262,22 @@ 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)
|
|
||||||
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) => {
|
||||||
|
if (payload.updateType != 2) {
|
||||||
|
updateGroups(payload.groupList).then();
|
||||||
|
} else {
|
||||||
|
if (process.platform != "win32") {
|
||||||
|
processGroupEvent(payload).then();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -162,7 +162,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
|
||||||
)
|
)
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
Reference in New Issue
Block a user