Compare commits

..

4 Commits

Author SHA1 Message Date
linyuchen
6542f2e63b fix: get group list
fix: 兼容 cc
2024-03-24 11:57:02 +08:00
linyuchen
94c928905e fix: get self uin on old QQ 2024-03-24 00:48:30 +08:00
linyuchen
c14f8b21c2 fix: send private msg 2024-03-24 00:10:13 +08:00
linyuchen
6d5ccc6664 fix: add field busid of upload group file event
fix: operator_id typo of group_increase event
2024-03-23 23:24:17 +08:00
13 changed files with 56 additions and 23 deletions

View File

@@ -1,10 +1,10 @@
{
"manifest_version": 4,
"type": "extension",
"name": "LLOneBot v3.19.0",
"name": "LLOneBot v3.19.1",
"slug": "LLOneBot",
"description": "LiteLoaderQQNT的OneBotApi,不支持商店在线更新",
"version": "3.19.0",
"version": "3.19.1",
"icon": "./icon.jpg",
"authors": [
{

View File

@@ -18,7 +18,7 @@ import {
friendRequests,
getFriend,
getGroup,
getGroupMember,
getGroupMember, groups,
llonebotError,
refreshGroupMembers,
selfInfo, uidMaps
@@ -107,8 +107,8 @@ function onLoad() {
const config = getConfigUtil().getConfig()
return config;
})
ipcMain.on(CHANNEL_SET_CONFIG, (event, ask:boolean, config: Config) => {
if (!ask){
ipcMain.on(CHANNEL_SET_CONFIG, (event, ask: boolean, config: Config) => {
if (!ask) {
setConfig(config).then();
return
}
@@ -358,13 +358,19 @@ function onLoad() {
log("llonebot pid", process.pid)
llonebotError.otherError = "";
startTime = Date.now();
dbUtil.getReceivedTempUinMap().then(m=>{
dbUtil.getReceivedTempUinMap().then(m => {
for (const [key, value] of Object.entries(m)) {
uidMaps[value] = key;
}
})
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()
if (config.ob11.enableHttp) {
ob11HTTPServer.start(config.ob11.httpPort)
@@ -389,13 +395,15 @@ function onLoad() {
selfInfo.nick = selfInfo.uin;
} catch (e) {
log("retry get self info", e);
}
if (!selfInfo.uin) {
selfInfo.uin = globalThis.authData?.uin;
selfInfo.uid = globalThis.authData?.uid;
selfInfo.nick = selfInfo.uin;
}
log("self info", selfInfo, globalThis.authData);
if (selfInfo.uin) {
async function getUserNick(){
async function getUserNick() {
try {
getSelfNickCount++;
const userInfo = (await NTQQUserApi.getUserDetailInfo(selfInfo.uid));
@@ -411,6 +419,7 @@ function onLoad() {
return setTimeout(getUserNick, 1000);
}
}
getUserNick().then()
start().then();
} else {

View File

@@ -10,7 +10,7 @@ export class NTQQGroupApi{
static async getGroups(forced = false) {
let cbCmd = ReceiveCmdS.GROUPS
if (process.platform != "win32") {
cbCmd = ReceiveCmdS.GROUPS_UNIX
cbCmd = ReceiveCmdS.GROUPS_STORE
}
const result = await callNTQQApi<{
updateType: number,

View File

@@ -25,7 +25,7 @@ export let ReceiveCmdS = {
USER_INFO: "nodeIKernelProfileListener/onProfileSimpleChanged",
USER_DETAIL_INFO: "nodeIKernelProfileListener/onProfileDetailInfoChanged",
GROUPS: "nodeIKernelGroupListener/onGroupListUpdate",
GROUPS_UNIX: "onGroupListUpdate",
GROUPS_STORE: "onGroupListUpdate",
GROUP_MEMBER_INFO_UPDATE: "nodeIKernelGroupListener/onMemberInfoChange",
FRIENDS: "onBuddyListChange",
MEDIA_DOWNLOAD_COMPLETE: "nodeIKernelMsgListener/onRichMediaDownloadComplete",
@@ -229,8 +229,8 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
for (const group of newGroupList) {
let existGroup = groups.find(g => g.groupCode == group.groupCode);
if (existGroup) {
if (existGroup.memberCount > group.memberCount) {
log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
const oldMembers = existGroup.members;
await sleep(200); // 如果请求QQ API的速度过快通常无法正确拉取到最新的群信息因此这里人为引入一个延时
@@ -262,12 +262,22 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
}
// 群列表变动
registerReceiveHook<{ groupList: Group[], updateType: number }>([ReceiveCmdS.GROUPS, ReceiveCmdS.GROUPS_UNIX], (payload) => {
log("群列表变动", payload)
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS, (payload) => {
if (payload.updateType != 2) {
updateGroups(payload.groupList).then();
} 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();
}
}
})

View File

@@ -162,7 +162,12 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
ipcMain.emit(
channel,
{},
{
sender: {
send: (..._args: unknown[]) => {
},
},
},
{type: 'request', callbackId: uuid, eventName},
apiArgs
)

View File

@@ -98,7 +98,8 @@ export interface FileElement {
"fileSha3"?: "",
"fileUuid"?: "",
"fileSubId"?: "",
"thumbFileSize"?: number
"thumbFileSize"?: number,
fileBizId?: number
}
export interface SendFileElement {

View File

@@ -3,12 +3,18 @@ import {OB11Constructor} from "../../constructor";
import {groups} from "../../../common/data";
import BaseAction from "../BaseAction";
import {ActionName} from "../types";
import {NTQQGroupApi} from "../../../ntqqapi/api";
import {log} from "../../../common/utils";
class GetGroupList extends BaseAction<null, OB11Group[]> {
actionName = ActionName.GetGroupList
protected async _handle(payload: null) {
// if (groups.length === 0) {
// const groups = await NTQQGroupApi.getGroups(true)
// log("get groups", groups)
// }
return OB11Constructor.groups(groups);
}
}

View File

@@ -232,7 +232,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
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 {
valid: false,
message: `${payload.group_id}不存在`

View File

@@ -275,7 +275,8 @@ export class OB11Constructor {
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {
id: element.fileElement.fileUuid,
name: element.fileElement.fileName,
size: parseInt(element.fileElement.fileSize)
size: parseInt(element.fileElement.fileSize),
busid: element.fileElement.fileBizId || 0
})
}

View File

@@ -3,12 +3,12 @@ import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
notice_type = "group_decrease";
sub_type: "leave" | "kick" | "kick_me" = "leave"; // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
operate_id: number;
operator_id: number;
constructor(groupId: number, userId: number) {
super();
this.group_id = groupId;
this.operate_id = userId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
this.operator_id = userId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
this.user_id = userId;
}
}

View File

@@ -3,7 +3,8 @@ import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
export interface GroupUploadFile{
id: string,
name: string,
size: number
size: number,
busid: number,
}
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {

View File

@@ -150,7 +150,7 @@ async function onSettingWindowCreated(view: Element) {
),
SettingItem(
'日志文件目录',
`${window.LiteLoader.plugins['LLOneBot'].path.data}`,
`${window.LiteLoader.plugins['LLOneBot'].path.data}/logs`,
SettingButton('打开', 'config-open-log-path'),
),
]),

View File

@@ -1 +1 @@
export const version = "3.19.0"
export const version = "3.19.1"