mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f150ae478b | ||
![]() |
d1f68553f1 | ||
![]() |
f47f0800de | ||
![]() |
b7ddefc950 | ||
![]() |
25b3325a44 | ||
![]() |
c281b87bab | ||
![]() |
c0946ddda2 | ||
![]() |
1128cf679c | ||
![]() |
ff65a42350 | ||
![]() |
c459587dcd | ||
![]() |
6f8ea9677f | ||
![]() |
38197527fa | ||
![]() |
21b2bd2c8e |
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 4,
|
"manifest_version": 4,
|
||||||
"type": "extension",
|
"type": "extension",
|
||||||
"name": "LLOneBot v3.26.3",
|
"name": "LLOneBot v3.26.5",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
||||||
"version": "3.26.3",
|
"version": "3.26.5",
|
||||||
"icon": "./icon.jpg",
|
"icon": "./icon.jpg",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -1,30 +1,50 @@
|
|||||||
import https from 'node:https';
|
import https from 'node:https';
|
||||||
import http from 'node:http';
|
import http from 'node:http';
|
||||||
|
import { log } from '@/common/utils/log'
|
||||||
|
|
||||||
export class RequestUtil {
|
export class RequestUtil {
|
||||||
// 适用于获取服务器下发cookies时获取,仅GET
|
// 适用于获取服务器下发cookies时获取,仅GET
|
||||||
static async HttpsGetCookies(url: string): Promise<Map<string, string>> {
|
static async HttpsGetCookies(url: string): Promise<{ [key: string]: string }> {
|
||||||
return new Promise<Map<string, string>>((resolve, reject) => {
|
const client = url.startsWith('https') ? https : http;
|
||||||
const protocol = url.startsWith('https://') ? https : http;
|
return new Promise((resolve, reject) => {
|
||||||
protocol.get(url, (res) => {
|
client.get(url, (res) => {
|
||||||
const cookiesHeader = res.headers['set-cookie'];
|
let cookies: { [key: string]: string } = {};
|
||||||
if (!cookiesHeader) {
|
const handleRedirect = (res: http.IncomingMessage) => {
|
||||||
resolve(new Map<string, string>());
|
//console.log(res.headers.location);
|
||||||
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
||||||
|
if (res.headers.location) {
|
||||||
|
const redirectUrl = new URL(res.headers.location, url);
|
||||||
|
RequestUtil.HttpsGetCookies(redirectUrl.href).then((redirectCookies) => {
|
||||||
|
// 合并重定向过程中的cookies
|
||||||
|
log('redirectCookies', redirectCookies)
|
||||||
|
cookies = { ...cookies, ...redirectCookies };
|
||||||
|
resolve(cookies);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const cookiesMap = new Map<string, string>();
|
resolve(cookies);
|
||||||
cookiesHeader.forEach((cookieStr) => {
|
}
|
||||||
cookieStr.split(';').forEach((cookiePart) => {
|
} else {
|
||||||
const trimmedPart = cookiePart.trim();
|
resolve(cookies);
|
||||||
if (trimmedPart.includes('=')) {
|
}
|
||||||
const [key, value] = trimmedPart.split('=').map(part => part.trim());
|
};
|
||||||
cookiesMap.set(key, decodeURIComponent(value)); // 解码cookie值
|
res.on('data', () => { }); // Necessary to consume the stream
|
||||||
|
res.on('end', () => {
|
||||||
|
handleRedirect(res);
|
||||||
|
});
|
||||||
|
if (res.headers['set-cookie']) {
|
||||||
|
// console.log(res.headers['set-cookie']);
|
||||||
|
log('set-cookie', url, res.headers['set-cookie']);
|
||||||
|
res.headers['set-cookie'].forEach((cookie) => {
|
||||||
|
const parts = cookie.split(';')[0].split('=');
|
||||||
|
const key = parts[0];
|
||||||
|
const value = parts[1];
|
||||||
|
if (key && value && key.length > 0 && value.length > 0) {
|
||||||
|
cookies[key] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
resolve(cookiesMap);
|
|
||||||
}
|
}
|
||||||
}).on('error', (error) => {
|
}).on('error', (err) => {
|
||||||
reject(error);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ import {
|
|||||||
selfInfo,
|
selfInfo,
|
||||||
uidMaps,
|
uidMaps,
|
||||||
} from '../common/data'
|
} from '../common/data'
|
||||||
import { hookNTQQApiCall, hookNTQQApiReceive, ReceiveCmdS, registerReceiveHook } from '../ntqqapi/hook'
|
import { hookNTQQApiCall, hookNTQQApiReceive, ReceiveCmdS, registerReceiveHook, startHook } from '../ntqqapi/hook'
|
||||||
import { OB11Constructor } from '../onebot11/constructor'
|
import { OB11Constructor } from '../onebot11/constructor'
|
||||||
import {
|
import {
|
||||||
ChatType,
|
ChatType,
|
||||||
@@ -200,6 +200,7 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function startReceiveHook() {
|
async function startReceiveHook() {
|
||||||
|
startHook().then()
|
||||||
if (getConfigUtil().getConfig().enablePoke) {
|
if (getConfigUtil().getConfig().enablePoke) {
|
||||||
crychic.loadNode()
|
crychic.loadNode()
|
||||||
crychic.registerPokeHandler((id, isGroup) => {
|
crychic.registerPokeHandler((id, isGroup) => {
|
||||||
@@ -436,14 +437,33 @@ function onLoad() {
|
|||||||
uidMaps[value] = key
|
uidMaps[value] = key
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
startReceiveHook().then()
|
try{
|
||||||
NTQQGroupApi.getGroups(true).then(groups=> {
|
log('start get groups')
|
||||||
for (let group of groups) {
|
const _groups = await NTQQGroupApi.getGroups()
|
||||||
|
log('_groups', _groups)
|
||||||
|
await Promise.all(
|
||||||
|
_groups.map(async (group) => {
|
||||||
|
try {
|
||||||
|
const members = await NTQQGroupApi.getGroupMembers(group.groupCode)
|
||||||
|
group.members = members
|
||||||
|
groups.push(group)
|
||||||
|
} catch (e) {
|
||||||
|
log('获取群成员失败', e)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
).catch(log)
|
catch (e) {
|
||||||
|
log('获取群列表失败', e)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
log('start activate group member info')
|
||||||
NTQQGroupApi.activateMemberInfoChange().then().catch(log)
|
NTQQGroupApi.activateMemberInfoChange().then().catch(log)
|
||||||
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
||||||
|
startReceiveHook().then()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
@@ -35,14 +35,20 @@ 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_STORE
|
// cbCmd = ReceiveCmdS.GROUPS_STORE
|
||||||
}
|
// }
|
||||||
const result = await callNTQQApi<{
|
const result = await callNTQQApi<{
|
||||||
updateType: number
|
updateType: number
|
||||||
groupList: Group[]
|
groupList: Group[]
|
||||||
}>({ methodName: NTQQApiMethod.GROUPS, args: [{ force_update: forced }, undefined], cbCmd })
|
}>({
|
||||||
|
methodName: NTQQApiMethod.GROUPS,
|
||||||
|
args: [{ force_update: forced }, undefined],
|
||||||
|
cbCmd: [ReceiveCmdS.GROUPS, ReceiveCmdS.GROUPS_STORE],
|
||||||
|
afterFirstCmd: false,
|
||||||
|
})
|
||||||
|
log('get groups result', result)
|
||||||
return result.groupList
|
return result.groupList
|
||||||
}
|
}
|
||||||
static async getGroupMembers(groupQQ: string, num = 3000): Promise<GroupMember[]> {
|
static async getGroupMembers(groupQQ: string, num = 3000): Promise<GroupMember[]> {
|
||||||
|
@@ -6,6 +6,7 @@ import { NTQQWindowApi, NTQQWindows } from './window'
|
|||||||
import { cacheFunc, isQQ998, log, sleep } from '../../common/utils'
|
import { cacheFunc, isQQ998, log, sleep } from '../../common/utils'
|
||||||
import { wrapperApi } from '@/ntqqapi/native/wrapper'
|
import { wrapperApi } from '@/ntqqapi/native/wrapper'
|
||||||
import * as https from 'https'
|
import * as https from 'https'
|
||||||
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
|
|
||||||
let userInfoCache: Record<string, User> = {} // uid: User
|
let userInfoCache: Record<string, User> = {} // uid: User
|
||||||
|
|
||||||
@@ -98,7 +99,17 @@ export class NTQQUserApi {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
static async getQzoneCookies() {
|
||||||
|
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin + '&clientkey=' + (await this.getClientKey()).clientKey + '&u1=https%3A%2F%2Fuser.qzone.qq.com%2F' + selfInfo.uin + '%2Finfocenter&keyindex=19%27'
|
||||||
|
let cookies: { [key: string]: string; } = {};
|
||||||
|
try {
|
||||||
|
cookies = await RequestUtil.HttpsGetCookies(requestUrl);
|
||||||
|
} catch (e: any) {
|
||||||
|
log('获取QZone Cookies失败', e)
|
||||||
|
cookies = {}
|
||||||
|
}
|
||||||
|
return cookies;
|
||||||
|
}
|
||||||
static async getSkey(): Promise<string> {
|
static async getSkey(): Promise<string> {
|
||||||
const clientKeyData = await this.getClientKey()
|
const clientKeyData = await this.getClientKey()
|
||||||
if (clientKeyData.result !== 0) {
|
if (clientKeyData.result !== 0) {
|
||||||
@@ -106,33 +117,19 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
const url = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin
|
const url = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin
|
||||||
+ '&clientkey=' + clientKeyData.clientKey
|
+ '&clientkey=' + clientKeyData.clientKey
|
||||||
+ '&u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=' + clientKeyData.keyIndex
|
+ '&u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=' + clientKeyData.keyIndex;
|
||||||
|
return (await RequestUtil.HttpsGetCookies(url))?.skey;
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const req = https.get(url, (res) => {
|
|
||||||
const rawCookies = res.headers['set-cookie']
|
|
||||||
const cookies = {}
|
|
||||||
rawCookies.forEach(cookie => {
|
|
||||||
// 使用正则表达式匹配 cookie 名称和值
|
|
||||||
const regex = /([^=;]+)=([^;]*)/
|
|
||||||
const match = regex.exec(cookie)
|
|
||||||
if (match) {
|
|
||||||
cookies[match[1].trim()] = match[2].trim()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
resolve(cookies['skey'])
|
|
||||||
})
|
|
||||||
req.on('error', e => {
|
|
||||||
reject(e)
|
|
||||||
});
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@cacheFunc(60 * 30 * 1000)
|
@cacheFunc(60 * 30 * 1000)
|
||||||
static async getCookies(domain: string) {
|
static async getCookies(domain: string) {
|
||||||
|
if (domain.endsWith("qzone.qq.com")) {
|
||||||
|
let data = (await NTQQUserApi.getQzoneCookies());
|
||||||
|
const CookieValue = 'p_skey=' + data.p_skey + '; skey=' + data.skey + '; p_uin=o' + selfInfo.uin + '; uin=o' + selfInfo.uin;
|
||||||
|
return { bkn: NTQQUserApi.genBkn(data.p_skey), cookies: CookieValue };
|
||||||
|
}
|
||||||
const skey = await this.getSkey();
|
const skey = await this.getSkey();
|
||||||
const pskey= (await this.getPSkey([domain])).get(domain);
|
const pskey = (await this.getPSkey([domain])).get(domain);
|
||||||
if (!pskey || !skey) {
|
if (!pskey || !skey) {
|
||||||
throw new Error('获取Cookies失败')
|
throw new Error('获取Cookies失败')
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import { NTQQGroupApi } from './api/group'
|
|||||||
import { log } from '@/common/utils'
|
import { log } from '@/common/utils'
|
||||||
import { isNumeric, sleep } from '@/common/utils'
|
import { isNumeric, sleep } from '@/common/utils'
|
||||||
import { OB11Constructor } from '../onebot11/constructor'
|
import { OB11Constructor } from '../onebot11/constructor'
|
||||||
|
import { OB11GroupCardEvent } from '../onebot11/event/notice/OB11GroupCardEvent'
|
||||||
|
|
||||||
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
||||||
|
|
||||||
@@ -324,41 +325,51 @@ async function processGroupEvent(payload: { groupList: Group[] }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function startHook() {
|
||||||
|
|
||||||
// 群列表变动
|
// 群列表变动
|
||||||
registerReceiveHook<{ groupList: Group[]; updateType: number }>(ReceiveCmdS.GROUPS, (payload) => {
|
registerReceiveHook<{ groupList: Group[]; updateType: number }>(ReceiveCmdS.GROUPS, (payload) => {
|
||||||
// updateType 3是群列表变动,2是群成员变动
|
// updateType 3是群列表变动,2是群成员变动
|
||||||
// log("群列表变动", payload.updateType, payload.groupList)
|
// log("群列表变动", payload.updateType, payload.groupList)
|
||||||
if (payload.updateType != 2) {
|
if (payload.updateType != 2) {
|
||||||
updateGroups(payload.groupList).then()
|
updateGroups(payload.groupList).then()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
processGroupEvent(payload).then()
|
processGroupEvent(payload).then()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
registerReceiveHook<{ groupList: Group[]; updateType: number }>(ReceiveCmdS.GROUPS_STORE, (payload) => {
|
registerReceiveHook<{ groupList: Group[]; updateType: number }>(ReceiveCmdS.GROUPS_STORE, (payload) => {
|
||||||
// updateType 3是群列表变动,2是群成员变动
|
// updateType 3是群列表变动,2是群成员变动
|
||||||
// log("群列表变动", payload.updateType, payload.groupList)
|
// log("群列表变动", payload.updateType, payload.groupList)
|
||||||
if (payload.updateType != 2) {
|
if (payload.updateType != 2) {
|
||||||
updateGroups(payload.groupList).then()
|
updateGroups(payload.groupList).then()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (process.platform != 'win32') {
|
if (process.platform != 'win32') {
|
||||||
processGroupEvent(payload).then()
|
processGroupEvent(payload).then()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerReceiveHook<{
|
registerReceiveHook<{
|
||||||
groupCode: string
|
groupCode: string
|
||||||
dataSource: number
|
dataSource: number
|
||||||
members: Set<GroupMember>
|
members: Set<GroupMember>
|
||||||
}>(ReceiveCmdS.GROUP_MEMBER_INFO_UPDATE, async (payload) => {
|
}>(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, members)
|
// log("群成员信息变动", groupCode, members)
|
||||||
for (const member of members) {
|
for (const member of members) {
|
||||||
const existMember = await getGroupMember(groupCode, member.uin)
|
const existMember = await getGroupMember(groupCode, member.uin)
|
||||||
if (existMember) {
|
if (existMember) {
|
||||||
|
if (member.cardName != existMember.cardName) {
|
||||||
|
log('群成员名片变动', `${groupCode}: ${existMember.uin}`, existMember.cardName, '->', member.cardName)
|
||||||
|
postOb11Event(
|
||||||
|
new OB11GroupCardEvent(parseInt(groupCode), parseInt(member.uin), member.cardName, existMember.cardName),
|
||||||
|
)
|
||||||
|
}
|
||||||
Object.assign(existMember, member)
|
Object.assign(existMember, member)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,12 +387,12 @@ registerReceiveHook<{
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
// 好友列表变动
|
// 好友列表变动
|
||||||
registerReceiveHook<{
|
registerReceiveHook<{
|
||||||
data:CategoryFriend[]
|
data: CategoryFriend[]
|
||||||
}>(ReceiveCmdS.FRIENDS, (payload) => {
|
}>(ReceiveCmdS.FRIENDS, (payload) => {
|
||||||
rawFriends.length = 0;
|
rawFriends.length = 0;
|
||||||
rawFriends.push(...payload.data);
|
rawFriends.push(...payload.data);
|
||||||
for (const fData of payload.data) {
|
for (const fData of payload.data) {
|
||||||
@@ -391,14 +402,15 @@ registerReceiveHook<{
|
|||||||
let existFriend = friends.find((f) => f.uin == friend.uin)
|
let existFriend = friends.find((f) => f.uin == friend.uin)
|
||||||
if (!existFriend) {
|
if (!existFriend) {
|
||||||
friends.push(friend)
|
friends.push(friend)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Object.assign(existFriend, friend)
|
Object.assign(existFriend, friend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerReceiveHook<{ msgList: Array<RawMessage> }>([ReceiveCmdS.NEW_MSG, ReceiveCmdS.NEW_ACTIVE_MSG], (payload) => {
|
registerReceiveHook<{ msgList: Array<RawMessage> }>([ReceiveCmdS.NEW_MSG, ReceiveCmdS.NEW_ACTIVE_MSG], (payload) => {
|
||||||
// 保存一下uid
|
// 保存一下uid
|
||||||
for (const message of payload.msgList) {
|
for (const message of payload.msgList) {
|
||||||
const uid = message.senderUid
|
const uid = message.senderUid
|
||||||
@@ -454,9 +466,9 @@ registerReceiveHook<{ msgList: Array<RawMessage> }>([ReceiveCmdS.NEW_MSG, Receiv
|
|||||||
}, getConfigUtil().getConfig().autoDeleteFileSecond * 1000)
|
}, getConfigUtil().getConfig().autoDeleteFileSecond * 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmdS.SELF_SEND_MSG, ({ msgRecord }) => {
|
registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmdS.SELF_SEND_MSG, ({ msgRecord }) => {
|
||||||
const message = msgRecord
|
const message = msgRecord
|
||||||
const peerUid = message.peerUid
|
const peerUid = message.peerUid
|
||||||
// log("收到自己发送成功的消息", Object.keys(sendMessagePool), message);
|
// log("收到自己发送成功的消息", Object.keys(sendMessagePool), message);
|
||||||
@@ -470,14 +482,14 @@ registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmdS.SELF_SEND_MSG, ({ msg
|
|||||||
log('receive self msg error', e.stack)
|
log('receive self msg error', e.stack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerReceiveHook<{ info: { status: number } }>(ReceiveCmdS.SELF_STATUS, (info) => {
|
registerReceiveHook<{ info: { status: number } }>(ReceiveCmdS.SELF_STATUS, (info) => {
|
||||||
selfInfo.online = info.info.status !== 20
|
selfInfo.online = info.info.status !== 20
|
||||||
})
|
})
|
||||||
|
|
||||||
let activatedPeerUids: string[] = []
|
let activatedPeerUids: string[] = []
|
||||||
registerReceiveHook<{
|
registerReceiveHook<{
|
||||||
changedRecentContactLists: {
|
changedRecentContactLists: {
|
||||||
listType: number
|
listType: number
|
||||||
sortedContactList: string[]
|
sortedContactList: string[]
|
||||||
@@ -486,7 +498,7 @@ registerReceiveHook<{
|
|||||||
chatType: ChatType
|
chatType: ChatType
|
||||||
}[]
|
}[]
|
||||||
}[]
|
}[]
|
||||||
}>(ReceiveCmdS.RECENT_CONTACT, async (payload) => {
|
}>(ReceiveCmdS.RECENT_CONTACT, async (payload) => {
|
||||||
for (const recentContact of payload.changedRecentContactLists) {
|
for (const recentContact of payload.changedRecentContactLists) {
|
||||||
for (const changedContact of recentContact.changedList) {
|
for (const changedContact of recentContact.changedList) {
|
||||||
if (activatedPeerUids.includes(changedContact.id)) continue
|
if (activatedPeerUids.includes(changedContact.id)) continue
|
||||||
@@ -503,20 +515,22 @@ registerReceiveHook<{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
NTQQMsgApi.activateChat(peer).then()
|
NTQQMsgApi.activateChat(peer).then()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerCallHook(NTQQApiMethod.DELETE_ACTIVE_CHAT, async (payload) => {
|
registerCallHook(NTQQApiMethod.DELETE_ACTIVE_CHAT, async (payload) => {
|
||||||
const peerUid = payload[0] as string
|
const peerUid = payload[0] as string
|
||||||
log('激活的聊天窗口被删除,准备重新激活', peerUid)
|
log('激活的聊天窗口被删除,准备重新激活', peerUid)
|
||||||
let chatType = ChatType.friend
|
let chatType = ChatType.friend
|
||||||
if (isNumeric(peerUid)) {
|
if (isNumeric(peerUid)) {
|
||||||
chatType = ChatType.group
|
chatType = ChatType.group
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// 检查是否好友
|
// 检查是否好友
|
||||||
if (!(await getFriend(peerUid))) {
|
if (!(await getFriend(peerUid))) {
|
||||||
chatType = ChatType.temp
|
chatType = ChatType.temp
|
||||||
@@ -527,4 +541,6 @@ registerCallHook(NTQQApiMethod.DELETE_ACTIVE_CHAT, async (payload) => {
|
|||||||
NTQQMsgApi.activateChat(peer).then((r) => {
|
NTQQMsgApi.activateChat(peer).then((r) => {
|
||||||
log('重新激活聊天窗口', peer, { result: r.result, errMsg: r.errMsg })
|
log('重新激活聊天窗口', peer, { result: r.result, errMsg: r.errMsg })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
}
|
@@ -107,7 +107,7 @@ interface NTQQApiParams {
|
|||||||
channel?: NTQQApiChannel
|
channel?: NTQQApiChannel
|
||||||
classNameIsRegister?: boolean
|
classNameIsRegister?: boolean
|
||||||
args?: unknown[]
|
args?: unknown[]
|
||||||
cbCmd?: ReceiveCmd | null
|
cbCmd?: ReceiveCmd | ReceiveCmd[] | null
|
||||||
cmdCB?: (payload: any) => boolean
|
cmdCB?: (payload: any) => boolean
|
||||||
afterFirstCmd?: boolean // 是否在methodName调用完之后再去hook cbCmd
|
afterFirstCmd?: boolean // 是否在methodName调用完之后再去hook cbCmd
|
||||||
timeoutSecond?: number
|
timeoutSecond?: number
|
||||||
@@ -147,7 +147,8 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
success = true
|
success = true
|
||||||
resolve(r)
|
resolve(r)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
||||||
const secondCallback = () => {
|
const secondCallback = () => {
|
||||||
const hookId = registerReceiveHook<ReturnType>(cbCmd, (payload) => {
|
const hookId = registerReceiveHook<ReturnType>(cbCmd, (payload) => {
|
||||||
@@ -158,7 +159,8 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
success = true
|
success = true
|
||||||
resolve(payload)
|
resolve(payload)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
removeReceiveHook(hookId)
|
removeReceiveHook(hookId)
|
||||||
success = true
|
success = true
|
||||||
resolve(payload)
|
resolve(payload)
|
||||||
@@ -170,7 +172,8 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
log(`${methodName} callback`, result)
|
log(`${methodName} callback`, result)
|
||||||
if (result?.result == 0 || result === undefined) {
|
if (result?.result == 0 || result === undefined) {
|
||||||
afterFirstCmd && secondCallback()
|
afterFirstCmd && secondCallback()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
success = true
|
success = true
|
||||||
reject(`ntqq api call failed, ${result.errMsg}`)
|
reject(`ntqq api call failed, ${result.errMsg}`)
|
||||||
}
|
}
|
||||||
@@ -188,7 +191,8 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
channel,
|
channel,
|
||||||
{
|
{
|
||||||
sender: {
|
sender: {
|
||||||
send: (..._args: unknown[]) => {},
|
send: (..._args: unknown[]) => {
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type: 'request', callbackId: uuid, eventName },
|
{ type: 'request', callbackId: uuid, eventName },
|
||||||
|
@@ -46,7 +46,7 @@ import GetFile from './file/GetFile'
|
|||||||
import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg'
|
import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg'
|
||||||
import { GetCookies } from './user/GetCookie'
|
import { GetCookies } from './user/GetCookie'
|
||||||
import { SetMsgEmojiLike } from './msg/SetMsgEmojiLike'
|
import { SetMsgEmojiLike } from './msg/SetMsgEmojiLike'
|
||||||
import { ForwardFriendSingleMsg, ForwardSingleGroupMsg } from './msg/ForwardSingleMsg'
|
import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from './msg/ForwardSingleMsg'
|
||||||
import { GetGroupEssence } from './group/GetGroupEssence'
|
import { GetGroupEssence } from './group/GetGroupEssence'
|
||||||
import { GetGroupHonorInfo } from './group/GetGroupHonorInfo'
|
import { GetGroupHonorInfo } from './group/GetGroupHonorInfo'
|
||||||
import { GoCQHTTHandleQuickOperation } from './go-cqhttp/QuickOperation'
|
import { GoCQHTTHandleQuickOperation } from './go-cqhttp/QuickOperation'
|
||||||
@@ -91,7 +91,7 @@ export const actionHandlers = [
|
|||||||
new GetCookies(),
|
new GetCookies(),
|
||||||
new SetMsgEmojiLike(),
|
new SetMsgEmojiLike(),
|
||||||
new ForwardFriendSingleMsg(),
|
new ForwardFriendSingleMsg(),
|
||||||
new ForwardSingleGroupMsg(),
|
new ForwardGroupSingleMsg(),
|
||||||
//以下为go-cqhttp api
|
//以下为go-cqhttp api
|
||||||
new GetGroupEssence(),
|
new GetGroupEssence(),
|
||||||
new GetGroupHonorInfo(),
|
new GetGroupHonorInfo(),
|
||||||
|
@@ -43,6 +43,6 @@ export class ForwardFriendSingleMsg extends ForwardSingleMsg {
|
|||||||
actionName = ActionName.ForwardFriendSingleMsg
|
actionName = ActionName.ForwardFriendSingleMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ForwardSingleGroupMsg extends ForwardSingleMsg {
|
export class ForwardGroupSingleMsg extends ForwardSingleMsg {
|
||||||
actionName = ActionName.ForwardGroupSingleMsg
|
actionName = ActionName.ForwardGroupSingleMsg
|
||||||
}
|
}
|
||||||
|
@@ -327,7 +327,7 @@ export async function sendMsg(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log('发送消息总大小', totalSize, 'bytes')
|
log('发送消息总大小', totalSize, 'bytes')
|
||||||
let timeout = ((totalSize / 1024 / 512) * 1000) + 5000 // 512kb/s
|
let timeout = ((totalSize / 1024 / 100) * 1000) + 5000 // 100kb/s
|
||||||
log('设置消息超时时间', timeout)
|
log('设置消息超时时间', timeout)
|
||||||
const returnMsg = await NTQQMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
const returnMsg = await NTQQMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
||||||
log('消息发送结果', returnMsg)
|
log('消息发送结果', returnMsg)
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import BaseAction from '../BaseAction'
|
import BaseAction from '../BaseAction'
|
||||||
import { NTQQUserApi } from '../../../ntqqapi/api'
|
import { NTQQUserApi } from '@/ntqqapi/api'
|
||||||
import { groups } from '../../../common/data'
|
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const version = '3.26.3'
|
export const version = '3.26.5'
|
||||||
|
Reference in New Issue
Block a user