mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
merge main
This commit is contained in:
commit
c281b87bab
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 4,
|
"manifest_version": 4,
|
||||||
"type": "extension",
|
"type": "extension",
|
||||||
"name": "LLOneBot v3.26.2",
|
"name": "LLOneBot v3.26.3",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
|
||||||
"version": "3.26.2",
|
"version": "3.26.3",
|
||||||
"icon": "./icon.jpg",
|
"icon": "./icon.jpg",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -3,26 +3,34 @@ import fs from 'node:fs'
|
|||||||
import os from 'node:os'
|
import os from 'node:os'
|
||||||
import { systemPlatform } from './system'
|
import { systemPlatform } from './system'
|
||||||
|
|
||||||
export const exePath = process.execPath;
|
export const exePath = process.execPath
|
||||||
|
|
||||||
export const pkgInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'package.json');
|
function getPKGPath() {
|
||||||
let configVersionInfoPath;
|
let p = path.join(path.dirname(exePath), 'resources', 'app', 'package.json')
|
||||||
|
if (systemPlatform === 'darwin') {
|
||||||
|
p = path.join(path.dirname(path.dirname(exePath)), 'Resources', 'app', 'package.json')
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pkgInfoPath = getPKGPath()
|
||||||
|
let configVersionInfoPath: string
|
||||||
|
|
||||||
|
|
||||||
if (os.platform() !== 'linux') {
|
if (os.platform() !== 'linux') {
|
||||||
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json')
|
||||||
} else {
|
}
|
||||||
const userPath = os.homedir();
|
else {
|
||||||
const appDataPath = path.resolve(userPath, './.config/QQ');
|
const userPath = os.homedir()
|
||||||
configVersionInfoPath = path.resolve(appDataPath, './versions/config.json');
|
const appDataPath = path.resolve(userPath, './.config/QQ')
|
||||||
|
configVersionInfoPath = path.resolve(appDataPath, './versions/config.json')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof configVersionInfoPath !== 'string') {
|
if (typeof configVersionInfoPath !== 'string') {
|
||||||
throw new Error('Something went wrong when load QQ info path');
|
throw new Error('Something went wrong when load QQ info path')
|
||||||
}
|
}
|
||||||
|
|
||||||
export { configVersionInfoPath };
|
export { configVersionInfoPath }
|
||||||
|
|
||||||
type QQPkgInfo = {
|
type QQPkgInfo = {
|
||||||
version: string;
|
version: string;
|
||||||
@ -43,21 +51,21 @@ let _qqVersionConfigInfo: QQVersionConfigInfo = {
|
|||||||
'curVersion': '9.9.9-23361',
|
'curVersion': '9.9.9-23361',
|
||||||
'prevVersion': '',
|
'prevVersion': '',
|
||||||
'onErrorVersions': [],
|
'onErrorVersions': [],
|
||||||
'buildId': '23361'
|
'buildId': '23361',
|
||||||
};
|
}
|
||||||
|
|
||||||
if (fs.existsSync(configVersionInfoPath)) {
|
if (fs.existsSync(configVersionInfoPath)) {
|
||||||
try {
|
try {
|
||||||
const _ =JSON.parse(fs.readFileSync(configVersionInfoPath).toString());
|
const _ = JSON.parse(fs.readFileSync(configVersionInfoPath).toString())
|
||||||
_qqVersionConfigInfo = Object.assign(_qqVersionConfigInfo, _);
|
_qqVersionConfigInfo = Object.assign(_qqVersionConfigInfo, _)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Load QQ version config info failed, Use default version', e);
|
console.error('Load QQ version config info failed, Use default version', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const qqVersionConfigInfo: QQVersionConfigInfo = _qqVersionConfigInfo;
|
export const qqVersionConfigInfo: QQVersionConfigInfo = _qqVersionConfigInfo
|
||||||
|
|
||||||
export const qqPkgInfo: QQPkgInfo = require(pkgInfoPath);
|
export const qqPkgInfo: QQPkgInfo = require(pkgInfoPath)
|
||||||
// platform_type: 3,
|
// platform_type: 3,
|
||||||
// app_type: 4,
|
// app_type: 4,
|
||||||
// app_version: '9.9.9-23159',
|
// app_version: '9.9.9-23159',
|
||||||
@ -66,10 +74,10 @@ export const qqPkgInfo: QQPkgInfo = require(pkgInfoPath);
|
|||||||
// platVer: '10.0.26100',
|
// platVer: '10.0.26100',
|
||||||
// clientVer: '9.9.9-23159',
|
// clientVer: '9.9.9-23159',
|
||||||
|
|
||||||
let _appid: string = '537213803'; // 默认为 Windows 平台的 appid
|
let _appid: string = '537213803' // 默认为 Windows 平台的 appid
|
||||||
if (systemPlatform === 'linux') {
|
if (systemPlatform === 'linux') {
|
||||||
_appid = '537213827';
|
_appid = '537213827'
|
||||||
}
|
}
|
||||||
// todo: mac 平台的 appid
|
// todo: mac 平台的 appid
|
||||||
export const appid = _appid;
|
export const appid = _appid
|
||||||
export const isQQ998: boolean = qqPkgInfo.buildVersion >= '22106'
|
export const isQQ998: boolean = qqPkgInfo.buildVersion >= '22106'
|
@ -3,28 +3,45 @@ import http from 'node:http';
|
|||||||
|
|
||||||
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);
|
||||||
} else {
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
||||||
const cookiesMap = new Map<string, string>();
|
if (res.headers.location) {
|
||||||
cookiesHeader.forEach((cookieStr) => {
|
const redirectUrl = new URL(res.headers.location, url);
|
||||||
cookieStr.split(';').forEach((cookiePart) => {
|
RequestUtil.HttpsGetCookies(redirectUrl.href).then((redirectCookies) => {
|
||||||
const trimmedPart = cookiePart.trim();
|
// 合并重定向过程中的cookies
|
||||||
if (trimmedPart.includes('=')) {
|
cookies = { ...cookies, ...redirectCookies };
|
||||||
const [key, value] = trimmedPart.split('=').map(part => part.trim());
|
resolve(cookies);
|
||||||
cookiesMap.set(key, decodeURIComponent(value)); // 解码cookie值
|
});
|
||||||
}
|
} else {
|
||||||
});
|
resolve(cookies);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve(cookies);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
res.on('data', () => { }); // Necessary to consume the stream
|
||||||
|
res.on('end', () => {
|
||||||
|
handleRedirect(res);
|
||||||
|
});
|
||||||
|
if (res.headers['set-cookie']) {
|
||||||
|
//console.log(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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -349,32 +349,48 @@ function onLoad() {
|
|||||||
log('获取群通知的成员信息失败', notify, e.stack.toString())
|
log('获取群通知的成员信息失败', notify, e.stack.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
else if ([GroupNotifyTypes.JOIN_REQUEST, GroupNotifyTypes.JOIN_REQUEST_BY_INVITED].includes(notify.type)) {
|
||||||
log('有加群请求')
|
log('有加群请求')
|
||||||
let groupRequestEvent = new OB11GroupRequestEvent()
|
let groupRequestEvent = new OB11GroupRequestEvent()
|
||||||
groupRequestEvent.group_id = parseInt(notify.group.groupCode)
|
groupRequestEvent.group_id = parseInt(notify.group.groupCode)
|
||||||
let requestQQ = ''
|
let requestQQ = uidMaps[notify.user1.uid]
|
||||||
try {
|
if (!requestQQ) {
|
||||||
requestQQ = (await NTQQUserApi.getUserDetailInfo(notify.user1.uid)).uin
|
try {
|
||||||
} catch (e) {
|
requestQQ = (await NTQQUserApi.getUserDetailInfo(notify.user1.uid)).uin
|
||||||
log('获取加群人QQ号失败', e)
|
} catch (e) {
|
||||||
|
log('获取加群人QQ号失败', e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
groupRequestEvent.user_id = parseInt(requestQQ) || 0
|
groupRequestEvent.user_id = parseInt(requestQQ) || 0
|
||||||
groupRequestEvent.sub_type = 'add'
|
groupRequestEvent.sub_type = 'add'
|
||||||
groupRequestEvent.comment = notify.postscript
|
groupRequestEvent.comment = notify.postscript
|
||||||
groupRequestEvent.flag = notify.seq
|
groupRequestEvent.flag = notify.seq
|
||||||
|
if (notify.type == GroupNotifyTypes.JOIN_REQUEST_BY_INVITED) {
|
||||||
|
// groupRequestEvent.sub_type = 'invite'
|
||||||
|
let invitorQQ = uidMaps[notify.user2.uid]
|
||||||
|
if (!invitorQQ) {
|
||||||
|
try {
|
||||||
|
let invitor = (await NTQQUserApi.getUserDetailInfo(notify.user2.uid))
|
||||||
|
groupRequestEvent.invitor_id = parseInt(invitor.uin)
|
||||||
|
} catch (e) {
|
||||||
|
groupRequestEvent.invitor_id = 0
|
||||||
|
log('获取邀请人QQ号失败', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
postOb11Event(groupRequestEvent)
|
postOb11Event(groupRequestEvent)
|
||||||
}
|
}
|
||||||
else if (notify.type == GroupNotifyTypes.INVITE_ME) {
|
else if (notify.type == GroupNotifyTypes.INVITE_ME) {
|
||||||
log('收到邀请我加群通知')
|
log('收到邀请我加群通知')
|
||||||
let groupInviteEvent = new OB11GroupRequestEvent()
|
let groupInviteEvent = new OB11GroupRequestEvent()
|
||||||
groupInviteEvent.group_id = parseInt(notify.group.groupCode)
|
groupInviteEvent.group_id = parseInt(notify.group.groupCode)
|
||||||
let user_id = (await getFriend(notify.user2.uid))?.uin
|
let user_id = uidMaps[notify.user2.uid]
|
||||||
if (!user_id) {
|
if (!user_id) {
|
||||||
user_id = (await NTQQUserApi.getUserDetailInfo(notify.user2.uid))?.uin
|
user_id = (await NTQQUserApi.getUserDetailInfo(notify.user2.uid))?.uin
|
||||||
}
|
}
|
||||||
groupInviteEvent.user_id = parseInt(user_id)
|
groupInviteEvent.user_id = parseInt(user_id)
|
||||||
groupInviteEvent.sub_type = 'invite'
|
groupInviteEvent.sub_type = 'invite'
|
||||||
|
// groupInviteEvent.invitor_id = parseInt(user_id)
|
||||||
groupInviteEvent.flag = notify.seq
|
groupInviteEvent.flag = notify.seq
|
||||||
postOb11Event(groupInviteEvent)
|
postOb11Event(groupInviteEvent)
|
||||||
}
|
}
|
||||||
@ -421,7 +437,13 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
startReceiveHook().then()
|
startReceiveHook().then()
|
||||||
NTQQGroupApi.getGroups(true).then()
|
NTQQGroupApi.getGroups(true).then(groups=> {
|
||||||
|
for (let group of groups) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).catch(log)
|
||||||
|
NTQQGroupApi.activateMemberInfoChange().then().catch(log)
|
||||||
|
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
||||||
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)
|
||||||
|
@ -7,6 +7,33 @@ import { log } from '../../common/utils/log'
|
|||||||
import { NTQQWindowApi, NTQQWindows } from './window'
|
import { NTQQWindowApi, NTQQWindows } from './window'
|
||||||
|
|
||||||
export class NTQQGroupApi {
|
export class NTQQGroupApi {
|
||||||
|
|
||||||
|
static async activateMemberListChange(){
|
||||||
|
return await callNTQQApi<GeneralCallResult>({
|
||||||
|
methodName: NTQQApiMethod.ACTIVATE_MEMBER_LIST_CHANGE,
|
||||||
|
classNameIsRegister: true,
|
||||||
|
args: [],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
static async activateMemberInfoChange(){
|
||||||
|
return await callNTQQApi<GeneralCallResult>({
|
||||||
|
methodName: NTQQApiMethod.ACTIVATE_MEMBER_INFO_CHANGE,
|
||||||
|
classNameIsRegister: true,
|
||||||
|
args: [],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
static async getGroupAllInfo(groupCode: string, source: number=4){
|
||||||
|
return await callNTQQApi<GeneralCallResult & Group>({
|
||||||
|
methodName: NTQQApiMethod.GET_GROUP_ALL_INFO,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
groupCode,
|
||||||
|
source
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
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') {
|
||||||
@ -58,6 +85,19 @@ export class NTQQGroupApi {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static async getGroupMembersInfo(groupCode: string, uids: string[], forceUpdate: boolean=false) {
|
||||||
|
return await callNTQQApi<GeneralCallResult>({
|
||||||
|
methodName: NTQQApiMethod.GROUP_MEMBERS_INFO,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
forceUpdate,
|
||||||
|
groupCode,
|
||||||
|
uids
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
static async getGroupNotifies() {
|
static async getGroupNotifies() {
|
||||||
// 获取管理员变更
|
// 获取管理员变更
|
||||||
// 加群通知,退出通知,需要管理员权限
|
// 加群通知,退出通知,需要管理员权限
|
||||||
@ -158,7 +198,8 @@ export class NTQQGroupApi {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
static async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
static async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
||||||
|
const res = await callNTQQApi<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.SET_MEMBER_CARD,
|
methodName: NTQQApiMethod.SET_MEMBER_CARD,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
@ -169,6 +210,8 @@ export class NTQQGroupApi {
|
|||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
NTQQGroupApi.getGroupMembersInfo(groupQQ, [memberUid], true).then().catch(log)
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
static async setMemberRole(groupQQ: string, memberUid: string, role: GroupMemberRole) {
|
static async setMemberRole(groupQQ: string, memberUid: string, role: GroupMemberRole) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await callNTQQApi<GeneralCallResult>({
|
||||||
|
@ -29,7 +29,8 @@ async function sendWaiter(peer: Peer, waitComplete = true, timeout: number = 100
|
|||||||
await sleep(500)
|
await sleep(500)
|
||||||
checkLastSendUsingTime += 500
|
checkLastSendUsingTime += 500
|
||||||
return await waitLastSend()
|
return await waitLastSend()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +49,8 @@ async function sendWaiter(peer: Peer, waitComplete = true, timeout: number = 100
|
|||||||
if ((await dbUtil.getMsgByLongId(sentMessage.msgId)).sendStatus == 2) {
|
if ((await dbUtil.getMsgByLongId(sentMessage.msgId)).sendStatus == 2) {
|
||||||
return sentMessage
|
return sentMessage
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return sentMessage
|
return sentMessage
|
||||||
}
|
}
|
||||||
// log(`给${peerUid}发送消息成功`)
|
// log(`给${peerUid}发送消息成功`)
|
||||||
@ -60,10 +62,28 @@ async function sendWaiter(peer: Peer, waitComplete = true, timeout: number = 100
|
|||||||
await sleep(500)
|
await sleep(500)
|
||||||
return await checkSendComplete()
|
return await checkSendComplete()
|
||||||
}
|
}
|
||||||
return checkSendComplete();
|
return checkSendComplete()
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQMsgApi {
|
export class NTQQMsgApi {
|
||||||
|
static enterOrExitAIO(peer: Peer, enter: boolean) {
|
||||||
|
return callNTQQApi<GeneralCallResult>({
|
||||||
|
methodName: NTQQApiMethod.ENTER_OR_EXIT_AIO,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
"info_list": [
|
||||||
|
{
|
||||||
|
peer,
|
||||||
|
"option": enter ? 1 : 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"send": true
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
static async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, set: boolean = true) {
|
static async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, set: boolean = true) {
|
||||||
// nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览
|
// nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览
|
||||||
// nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid
|
// nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid
|
||||||
@ -83,6 +103,7 @@ export class NTQQMsgApi {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) {
|
static async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) {
|
||||||
return await callNTQQApi<GeneralCallResult & { msgList: RawMessage[] }>({
|
return await callNTQQApi<GeneralCallResult & { msgList: RawMessage[] }>({
|
||||||
methodName: NTQQApiMethod.GET_MULTI_MSG,
|
methodName: NTQQApiMethod.GET_MULTI_MSG,
|
||||||
@ -97,6 +118,20 @@ export class NTQQMsgApi {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getMsgBoxInfo(peer: Peer) {
|
||||||
|
return await callNTQQApi<GeneralCallResult>({
|
||||||
|
methodName: NTQQApiMethod.GET_MSG_BOX_INFO,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
contacts: [
|
||||||
|
peer
|
||||||
|
],
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
static async activateChat(peer: Peer) {
|
static async activateChat(peer: Peer) {
|
||||||
// await this.fetchRecentContact();
|
// await this.fetchRecentContact();
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
@ -105,6 +140,7 @@ export class NTQQMsgApi {
|
|||||||
args: [{ peer, cnt: 20 }, null],
|
args: [{ peer, cnt: 20 }, null],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static async activateChatAndGetHistory(peer: Peer) {
|
static async activateChatAndGetHistory(peer: Peer) {
|
||||||
// await this.fetchRecentContact();
|
// await this.fetchRecentContact();
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
@ -114,6 +150,7 @@ export class NTQQMsgApi {
|
|||||||
args: [{ peer, cnt: 20 }, null],
|
args: [{ peer, cnt: 20 }, null],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getMsgHistory(peer: Peer, msgId: string, count: number) {
|
static async getMsgHistory(peer: Peer, msgId: string, count: number) {
|
||||||
// 消息时间从旧到新
|
// 消息时间从旧到新
|
||||||
return await callNTQQApi<GeneralCallResult & { msgList: RawMessage[] }>({
|
return await callNTQQApi<GeneralCallResult & { msgList: RawMessage[] }>({
|
||||||
@ -129,6 +166,7 @@ export class NTQQMsgApi {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static async fetchRecentContact() {
|
static async fetchRecentContact() {
|
||||||
await callNTQQApi({
|
await callNTQQApi({
|
||||||
methodName: NTQQApiMethod.RECENT_CONTACT,
|
methodName: NTQQApiMethod.RECENT_CONTACT,
|
||||||
@ -164,7 +202,7 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
const waiter = sendWaiter(peer, waitComplete, timeout);
|
const waiter = sendWaiter(peer, waitComplete, timeout)
|
||||||
callNTQQApi({
|
callNTQQApi({
|
||||||
methodName: NTQQApiMethod.SEND_MSG,
|
methodName: NTQQApiMethod.SEND_MSG,
|
||||||
args: [
|
args: [
|
||||||
@ -177,11 +215,11 @@ export class NTQQMsgApi {
|
|||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
}).then()
|
}).then()
|
||||||
return await waiter;
|
return await waiter
|
||||||
}
|
}
|
||||||
|
|
||||||
static async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
static async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
||||||
const waiter = sendWaiter(destPeer, true, 10000);
|
const waiter = sendWaiter(destPeer, true, 10000)
|
||||||
callNTQQApi<GeneralCallResult>({
|
callNTQQApi<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.FORWARD_MSG,
|
methodName: NTQQApiMethod.FORWARD_MSG,
|
||||||
args: [
|
args: [
|
||||||
@ -195,7 +233,7 @@ export class NTQQMsgApi {
|
|||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
}).then().catch(log)
|
}).then().catch(log)
|
||||||
return await waiter;
|
return await waiter
|
||||||
}
|
}
|
||||||
|
|
||||||
static async multiForwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
static async multiForwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
||||||
|
@ -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
|
||||||
|
|
||||||
@ -47,9 +48,12 @@ export class NTQQUserApi {
|
|||||||
return result.profiles.get(uid)
|
return result.profiles.get(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getUserDetailInfo(uid: string, getLevel = false) {
|
static async getUserDetailInfo(uid: string, getLevel = false, withBizInfo = true) {
|
||||||
// this.getUserInfo(uid);
|
// this.getUserInfo(uid);
|
||||||
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
|
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
|
||||||
|
if (!withBizInfo) {
|
||||||
|
methodName = NTQQApiMethod.USER_DETAIL_INFO
|
||||||
|
}
|
||||||
const fetchInfo = async () => {
|
const fetchInfo = async () => {
|
||||||
const result = await callNTQQApi<{ info: User }>({
|
const result = await callNTQQApi<{ info: User }>({
|
||||||
methodName,
|
methodName,
|
||||||
@ -95,7 +99,16 @@ export class NTQQUserApi {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
static async getQzoneCookies() {
|
||||||
|
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin + '&clientkey=' + this.getClientKey() + '&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) {
|
||||||
|
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) {
|
||||||
@ -103,33 +116,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失败')
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,17 @@ export enum NTQQApiMethod {
|
|||||||
HISTORY_MSG = 'nodeIKernelMsgService/getMsgsIncludeSelf',
|
HISTORY_MSG = 'nodeIKernelMsgService/getMsgsIncludeSelf',
|
||||||
GET_MULTI_MSG = 'nodeIKernelMsgService/getMultiMsg',
|
GET_MULTI_MSG = 'nodeIKernelMsgService/getMultiMsg',
|
||||||
DELETE_ACTIVE_CHAT = 'nodeIKernelMsgService/deleteActiveChatByUid',
|
DELETE_ACTIVE_CHAT = 'nodeIKernelMsgService/deleteActiveChatByUid',
|
||||||
|
ENTER_OR_EXIT_AIO = 'nodeIKernelMsgService/enterOrExitAio',
|
||||||
|
|
||||||
LIKE_FRIEND = 'nodeIKernelProfileLikeService/setBuddyProfileLike',
|
LIKE_FRIEND = 'nodeIKernelProfileLikeService/setBuddyProfileLike',
|
||||||
SELF_INFO = 'fetchAuthData',
|
SELF_INFO = 'fetchAuthData',
|
||||||
FRIENDS = 'nodeIKernelBuddyService/getBuddyList',
|
FRIENDS = 'nodeIKernelBuddyService/getBuddyList',
|
||||||
|
|
||||||
GROUPS = 'nodeIKernelGroupService/getGroupList',
|
GROUPS = 'nodeIKernelGroupService/getGroupList',
|
||||||
GROUP_MEMBER_SCENE = 'nodeIKernelGroupService/createMemberListScene',
|
GROUP_MEMBER_SCENE = 'nodeIKernelGroupService/createMemberListScene',
|
||||||
GROUP_MEMBERS = 'nodeIKernelGroupService/getNextMemberList',
|
GROUP_MEMBERS = 'nodeIKernelGroupService/getNextMemberList',
|
||||||
|
GROUP_MEMBERS_INFO = 'nodeIKernelGroupService/getMemberInfo',
|
||||||
|
|
||||||
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',
|
USER_DETAIL_INFO_WITH_BIZ_INFO = 'nodeIKernelProfileService/getUserDetailInfoWithBizInfo',
|
||||||
@ -65,6 +69,10 @@ export enum NTQQApiMethod {
|
|||||||
PUBLISH_GROUP_BULLETIN = 'nodeIKernelGroupService/publishGroupBulletinBulletin',
|
PUBLISH_GROUP_BULLETIN = 'nodeIKernelGroupService/publishGroupBulletinBulletin',
|
||||||
SET_GROUP_NAME = 'nodeIKernelGroupService/modifyGroupName',
|
SET_GROUP_NAME = 'nodeIKernelGroupService/modifyGroupName',
|
||||||
SET_GROUP_TITLE = 'nodeIKernelGroupService/modifyMemberSpecialTitle',
|
SET_GROUP_TITLE = 'nodeIKernelGroupService/modifyMemberSpecialTitle',
|
||||||
|
ACTIVATE_MEMBER_LIST_CHANGE = 'nodeIKernelGroupListener/onMemberListChange',
|
||||||
|
ACTIVATE_MEMBER_INFO_CHANGE = 'nodeIKernelGroupListener/onMemberInfoChange',
|
||||||
|
GET_MSG_BOX_INFO = 'nodeIKernelMsgService/getABatchOfContactMsgBoxInfo',
|
||||||
|
GET_GROUP_ALL_INFO = 'nodeIKernelGroupService/getGroupAllInfo',
|
||||||
|
|
||||||
CACHE_SET_SILENCE = 'nodeIKernelStorageCleanService/setSilentScan',
|
CACHE_SET_SILENCE = 'nodeIKernelStorageCleanService/setSilentScan',
|
||||||
CACHE_ADD_SCANNED_PATH = 'nodeIKernelStorageCleanService/addCacheScanedPaths',
|
CACHE_ADD_SCANNED_PATH = 'nodeIKernelStorageCleanService/addCacheScanedPaths',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export enum GroupNotifyTypes {
|
export enum GroupNotifyTypes {
|
||||||
INVITE_ME = 1,
|
INVITE_ME = 1,
|
||||||
INVITED_JOIN = 4, // 有人接受了邀请入群
|
INVITED_JOIN = 4, // 有人接受了邀请入群
|
||||||
|
JOIN_REQUEST_BY_INVITED = 5, // 有人邀请了别人入群
|
||||||
JOIN_REQUEST = 7,
|
JOIN_REQUEST = 7,
|
||||||
ADMIN_SET = 8,
|
ADMIN_SET = 8,
|
||||||
KICK_MEMBER = 9,
|
KICK_MEMBER = 9,
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
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 {
|
domain: string
|
||||||
domain: string
|
}
|
||||||
}
|
|
||||||
|
export class GetCookies extends BaseAction<Payload, { cookies: string; bkn: string }> {
|
||||||
export class GetCookies extends BaseAction<Payload, { cookies: string; bkn: string }> {
|
actionName = ActionName.GetCookies
|
||||||
actionName = ActionName.GetCookies
|
|
||||||
|
protected async _handle(payload: Payload) {
|
||||||
protected async _handle(payload: Payload) {
|
const domain = payload.domain || 'qun.qq.com'
|
||||||
const domain = payload.domain || 'qun.qq.com'
|
return NTQQUserApi.getCookies(domain);
|
||||||
return NTQQUserApi.getCookies(domain);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -5,6 +5,7 @@ export class OB11GroupRequestEvent extends OB11GroupNoticeEvent {
|
|||||||
post_type = EventType.REQUEST
|
post_type = EventType.REQUEST
|
||||||
request_type: 'group' = 'group'
|
request_type: 'group' = 'group'
|
||||||
sub_type: 'add' | 'invite' = 'add'
|
sub_type: 'add' | 'invite' = 'add'
|
||||||
|
invitor_id: number | undefined = undefined
|
||||||
comment: string
|
comment: string
|
||||||
flag: string
|
flag: string
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user