mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
sync
This commit is contained in:
@@ -33,6 +33,8 @@ export const llonebotError: LLOneBotError = {
|
|||||||
wsServerError: '',
|
wsServerError: '',
|
||||||
otherError: 'LLOnebot未能正常启动,请检查日志查看错误',
|
otherError: 'LLOnebot未能正常启动,请检查日志查看错误',
|
||||||
}
|
}
|
||||||
|
// 群号 -> 群成员map(uid=>GroupMember)
|
||||||
|
export const groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
||||||
|
|
||||||
export async function getFriend(uinOrUid: string): Promise<Friend | undefined> {
|
export async function getFriend(uinOrUid: string): Promise<Friend | undefined> {
|
||||||
let filterKey = isNumeric(uinOrUid.toString()) ? 'uin' : 'uid'
|
let filterKey = isNumeric(uinOrUid.toString()) ? 'uin' : 'uid'
|
||||||
@@ -79,34 +81,32 @@ export function deleteGroup(groupCode: string) {
|
|||||||
export async function getGroupMember(groupQQ: string | number, memberUinOrUid: string | number) {
|
export async function getGroupMember(groupQQ: string | number, memberUinOrUid: string | number) {
|
||||||
groupQQ = groupQQ.toString()
|
groupQQ = groupQQ.toString()
|
||||||
memberUinOrUid = memberUinOrUid.toString()
|
memberUinOrUid = memberUinOrUid.toString()
|
||||||
const group = await getGroup(groupQQ)
|
let members = groupMembers.get(groupQQ)
|
||||||
if (group) {
|
if (!members) {
|
||||||
const filterKey = isNumeric(memberUinOrUid) ? 'uin' : 'uid'
|
try {
|
||||||
const filterValue = memberUinOrUid
|
members = await NTQQGroupApi.getGroupMembers(groupQQ)
|
||||||
let filterFunc: (member: GroupMember) => boolean = (member) => member[filterKey] === filterValue
|
// 更新群成员列表
|
||||||
let member = group.members?.find(filterFunc)
|
groupMembers.set(groupQQ, members)
|
||||||
if (!member) {
|
}
|
||||||
try {
|
catch (e) {
|
||||||
const _members = await NTQQGroupApi.getGroupMembers(groupQQ)
|
return null
|
||||||
if (_members.length > 0) {
|
}
|
||||||
group.members = _members
|
}
|
||||||
}
|
const getMember = () => {
|
||||||
} catch (e) {
|
let member: GroupMember | undefined = undefined
|
||||||
// log("刷新群成员列表失败", e.stack.toString())
|
if (isNumeric(memberUinOrUid)) {
|
||||||
}
|
member = Array.from(members!.values()).find(member => member.uin === memberUinOrUid)
|
||||||
|
} else {
|
||||||
member = group.members?.find(filterFunc)
|
member = members!.get(memberUinOrUid)
|
||||||
}
|
}
|
||||||
return member
|
return member
|
||||||
}
|
}
|
||||||
return null
|
let member = getMember()
|
||||||
}
|
if (!member) {
|
||||||
|
members = await NTQQGroupApi.getGroupMembers(groupQQ)
|
||||||
export async function refreshGroupMembers(groupQQ: string) {
|
member = getMember()
|
||||||
const group = groups.find((group) => group.groupCode === groupQQ)
|
|
||||||
if (group) {
|
|
||||||
group.members = await NTQQGroupApi.getGroupMembers(groupQQ)
|
|
||||||
}
|
}
|
||||||
|
return member
|
||||||
}
|
}
|
||||||
|
|
||||||
export const uidMaps: Record<string, string> = {} // 一串加密的字符串(uid) -> qq号
|
export const uidMaps: Record<string, string> = {} // 一串加密的字符串(uid) -> qq号
|
||||||
|
@@ -33,17 +33,17 @@ if (typeof configVersionInfoPath !== 'string') {
|
|||||||
export { configVersionInfoPath }
|
export { configVersionInfoPath }
|
||||||
|
|
||||||
type QQPkgInfo = {
|
type QQPkgInfo = {
|
||||||
version: string;
|
version: string
|
||||||
buildVersion: string;
|
buildVersion: string
|
||||||
platform: string;
|
platform: string
|
||||||
eleArch: string;
|
eleArch: string
|
||||||
}
|
}
|
||||||
type QQVersionConfigInfo = {
|
type QQVersionConfigInfo = {
|
||||||
baseVersion: string;
|
baseVersion: string
|
||||||
curVersion: string;
|
curVersion: string
|
||||||
prevVersion: string;
|
prevVersion: string
|
||||||
onErrorVersions: Array<any>;
|
onErrorVersions: Array<any>
|
||||||
buildId: string;
|
buildId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let _qqVersionConfigInfo: QQVersionConfigInfo = {
|
let _qqVersionConfigInfo: QQVersionConfigInfo = {
|
||||||
@@ -80,4 +80,8 @@ if (systemPlatform === 'linux') {
|
|||||||
}
|
}
|
||||||
// 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'
|
||||||
|
|
||||||
|
export function getBuildVersion(): number {
|
||||||
|
return +qqPkgInfo.buildVersion
|
||||||
|
}
|
@@ -74,24 +74,50 @@ export function wrapText(str: string, maxLength: number): string {
|
|||||||
* @returns 处理后缓存或调用原方法的结果
|
* @returns 处理后缓存或调用原方法的结果
|
||||||
*/
|
*/
|
||||||
export function cacheFunc(ttl: number, customKey: string = '') {
|
export function cacheFunc(ttl: number, customKey: string = '') {
|
||||||
const cache = new Map<string, { expiry: number; value: any }>();
|
const cache = new Map<string, { expiry: number; value: any }>()
|
||||||
|
|
||||||
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {
|
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {
|
||||||
const originalMethod = descriptor.value;
|
const originalMethod = descriptor.value
|
||||||
const className = target.constructor.name; // 获取类名
|
const className = target.constructor.name // 获取类名
|
||||||
const methodName = propertyKey; // 获取方法名
|
const methodName = propertyKey // 获取方法名
|
||||||
descriptor.value = async function (...args: any[]) {
|
descriptor.value = async function (...args: any[]) {
|
||||||
const cacheKey = `${customKey}${className}.${methodName}:${JSON.stringify(args)}`;
|
const cacheKey = `${customKey}${className}.${methodName}:${JSON.stringify(args)}`
|
||||||
const cached = cache.get(cacheKey);
|
const cached = cache.get(cacheKey)
|
||||||
if (cached && cached.expiry > Date.now()) {
|
if (cached && cached.expiry > Date.now()) {
|
||||||
return cached.value;
|
return cached.value
|
||||||
} else {
|
} else {
|
||||||
const result = await originalMethod.apply(this, args);
|
const result = await originalMethod.apply(this, args)
|
||||||
cache.set(cacheKey, { value: result, expiry: Date.now() + ttl });
|
cache.set(cacheKey, { value: result, expiry: Date.now() + ttl })
|
||||||
return result;
|
return result
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
return descriptor;
|
return descriptor
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: string = '', checker: any = (...data: any[]) => { return true }) {
|
||||||
|
function logExecutionTime(target: any, methodName: string, descriptor: PropertyDescriptor) {
|
||||||
|
const cache = new Map<string, { expiry: number; value: any }>()
|
||||||
|
const originalMethod = descriptor.value
|
||||||
|
descriptor.value = async function (...args: any[]) {
|
||||||
|
const key = `${customKey}${String(methodName)}.(${args.map(arg => JSON.stringify(arg)).join(', ')})`
|
||||||
|
cache.forEach((value, key) => {
|
||||||
|
if (value.expiry < Date.now()) {
|
||||||
|
cache.delete(key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const cachedValue = cache.get(key)
|
||||||
|
if (cachedValue && cachedValue.expiry > Date.now()) {
|
||||||
|
return cachedValue.value
|
||||||
|
}
|
||||||
|
const result = await originalMethod.apply(this, args)
|
||||||
|
if (!checker(...args, result)) {
|
||||||
|
return result //丢弃缓存
|
||||||
|
}
|
||||||
|
cache.set(key, { expiry: Date.now() + ttl, value: result })
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return logExecutionTime
|
||||||
}
|
}
|
71
src/common/utils/table.ts
Normal file
71
src/common/utils/table.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
export class LimitedHashTable<K, V> {
|
||||||
|
private keyToValue: Map<K, V> = new Map()
|
||||||
|
private valueToKey: Map<V, K> = new Map()
|
||||||
|
private maxSize: number
|
||||||
|
|
||||||
|
constructor(maxSize: number) {
|
||||||
|
this.maxSize = maxSize
|
||||||
|
}
|
||||||
|
|
||||||
|
resize(count: number) {
|
||||||
|
this.maxSize = count
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key: K, value: V): void {
|
||||||
|
this.keyToValue.set(key, value)
|
||||||
|
this.valueToKey.set(value, key)
|
||||||
|
while (this.keyToValue.size !== this.valueToKey.size) {
|
||||||
|
console.log('keyToValue.size !== valueToKey.size Error Atom')
|
||||||
|
this.keyToValue.clear()
|
||||||
|
this.valueToKey.clear()
|
||||||
|
}
|
||||||
|
while (this.keyToValue.size > this.maxSize || this.valueToKey.size > this.maxSize) {
|
||||||
|
const oldestKey = this.keyToValue.keys().next().value
|
||||||
|
this.valueToKey.delete(this.keyToValue.get(oldestKey)!)
|
||||||
|
this.keyToValue.delete(oldestKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getValue(key: K): V | undefined {
|
||||||
|
return this.keyToValue.get(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
getKey(value: V): K | undefined {
|
||||||
|
return this.valueToKey.get(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteByValue(value: V): void {
|
||||||
|
const key = this.valueToKey.get(value)
|
||||||
|
if (key !== undefined) {
|
||||||
|
this.keyToValue.delete(key)
|
||||||
|
this.valueToKey.delete(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteByKey(key: K): void {
|
||||||
|
const value = this.keyToValue.get(key)
|
||||||
|
if (value !== undefined) {
|
||||||
|
this.keyToValue.delete(key)
|
||||||
|
this.valueToKey.delete(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getKeyList(): K[] {
|
||||||
|
return Array.from(this.keyToValue.keys())
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取最近刚写入的几个值
|
||||||
|
getHeads(size: number): { key: K; value: V }[] | undefined {
|
||||||
|
const keyList = this.getKeyList()
|
||||||
|
if (keyList.length === 0) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const result: { key: K; value: V }[] = []
|
||||||
|
const listSize = Math.min(size, keyList.length)
|
||||||
|
for (let i = 0; i < listSize; i++) {
|
||||||
|
const key = keyList[listSize - i]
|
||||||
|
result.push({ key, value: this.keyToValue.get(key)! })
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
@@ -21,7 +21,6 @@ import {
|
|||||||
getGroupMember,
|
getGroupMember,
|
||||||
groups,
|
groups,
|
||||||
llonebotError,
|
llonebotError,
|
||||||
refreshGroupMembers,
|
|
||||||
selfInfo,
|
selfInfo,
|
||||||
uidMaps,
|
uidMaps,
|
||||||
} from '../common/data'
|
} from '../common/data'
|
||||||
@@ -443,32 +442,10 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
NTEventDispatch.init({ ListenerMap: wrapperConstructor, WrapperSession: wrapperApi.NodeIQQNTWrapperSession! })
|
NTEventDispatch.init({ ListenerMap: wrapperConstructor, WrapperSession: wrapperApi.NodeIQQNTWrapperSession! })
|
||||||
try {
|
log('start activate group member info')
|
||||||
log('start get groups')
|
NTQQGroupApi.activateMemberInfoChange().then().catch(log)
|
||||||
const _groups = await NTQQGroupApi.getGroups()
|
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
||||||
log('_groups', _groups)
|
startReceiveHook().then()
|
||||||
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 (e) {
|
|
||||||
log('获取群列表失败', e)
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
log('start activate group member info')
|
|
||||||
NTQQGroupApi.activateMemberInfoChange().then().catch(log)
|
|
||||||
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
|
||||||
startReceiveHook().then()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (config.ob11.enableHttp) {
|
if (config.ob11.enableHttp) {
|
||||||
ob11HTTPServer.start(config.ob11.httpPort)
|
ob11HTTPServer.start(config.ob11.httpPort)
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { Friend, FriendRequest, FriendV2 } from '../types'
|
import { Friend, FriendRequest, FriendV2 } from '../types'
|
||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
||||||
import { friendRequests } from '../../common/data'
|
import { friendRequests } from '@/common/data'
|
||||||
import { wrapperApi } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
|
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
|
||||||
import { NTEventDispatch } from '../../common/utils/EventTask'
|
import { NTEventDispatch } from '@/common/utils/EventTask'
|
||||||
|
import { CacheClassFuncAsyncExtend } from '@/common/utils/helper'
|
||||||
|
import { LimitedHashTable } from '@/common/utils/table'
|
||||||
|
|
||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
static async getFriends(forced = false) {
|
static async getFriends(forced = false) {
|
||||||
@@ -69,7 +71,7 @@ export class NTQQFriendApi {
|
|||||||
|
|
||||||
static async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
static async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
const uids: string[] = []
|
const uids: string[] = []
|
||||||
const session = wrapperApi.NodeIQQNTWrapperSession
|
const session = getSession()
|
||||||
const buddyService = session?.getBuddyService()
|
const buddyService = session?.getBuddyService()
|
||||||
const buddyListV2 = refresh ? await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
const buddyListV2 = refresh ? await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
||||||
uids.push(...buddyListV2?.data.flatMap(item => item.buddyUids)!)
|
uids.push(...buddyListV2?.data.flatMap(item => item.buddyUids)!)
|
||||||
@@ -78,4 +80,31 @@ export class NTQQFriendApi {
|
|||||||
)
|
)
|
||||||
return Array.from(data.values())
|
return Array.from(data.values())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CacheClassFuncAsyncExtend(3600 * 1000, 'getBuddyIdMap', () => true)
|
||||||
|
static async getBuddyIdMapCache(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
|
return await NTQQFriendApi.getBuddyIdMap(refresh)
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
|
const uids: string[] = []
|
||||||
|
const retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000)
|
||||||
|
const session = getSession()
|
||||||
|
const buddyService = session?.getBuddyService()
|
||||||
|
const buddyListV2 = refresh ? await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
||||||
|
uids.push(...buddyListV2?.data.flatMap(item => item.buddyUids)!)
|
||||||
|
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
|
);
|
||||||
|
data.forEach((value, key) => {
|
||||||
|
retMap.set(value.uin!, value.uid!)
|
||||||
|
})
|
||||||
|
//console.log('getBuddyIdMap', retMap.getValue)
|
||||||
|
return retMap
|
||||||
|
}
|
||||||
|
|
||||||
|
static async isBuddy(uid: string): Promise<boolean> {
|
||||||
|
const session = getSession()
|
||||||
|
return session?.getBuddyService().isBuddy(uid)!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ import { deleteGroup, uidMaps } from '../../common/data'
|
|||||||
import { dbUtil } from '../../common/db'
|
import { dbUtil } from '../../common/db'
|
||||||
import { log } from '../../common/utils/log'
|
import { log } from '../../common/utils/log'
|
||||||
import { NTQQWindowApi, NTQQWindows } from './window'
|
import { NTQQWindowApi, NTQQWindows } from './window'
|
||||||
import { wrapperApi } from '../wrapper'
|
import { getSession } from '../wrapper'
|
||||||
|
|
||||||
export class NTQQGroupApi {
|
export class NTQQGroupApi {
|
||||||
static async activateMemberListChange() {
|
static async activateMemberListChange() {
|
||||||
@@ -55,45 +55,15 @@ export class NTQQGroupApi {
|
|||||||
return result.groupList
|
return result.groupList
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getGroupMembers(groupQQ: string, num = 3000): Promise<GroupMember[]> {
|
static async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
const sceneId = await callNTQQApi({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.GROUP_MEMBER_SCENE,
|
const groupService = session?.getGroupService()
|
||||||
args: [
|
const sceneId = groupService?.createMemberListScene(groupQQ, 'groupMemberList_MainWindow')
|
||||||
{
|
const result = await groupService?.getNextMemberList(sceneId!, undefined, num)
|
||||||
groupCode: groupQQ,
|
if (result?.errCode !== 0) {
|
||||||
scene: 'groupMemberList_MainWindow',
|
throw ('获取群成员列表出错,' + result?.errMsg)
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
// log("get group member sceneId", sceneId)
|
|
||||||
try {
|
|
||||||
const result = await callNTQQApi<{
|
|
||||||
result: { infos: any }
|
|
||||||
}>({
|
|
||||||
methodName: NTQQApiMethod.GROUP_MEMBERS,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
sceneId: sceneId,
|
|
||||||
num: num,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
// log("members info", typeof result.result.infos, Object.keys(result.result.infos))
|
|
||||||
const values = result.result.infos.values()
|
|
||||||
|
|
||||||
const members: GroupMember[] = Array.from(values)
|
|
||||||
for (const member of members) {
|
|
||||||
uidMaps[member.uid] = member.uin
|
|
||||||
}
|
|
||||||
// log(uidMaps)
|
|
||||||
// log("members info", values)
|
|
||||||
log(`get group ${groupQQ} members success`)
|
|
||||||
return members
|
|
||||||
} catch (e) {
|
|
||||||
log(`get group ${groupQQ} members failed`, e)
|
|
||||||
return []
|
|
||||||
}
|
}
|
||||||
|
return result.result.infos
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getGroupMembersInfo(groupCode: string, uids: string[], forceUpdate: boolean = false) {
|
static async getGroupMembersInfo(groupCode: string, uids: string[], forceUpdate: boolean = false) {
|
||||||
@@ -300,7 +270,7 @@ export class NTQQGroupApi {
|
|||||||
static publishGroupBulletin(groupQQ: string, title: string, content: string) { }
|
static publishGroupBulletin(groupQQ: string, title: string, content: string) { }
|
||||||
|
|
||||||
static async removeGroupEssence(GroupCode: string, msgId: string) {
|
static async removeGroupEssence(GroupCode: string, msgId: string) {
|
||||||
const session = wrapperApi.NodeIQQNTWrapperSession
|
const session = getSession()
|
||||||
// 代码没测过
|
// 代码没测过
|
||||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||||
let MsgData = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false)
|
let MsgData = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false)
|
||||||
@@ -314,7 +284,7 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async addGroupEssence(GroupCode: string, msgId: string) {
|
static async addGroupEssence(GroupCode: string, msgId: string) {
|
||||||
const session = wrapperApi.NodeIQQNTWrapperSession
|
const session = getSession()
|
||||||
// 代码没测过
|
// 代码没测过
|
||||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||||
let MsgData = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false)
|
let MsgData = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false)
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import { callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod } from '../ntcall'
|
import { callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod } from '../ntcall'
|
||||||
import { Group, SelfInfo, User } from '../types'
|
import { SelfInfo, User, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '../types'
|
||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { selfInfo, uidMaps } from '../../common/data'
|
import { selfInfo, uidMaps, friends, groupMembers } from '@/common/data'
|
||||||
import { cacheFunc, isQQ998, log, sleep } from '../../common/utils'
|
import { cacheFunc, isQQ998, log, sleep, getBuildVersion } from '@/common/utils'
|
||||||
import { wrapperApi } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { RequestUtil } from '@/common/utils/request'
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services'
|
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services'
|
||||||
import { NodeIKernelProfileListener } from '../listeners'
|
import { NodeIKernelProfileListener } from '../listeners'
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask'
|
import { NTEventDispatch } from '@/common/utils/EventTask'
|
||||||
import { qqPkgInfo } from '@/common/utils/QQBasicInfo'
|
import { NTQQFriendApi } from './friend'
|
||||||
|
|
||||||
const userInfoCache: Record<string, User> = {} // uid: User
|
const userInfoCache: Record<string, User> = {} // uid: User
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ export class NTQQUserApi {
|
|||||||
return result.profiles.get(uid)
|
return result.profiles.get(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 26702
|
/** 26702 */
|
||||||
static async fetchUserDetailInfo(uid: string) {
|
static async fetchUserDetailInfo(uid: string) {
|
||||||
type EventService = NodeIKernelProfileService['fetchUserDetailInfo']
|
type EventService = NodeIKernelProfileService['fetchUserDetailInfo']
|
||||||
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged']
|
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged']
|
||||||
@@ -63,9 +63,9 @@ export class NTQQUserApi {
|
|||||||
5000,
|
5000,
|
||||||
(profile) => {
|
(profile) => {
|
||||||
if (profile.uid === uid) {
|
if (profile.uid === uid) {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
},
|
},
|
||||||
'BuddyProfileStore',
|
'BuddyProfileStore',
|
||||||
[
|
[
|
||||||
@@ -89,7 +89,7 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getUserDetailInfo(uid: string, getLevel = false, withBizInfo = true) {
|
static async getUserDetailInfo(uid: string, getLevel = false, withBizInfo = true) {
|
||||||
if (+qqPkgInfo.buildVersion >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return this.fetchUserDetailInfo(uid)
|
return this.fetchUserDetailInfo(uid)
|
||||||
}
|
}
|
||||||
// this.getUserInfo(uid)
|
// this.getUserInfo(uid)
|
||||||
@@ -195,7 +195,7 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getPSkey(domains: string[]): Promise<Map<string, string>> {
|
static async getPSkey(domains: string[]): Promise<Map<string, string>> {
|
||||||
const session = wrapperApi.NodeIQQNTWrapperSession
|
const session = getSession()
|
||||||
const res = await session?.getTipOffService().getPskey(domains, true)
|
const res = await session?.getTipOffService().getPskey(domains, true)
|
||||||
if (res.result !== 0) {
|
if (res.result !== 0) {
|
||||||
throw new Error(`获取Pskey失败: ${res.errMsg}`)
|
throw new Error(`获取Pskey失败: ${res.errMsg}`)
|
||||||
@@ -204,7 +204,91 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getClientKey(): Promise<ClientKeyData> {
|
static async getClientKey(): Promise<ClientKeyData> {
|
||||||
const session = wrapperApi.NodeIQQNTWrapperSession
|
const session = getSession()
|
||||||
return await session?.getTicketService().forceFetchClientKey('')
|
return await session?.getTicketService().forceFetchClientKey('')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async like(uid: string, count = 1): Promise<{ result: number, errMsg: string, succCounts: number }> {
|
||||||
|
const session = getSession()
|
||||||
|
return session?.getProfileLikeService().setBuddyProfileLike({
|
||||||
|
friendUid: uid,
|
||||||
|
sourceId: 71,
|
||||||
|
doLikeCount: count,
|
||||||
|
doLikeTollCount: 0
|
||||||
|
})!
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUidByUinV1(Uin: string) {
|
||||||
|
const session = getSession()
|
||||||
|
// 通用转换开始尝试
|
||||||
|
let uid = (await session?.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
||||||
|
// Uid 好友转
|
||||||
|
if (!uid) {
|
||||||
|
friends.forEach((t) => {
|
||||||
|
if (t.uin == Uin) {
|
||||||
|
uid = t.uid
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//Uid 群友列表转
|
||||||
|
if (!uid) {
|
||||||
|
for (let groupMembersList of groupMembers.values()) {
|
||||||
|
for (let GroupMember of groupMembersList.values()) {
|
||||||
|
if (GroupMember.uin == Uin) {
|
||||||
|
uid = GroupMember.uid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!uid) {
|
||||||
|
let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUin(Uin)).info.uid;//从QQ Native 特殊转换 方法三
|
||||||
|
if (unveifyUid.indexOf('*') == -1) {
|
||||||
|
uid = unveifyUid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uid
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUidByUinV2(Uin: string) {
|
||||||
|
const session = getSession()
|
||||||
|
let uid = (await session?.getProfileService().getUidByUin('FriendsServiceImpl', [Uin])!).get(Uin)
|
||||||
|
if (uid) return uid
|
||||||
|
uid = (await session?.getGroupService().getUidByUins([Uin])!).uids.get(Uin)
|
||||||
|
if (uid) return uid
|
||||||
|
uid = (await session?.getUixConvertService().getUid([Uin])).uidInfo.get(Uin)
|
||||||
|
if (uid) return uid
|
||||||
|
console.log((await NTQQFriendApi.getBuddyIdMapCache(true)))
|
||||||
|
uid = (await NTQQFriendApi.getBuddyIdMapCache(true)).getValue(Uin)//从Buddy缓存获取Uid
|
||||||
|
if (uid) return uid
|
||||||
|
uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin)
|
||||||
|
if (uid) return uid
|
||||||
|
let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUinV2(Uin)).detail.uid//从QQ Native 特殊转换
|
||||||
|
if (unveifyUid.indexOf("*") == -1) uid = unveifyUid
|
||||||
|
//if (uid) return uid
|
||||||
|
return uid
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUidByUin(Uin: string) {
|
||||||
|
if (getBuildVersion() >= 26702) {
|
||||||
|
return await NTQQUserApi.getUidByUinV2(Uin)
|
||||||
|
}
|
||||||
|
return await NTQQUserApi.getUidByUinV1(Uin)
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUserDetailInfoByUinV2(Uin: string) {
|
||||||
|
return await NTEventDispatch.CallNoListenerEvent
|
||||||
|
<(Uin: string) => Promise<UserDetailInfoByUinV2>>(
|
||||||
|
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
|
5000,
|
||||||
|
Uin
|
||||||
|
)
|
||||||
|
}
|
||||||
|
static async getUserDetailInfoByUin(Uin: string) {
|
||||||
|
return NTEventDispatch.CallNoListenerEvent
|
||||||
|
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
||||||
|
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
|
5000,
|
||||||
|
Uin
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ import { log } from '../common/utils/log'
|
|||||||
import { defaultVideoThumb, getVideoInfo } from '../common/utils/video'
|
import { defaultVideoThumb, getVideoInfo } from '../common/utils/video'
|
||||||
import { encodeSilk } from '../common/utils/audio'
|
import { encodeSilk } from '../common/utils/audio'
|
||||||
import { isNull } from '../common/utils'
|
import { isNull } from '../common/utils'
|
||||||
import faceConfig from './face_config.json';
|
import faceConfig from './face_config.json'
|
||||||
|
|
||||||
export const mFaceCache = new Map<string, string>() // emojiId -> faceName
|
export const mFaceCache = new Map<string, string>() // emojiId -> faceName
|
||||||
|
|
||||||
|
@@ -268,7 +268,7 @@ async function updateGroups(_groups: Group[], needUpdate: boolean = true) {
|
|||||||
const members = await NTQQGroupApi.getGroupMembers(group.groupCode)
|
const members = await NTQQGroupApi.getGroupMembers(group.groupCode)
|
||||||
|
|
||||||
if (members) {
|
if (members) {
|
||||||
existGroup.members = members
|
existGroup.members = Array.from(members.values())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,11 +287,11 @@ async function processGroupEvent(payload: { groupList: Group[] }) {
|
|||||||
await sleep(200) // 如果请求QQ API的速度过快,通常无法正确拉取到最新的群信息,因此这里人为引入一个延时
|
await sleep(200) // 如果请求QQ API的速度过快,通常无法正确拉取到最新的群信息,因此这里人为引入一个延时
|
||||||
const newMembers = await NTQQGroupApi.getGroupMembers(group.groupCode)
|
const newMembers = await NTQQGroupApi.getGroupMembers(group.groupCode)
|
||||||
|
|
||||||
group.members = newMembers
|
group.members = Array.from(newMembers.values())
|
||||||
const newMembersSet = new Set<string>() // 建立索引降低时间复杂度
|
const newMembersSet = new Set<string>() // 建立索引降低时间复杂度
|
||||||
|
|
||||||
for (const member of newMembers) {
|
for (const member of newMembers) {
|
||||||
newMembersSet.add(member.uin)
|
newMembersSet.add(member[1].uin)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
// 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
||||||
|
240
src/ntqqapi/listeners/NodeIKernelGroupListener.ts
Normal file
240
src/ntqqapi/listeners/NodeIKernelGroupListener.ts
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
import { Group, GroupListUpdateType, GroupMember, GroupNotify } from '@/ntqqapi/types'
|
||||||
|
|
||||||
|
interface IGroupListener {
|
||||||
|
onGroupListUpdate(updateType: GroupListUpdateType, groupList: Group[]): void
|
||||||
|
|
||||||
|
onGroupExtListUpdate(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupSingleScreenNotifies(doubt: boolean, seq: string, notifies: GroupNotify[]): void
|
||||||
|
|
||||||
|
onGroupNotifiesUpdated(dboubt: boolean, notifies: GroupNotify[]): void
|
||||||
|
|
||||||
|
onGroupNotifiesUnreadCountUpdated(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupDetailInfoChange(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupAllInfoChange(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupsMsgMaskResult(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupConfMemberChange(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupBulletinChange(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGetGroupBulletinListResult(...args: unknown[]): void
|
||||||
|
|
||||||
|
onMemberListChange(arg: {
|
||||||
|
sceneId: string,
|
||||||
|
ids: string[],
|
||||||
|
infos: Map<string, GroupMember>,
|
||||||
|
finish: boolean,
|
||||||
|
hasRobot: boolean
|
||||||
|
}): void
|
||||||
|
|
||||||
|
onMemberInfoChange(groupCode: string, changeType: number, members: Map<string, GroupMember>): void
|
||||||
|
|
||||||
|
onSearchMemberChange(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupBulletinRichMediaDownloadComplete(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupBulletinRichMediaProgressUpdate(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupStatisticInfoChange(...args: unknown[]): void
|
||||||
|
|
||||||
|
onJoinGroupNotify(...args: unknown[]): void
|
||||||
|
|
||||||
|
onShutUpMemberListChanged(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupBulletinRemindNotify(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupFirstBulletinNotify(...args: unknown[]): void
|
||||||
|
|
||||||
|
onJoinGroupNoVerifyFlag(...args: unknown[]): void
|
||||||
|
|
||||||
|
onGroupArkInviteStateResult(...args: unknown[]): void
|
||||||
|
// 发现于Win 9.9.9 23159
|
||||||
|
onGroupMemberLevelInfoChange(...args: unknown[]): void
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NodeIKernelGroupListener extends IGroupListener {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||||
|
new(listener: IGroupListener): NodeIKernelGroupListener
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GroupListener implements IGroupListener {
|
||||||
|
// 发现于Win 9.9.9 23159
|
||||||
|
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
||||||
|
|
||||||
|
}
|
||||||
|
onGetGroupBulletinListResult(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupAllInfoChange(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinChange(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinRemindNotify(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupArkInviteStateResult(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinRichMediaDownloadComplete(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupConfMemberChange(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupDetailInfoChange(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupExtListUpdate(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupFirstBulletinNotify(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupListUpdate(updateType: GroupListUpdateType, groupList: Group[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupNotifiesUpdated(dboubt: boolean, notifies: GroupNotify[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinRichMediaProgressUpdate(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupNotifiesUnreadCountUpdated(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupSingleScreenNotifies(doubt: boolean, seq: string, notifies: GroupNotify[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupsMsgMaskResult(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupStatisticInfoChange(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onJoinGroupNotify(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onJoinGroupNoVerifyFlag(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onMemberInfoChange(groupCode: string, changeType: number, members: Map<string, GroupMember>) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onMemberListChange(arg: {
|
||||||
|
sceneId: string,
|
||||||
|
ids: string[],
|
||||||
|
infos: Map<string, GroupMember>, // uid -> GroupMember
|
||||||
|
finish: boolean,
|
||||||
|
hasRobot: boolean
|
||||||
|
}) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onSearchMemberChange(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
onShutUpMemberListChanged(...args: unknown[]) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DebugGroupListener implements IGroupListener {
|
||||||
|
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
||||||
|
console.log('onGroupMemberLevelInfoChange:', ...args)
|
||||||
|
}
|
||||||
|
onGetGroupBulletinListResult(...args: unknown[]) {
|
||||||
|
console.log('onGetGroupBulletinListResult:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupAllInfoChange(...args: unknown[]) {
|
||||||
|
console.log('onGroupAllInfoChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinChange(...args: unknown[]) {
|
||||||
|
console.log('onGroupBulletinChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinRemindNotify(...args: unknown[]) {
|
||||||
|
console.log('onGroupBulletinRemindNotify:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupArkInviteStateResult(...args: unknown[]) {
|
||||||
|
console.log('onGroupArkInviteStateResult:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinRichMediaDownloadComplete(...args: unknown[]) {
|
||||||
|
console.log('onGroupBulletinRichMediaDownloadComplete:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupConfMemberChange(...args: unknown[]) {
|
||||||
|
console.log('onGroupConfMemberChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupDetailInfoChange(...args: unknown[]) {
|
||||||
|
console.log('onGroupDetailInfoChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupExtListUpdate(...args: unknown[]) {
|
||||||
|
console.log('onGroupExtListUpdate:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupFirstBulletinNotify(...args: unknown[]) {
|
||||||
|
console.log('onGroupFirstBulletinNotify:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupListUpdate(...args: unknown[]) {
|
||||||
|
console.log('onGroupListUpdate:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupNotifiesUpdated(...args: unknown[]) {
|
||||||
|
console.log('onGroupNotifiesUpdated:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupBulletinRichMediaProgressUpdate(...args: unknown[]) {
|
||||||
|
console.log('onGroupBulletinRichMediaProgressUpdate:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupNotifiesUnreadCountUpdated(...args: unknown[]) {
|
||||||
|
console.log('onGroupNotifiesUnreadCountUpdated:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupSingleScreenNotifies(doubt: boolean, seq: string, notifies: GroupNotify[]) {
|
||||||
|
console.log('onGroupSingleScreenNotifies:')
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupsMsgMaskResult(...args: unknown[]) {
|
||||||
|
console.log('onGroupsMsgMaskResult:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onGroupStatisticInfoChange(...args: unknown[]) {
|
||||||
|
console.log('onGroupStatisticInfoChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onJoinGroupNotify(...args: unknown[]) {
|
||||||
|
console.log('onJoinGroupNotify:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onJoinGroupNoVerifyFlag(...args: unknown[]) {
|
||||||
|
console.log('onJoinGroupNoVerifyFlag:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMemberInfoChange(groupCode: string, changeType: number, members: Map<string, GroupMember>) {
|
||||||
|
console.log('onMemberInfoChange:', groupCode, changeType, members)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMemberListChange(...args: unknown[]) {
|
||||||
|
console.log('onMemberListChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onSearchMemberChange(...args: unknown[]) {
|
||||||
|
console.log('onSearchMemberChange:', ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
onShutUpMemberListChanged(...args: unknown[]) {
|
||||||
|
console.log('onShutUpMemberListChanged:', ...args)
|
||||||
|
}
|
||||||
|
}
|
@@ -1 +1,2 @@
|
|||||||
export * from './NodeIKernelProfileListener'
|
export * from './NodeIKernelProfileListener'
|
||||||
|
export * from './NodeIKernelGroupListener'
|
249
src/ntqqapi/services/NodeIKernelGroupService.ts
Normal file
249
src/ntqqapi/services/NodeIKernelGroupService.ts
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
import { NodeIKernelGroupListener } from '@/ntqqapi/listeners'
|
||||||
|
import {
|
||||||
|
GroupExtParam,
|
||||||
|
GroupMember,
|
||||||
|
GroupMemberRole,
|
||||||
|
GroupNotifyTypes,
|
||||||
|
GroupRequestOperateTypes,
|
||||||
|
} from '@/ntqqapi/types'
|
||||||
|
import { GeneralCallResult } from './common'
|
||||||
|
|
||||||
|
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
||||||
|
|
||||||
|
export interface NodeIKernelGroupService {
|
||||||
|
getMemberCommonInfo(Req: {
|
||||||
|
groupCode: string,
|
||||||
|
startUin: string,
|
||||||
|
identifyFlag: string,
|
||||||
|
uinList: string[],
|
||||||
|
memberCommonFilter: {
|
||||||
|
memberUin: number,
|
||||||
|
uinFlag: number,
|
||||||
|
uinFlagExt: number,
|
||||||
|
uinMobileFlag: number,
|
||||||
|
shutUpTime: number,
|
||||||
|
privilege: number,
|
||||||
|
},
|
||||||
|
memberNum: number,
|
||||||
|
filterMethod: string,
|
||||||
|
onlineFlag: string,
|
||||||
|
realSpecialTitleFlag: number
|
||||||
|
}): Promise<unknown>
|
||||||
|
//26702
|
||||||
|
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>
|
||||||
|
//26702
|
||||||
|
getGroupHonorList(groupCodes: Array<string>): unknown
|
||||||
|
|
||||||
|
getUinByUids(uins: string[]): Promise<{
|
||||||
|
errCode: number,
|
||||||
|
errMsg: string,
|
||||||
|
uins: Map<string, string>
|
||||||
|
}>
|
||||||
|
|
||||||
|
getUidByUins(uins: string[]): Promise<{
|
||||||
|
errCode: number,
|
||||||
|
errMsg: string,
|
||||||
|
uids: Map<string, string>
|
||||||
|
}>
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>
|
||||||
|
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
getGroupLatestEssenceList(groupCode: string): Promise<unknown>
|
||||||
|
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
shareDigest(Req: {
|
||||||
|
appId: string,
|
||||||
|
appType: number,
|
||||||
|
msgStyle: number,
|
||||||
|
recvUin: string,
|
||||||
|
sendType: number,
|
||||||
|
clientInfo: {
|
||||||
|
platform: number
|
||||||
|
},
|
||||||
|
richMsg: {
|
||||||
|
usingArk: boolean,
|
||||||
|
title: string,
|
||||||
|
summary: string,
|
||||||
|
url: string,
|
||||||
|
pictureUrl: string,
|
||||||
|
brief: string
|
||||||
|
}
|
||||||
|
}): Promise<unknown>
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
fetchGroupEssenceList(Req: { groupCode: string, pageStart: number, pageLimit: number }, Arg: unknown): Promise<unknown>
|
||||||
|
//26702
|
||||||
|
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
||||||
|
errCode: number,
|
||||||
|
errMsg: string,
|
||||||
|
result: {
|
||||||
|
ids: Array<{
|
||||||
|
uid: string,
|
||||||
|
index: number//0
|
||||||
|
}>,
|
||||||
|
infos: {},
|
||||||
|
finish: true,
|
||||||
|
hasRobot: false
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
|
||||||
|
setHeader(uid: string, path: string): unknown
|
||||||
|
|
||||||
|
addKernelGroupListener(listener: NodeIKernelGroupListener): number
|
||||||
|
|
||||||
|
removeKernelGroupListener(listenerId: unknown): void
|
||||||
|
|
||||||
|
createMemberListScene(groupCode: string, scene: string): string
|
||||||
|
|
||||||
|
destroyMemberListScene(SceneId: string): void
|
||||||
|
//About Arg (a) name: lastId 根据手Q来看为object {index:?(number),uid:string}
|
||||||
|
getNextMemberList(sceneId: string, a: undefined, num: number): Promise<{
|
||||||
|
errCode: number, errMsg: string,
|
||||||
|
result: { ids: string[], infos: Map<string, GroupMember>, finish: boolean, hasRobot: boolean }
|
||||||
|
}>
|
||||||
|
|
||||||
|
getPrevMemberList(): unknown
|
||||||
|
|
||||||
|
monitorMemberList(): unknown
|
||||||
|
|
||||||
|
searchMember(sceneId: string, keywords: string[]): unknown
|
||||||
|
|
||||||
|
getMemberInfo(group_id: string, uids: string[], forceFetch: boolean): Promise<GeneralCallResult>
|
||||||
|
//getMemberInfo [ '56729xxxx', [ 'u_4Nj08cwW5Hxxxxx' ], true ]
|
||||||
|
|
||||||
|
kickMember(groupCode: string, memberUids: string[], refuseForever: boolean, kickReason: string): Promise<void>
|
||||||
|
|
||||||
|
modifyMemberRole(groupCode: string, uid: string, role: GroupMemberRole): void
|
||||||
|
|
||||||
|
modifyMemberCardName(groupCode: string, uid: string, cardName: string): void
|
||||||
|
|
||||||
|
getTransferableMemberInfo(groupCode: string): unknown//获取整个群的
|
||||||
|
|
||||||
|
transferGroup(uid: string): void
|
||||||
|
|
||||||
|
getGroupList(force: boolean): Promise<GeneralCallResult>
|
||||||
|
|
||||||
|
getGroupExtList(force: boolean): Promise<GeneralCallResult>
|
||||||
|
|
||||||
|
getGroupDetailInfo(groupCode: string): unknown
|
||||||
|
|
||||||
|
getMemberExtInfo(param: GroupExtParam): Promise<unknown>//req
|
||||||
|
|
||||||
|
getGroupAllInfo(): unknown
|
||||||
|
|
||||||
|
getDiscussExistInfo(): unknown
|
||||||
|
|
||||||
|
getGroupConfMember(): unknown
|
||||||
|
|
||||||
|
getGroupMsgMask(): unknown
|
||||||
|
|
||||||
|
getGroupPortrait(): void
|
||||||
|
|
||||||
|
modifyGroupName(groupCode: string, groupName: string, arg: false): void
|
||||||
|
|
||||||
|
modifyGroupRemark(groupCode: string, remark: string): void
|
||||||
|
|
||||||
|
modifyGroupDetailInfo(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
setGroupMsgMask(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
changeGroupShieldSettingTemp(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
inviteToGroup(arg: unknown): void
|
||||||
|
|
||||||
|
inviteMembersToGroup(args: unknown[]): void
|
||||||
|
|
||||||
|
inviteMembersToGroupWithMsg(args: unknown): void
|
||||||
|
|
||||||
|
createGroup(arg: unknown): void
|
||||||
|
|
||||||
|
createGroupWithMembers(arg: unknown): void
|
||||||
|
|
||||||
|
quitGroup(groupCode: string): void
|
||||||
|
|
||||||
|
destroyGroup(groupCode: string): void
|
||||||
|
//获取单屏群通知列表
|
||||||
|
getSingleScreenNotifies(force: boolean, start_seq: string, num: number): Promise<GeneralCallResult>
|
||||||
|
|
||||||
|
clearGroupNotifies(groupCode: string): void
|
||||||
|
|
||||||
|
getGroupNotifiesUnreadCount(unknown: Boolean): Promise<GeneralCallResult>
|
||||||
|
|
||||||
|
clearGroupNotifiesUnreadCount(groupCode: string): void
|
||||||
|
|
||||||
|
operateSysNotify(
|
||||||
|
doubt: boolean,
|
||||||
|
operateMsg: {
|
||||||
|
operateType: GroupRequestOperateTypes, // 2 拒绝
|
||||||
|
targetMsg: {
|
||||||
|
seq: string, // 通知序列号
|
||||||
|
type: GroupNotifyTypes,
|
||||||
|
groupCode: string,
|
||||||
|
postscript: string
|
||||||
|
}
|
||||||
|
}): Promise<void>
|
||||||
|
|
||||||
|
setTop(groupCode: string, isTop: boolean): void
|
||||||
|
|
||||||
|
getGroupBulletin(groupCode: string): unknown
|
||||||
|
|
||||||
|
deleteGroupBulletin(groupCode: string, seq: string): void
|
||||||
|
|
||||||
|
publishGroupBulletin(groupCode: string, pskey: string, data: any): Promise<GeneralCallResult>
|
||||||
|
|
||||||
|
publishInstructionForNewcomers(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
uploadGroupBulletinPic(groupCode: string, pskey: string, imagePath: string): Promise<GeneralCallResult & {
|
||||||
|
errCode: number
|
||||||
|
picInfo?: {
|
||||||
|
id: string,
|
||||||
|
width: number,
|
||||||
|
height: number
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
|
||||||
|
downloadGroupBulletinRichMedia(groupCode: string): unknown
|
||||||
|
|
||||||
|
getGroupBulletinList(groupCode: string): unknown
|
||||||
|
|
||||||
|
getGroupStatisticInfo(groupCode: string): unknown
|
||||||
|
|
||||||
|
getGroupRemainAtTimes(groupCode: string): number
|
||||||
|
|
||||||
|
getJoinGroupNoVerifyFlag(groupCode: string): unknown
|
||||||
|
|
||||||
|
getGroupArkInviteState(groupCode: string): unknown
|
||||||
|
|
||||||
|
reqToJoinGroup(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
setGroupShutUp(groupCode: string, shutUp: boolean): void
|
||||||
|
|
||||||
|
getGroupShutUpMemberList(groupCode: string): unknown[]
|
||||||
|
|
||||||
|
setMemberShutUp(groupCode: string, memberTimes: { uid: string, timeStamp: number }[]): Promise<void>
|
||||||
|
|
||||||
|
getGroupRecommendContactArkJson(groupCode: string): unknown
|
||||||
|
|
||||||
|
getJoinGroupLink(groupCode: string): unknown
|
||||||
|
|
||||||
|
modifyGroupExtInfo(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
//需要提前判断是否存在 高版本新增
|
||||||
|
addGroupEssence(param: {
|
||||||
|
groupCode: string
|
||||||
|
msgRandom: number,
|
||||||
|
msgSeq: number
|
||||||
|
}): Promise<unknown>
|
||||||
|
//需要提前判断是否存在 高版本新增
|
||||||
|
removeGroupEssence(param: {
|
||||||
|
groupCode: string
|
||||||
|
msgRandom: number,
|
||||||
|
msgSeq: number
|
||||||
|
}): Promise<unknown>
|
||||||
|
|
||||||
|
isNull(): boolean
|
||||||
|
}
|
22
src/ntqqapi/services/NodeIKernelProfileLikeService.ts
Normal file
22
src/ntqqapi/services/NodeIKernelProfileLikeService.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { BuddyProfileLikeReq } from '../types'
|
||||||
|
import { GeneralCallResult } from './common'
|
||||||
|
|
||||||
|
export interface NodeIKernelProfileLikeService {
|
||||||
|
addKernelProfileLikeListener(listener: NodeIKernelProfileLikeService): void
|
||||||
|
|
||||||
|
removeKernelProfileLikeListener(listener: unknown): void
|
||||||
|
|
||||||
|
setBuddyProfileLike(...args: unknown[]): { result: number, errMsg: string, succCounts: number }
|
||||||
|
|
||||||
|
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
||||||
|
'info': {
|
||||||
|
'userLikeInfos': Array<any>,
|
||||||
|
'friendMaxVotes': number,
|
||||||
|
'start': number
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
|
||||||
|
getProfileLikeScidResourceInfo(...args: unknown[]): void
|
||||||
|
|
||||||
|
isNull(): boolean
|
||||||
|
}
|
@@ -1,2 +1,4 @@
|
|||||||
export * from './NodeIKernelBuddyService'
|
export * from './NodeIKernelBuddyService'
|
||||||
export * from './NodeIKernelProfileService'
|
export * from './NodeIKernelProfileService'
|
||||||
|
export * from './NodeIKernelGroupService'
|
||||||
|
export * from './NodeIKernelProfileLikeService'
|
@@ -1,5 +1,12 @@
|
|||||||
import { QQLevel, Sex } from './user'
|
import { QQLevel, Sex } from './user'
|
||||||
|
|
||||||
|
export enum GroupListUpdateType {
|
||||||
|
REFRESHALL,
|
||||||
|
GETALL,
|
||||||
|
MODIFIED,
|
||||||
|
REMOVE
|
||||||
|
}
|
||||||
|
|
||||||
export interface Group {
|
export interface Group {
|
||||||
groupCode: string
|
groupCode: string
|
||||||
maxMember: number
|
maxMember: number
|
||||||
|
@@ -64,3 +64,41 @@ export interface FriendRequestNotify {
|
|||||||
buddyReqs: FriendRequest[]
|
buddyReqs: FriendRequest[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum MemberExtSourceType {
|
||||||
|
DEFAULTTYPE = 0,
|
||||||
|
TITLETYPE = 1,
|
||||||
|
NEWGROUPTYPE = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupExtParam {
|
||||||
|
groupCode: string
|
||||||
|
seq: string
|
||||||
|
beginUin: string
|
||||||
|
dataTime: string
|
||||||
|
uinList: Array<string>
|
||||||
|
uinNum: string
|
||||||
|
groupType: string
|
||||||
|
richCardNameVer: string
|
||||||
|
sourceType: MemberExtSourceType
|
||||||
|
memberExtFilter: {
|
||||||
|
memberLevelInfoUin: number
|
||||||
|
memberLevelInfoPoint: number
|
||||||
|
memberLevelInfoActiveDay: number
|
||||||
|
memberLevelInfoLevel: number
|
||||||
|
memberLevelInfoName: number
|
||||||
|
levelName: number
|
||||||
|
dataTime: number
|
||||||
|
userShowFlag: number
|
||||||
|
sysShowFlag: number
|
||||||
|
timeToUpdate: number
|
||||||
|
nickName: number
|
||||||
|
specialTitle: number
|
||||||
|
levelNameNew: number
|
||||||
|
userShowFlagNew: number
|
||||||
|
msgNeedField: number
|
||||||
|
cmdUinFlagExt3Grocery: number
|
||||||
|
memberIcon: number
|
||||||
|
memberInfoSeq: number
|
||||||
|
}
|
||||||
|
}
|
@@ -258,4 +258,86 @@ export interface UserDetailInfoListenerArg {
|
|||||||
simpleInfo: SimpleInfo
|
simpleInfo: SimpleInfo
|
||||||
commonExt: CommonExt
|
commonExt: CommonExt
|
||||||
photoWall: PhotoWall
|
photoWall: PhotoWall
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BuddyProfileLikeReq {
|
||||||
|
friendUids: string[]
|
||||||
|
basic: number
|
||||||
|
vote: number
|
||||||
|
favorite: number
|
||||||
|
userProfile: number
|
||||||
|
type: number
|
||||||
|
start: number
|
||||||
|
limit: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserDetailInfoByUinV2 {
|
||||||
|
result: number
|
||||||
|
errMsg: string
|
||||||
|
detail: {
|
||||||
|
uid: string
|
||||||
|
uin: string
|
||||||
|
simpleInfo: SimpleInfo
|
||||||
|
commonExt: CommonExt
|
||||||
|
photoWall: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserDetailInfoByUin {
|
||||||
|
result: number
|
||||||
|
errMsg: string
|
||||||
|
info: {
|
||||||
|
uid: string //这个没办法用
|
||||||
|
qid: string
|
||||||
|
uin: string
|
||||||
|
nick: string
|
||||||
|
remark: string
|
||||||
|
longNick: string
|
||||||
|
avatarUrl: string
|
||||||
|
birthday_year: number
|
||||||
|
birthday_month: number
|
||||||
|
birthday_day: number
|
||||||
|
sex: number //0
|
||||||
|
topTime: string
|
||||||
|
constellation: number
|
||||||
|
shengXiao: number
|
||||||
|
kBloodType: number
|
||||||
|
homeTown: string
|
||||||
|
makeFriendCareer: number
|
||||||
|
pos: string
|
||||||
|
eMail: string
|
||||||
|
phoneNum: string
|
||||||
|
college: string
|
||||||
|
country: string
|
||||||
|
province: string
|
||||||
|
city: string
|
||||||
|
postCode: string
|
||||||
|
address: string
|
||||||
|
isBlock: boolean
|
||||||
|
isSpecialCareOpen: boolean
|
||||||
|
isSpecialCareZone: boolean
|
||||||
|
ringId: string
|
||||||
|
regTime: number
|
||||||
|
interest: string
|
||||||
|
termType: number
|
||||||
|
labels: any[]
|
||||||
|
qqLevel: { crownNum: number, sunNum: number, moonNum: number, starNum: number }
|
||||||
|
isHideQQLevel: number
|
||||||
|
privilegeIcon: { jumpUrl: string, openIconList: any[], closeIconList: any[] }
|
||||||
|
isHidePrivilegeIcon: number
|
||||||
|
photoWall: { picList: any[] }
|
||||||
|
vipFlag: boolean
|
||||||
|
yearVipFlag: boolean
|
||||||
|
svipFlag: boolean
|
||||||
|
vipLevel: number
|
||||||
|
status: number
|
||||||
|
qidianMasterFlag: number
|
||||||
|
qidianCrewFlag: number
|
||||||
|
qidianCrewFlag2: number
|
||||||
|
extStatus: number
|
||||||
|
recommendImgFlag: number
|
||||||
|
disableEmojiShortCuts: number
|
||||||
|
pendantId: string
|
||||||
|
vipNameColorId: string
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,10 +1,18 @@
|
|||||||
import { NodeIKernelBuddyService } from './services/NodeIKernelBuddyService'
|
import {
|
||||||
|
NodeIKernelBuddyService,
|
||||||
|
NodeIKernelGroupService,
|
||||||
|
NodeIKernelProfileService,
|
||||||
|
NodeIKernelProfileLikeService
|
||||||
|
} from './services'
|
||||||
import os from 'node:os'
|
import os from 'node:os'
|
||||||
const Process = require('node:process')
|
const Process = require('node:process')
|
||||||
|
|
||||||
export interface NodeIQQNTWrapperSession {
|
export interface NodeIQQNTWrapperSession {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
getBuddyService(): NodeIKernelBuddyService
|
getBuddyService(): NodeIKernelBuddyService
|
||||||
|
getGroupService(): NodeIKernelGroupService
|
||||||
|
getProfileService(): NodeIKernelProfileService
|
||||||
|
getProfileLikeService(): NodeIKernelProfileLikeService
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WrapperApi {
|
export interface WrapperApi {
|
||||||
@@ -65,4 +73,8 @@ Process.dlopen = function (module, filename, flags = os.constants.dlopen.RTLD_LA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dlopenRet
|
return dlopenRet
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSession() {
|
||||||
|
return wrapperApi.NodeIQQNTWrapperSession
|
||||||
}
|
}
|
@@ -18,7 +18,8 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
|
|||||||
const group = await getGroup(payload.group_id.toString())
|
const group = await getGroup(payload.group_id.toString())
|
||||||
if (group) {
|
if (group) {
|
||||||
if (!group.members?.length || payload.no_cache === true || payload.no_cache === 'true') {
|
if (!group.members?.length || payload.no_cache === true || payload.no_cache === 'true') {
|
||||||
group.members = await NTQQGroupApi.getGroupMembers(payload.group_id.toString())
|
const members = await NTQQGroupApi.getGroupMembers(payload.group_id.toString())
|
||||||
|
group.members = Array.from(members.values())
|
||||||
log('强制刷新群成员列表, 数量: ', group.members.length)
|
log('强制刷新群成员列表, 数量: ', group.members.length)
|
||||||
}
|
}
|
||||||
return OB11Constructor.groupMembers(group)
|
return OB11Constructor.groupMembers(group)
|
||||||
|
@@ -7,10 +7,9 @@ import {
|
|||||||
GroupMemberRole,
|
GroupMemberRole,
|
||||||
PicSubType,
|
PicSubType,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SendArkElement,
|
|
||||||
SendMessageElement,
|
SendMessageElement,
|
||||||
} from '../../../ntqqapi/types'
|
} from '../../../ntqqapi/types'
|
||||||
import { friends, getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } from '../../../common/data'
|
import { friends, getGroup, getGroupMember, getUidByUin, selfInfo } from '../../../common/data'
|
||||||
import {
|
import {
|
||||||
OB11MessageCustomMusic,
|
OB11MessageCustomMusic,
|
||||||
OB11MessageData,
|
OB11MessageData,
|
||||||
@@ -20,63 +19,21 @@ import {
|
|||||||
OB11MessageMixType,
|
OB11MessageMixType,
|
||||||
OB11MessageMusic,
|
OB11MessageMusic,
|
||||||
OB11MessageNode,
|
OB11MessageNode,
|
||||||
OB11MessageVideo,
|
|
||||||
OB11PostSendMsg,
|
OB11PostSendMsg,
|
||||||
} from '../../types'
|
} from '../../types'
|
||||||
import { NTQQMsgApi } from '../../../ntqqapi/api/msg'
|
|
||||||
import { SendMsgElementConstructor } from '../../../ntqqapi/constructor'
|
import { SendMsgElementConstructor } from '../../../ntqqapi/constructor'
|
||||||
import BaseAction from '../BaseAction'
|
import BaseAction from '../BaseAction'
|
||||||
import { ActionName, BaseCheckResult } from '../types'
|
import { ActionName, BaseCheckResult } from '../types'
|
||||||
import * as fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import { decodeCQCode } from '../../cqcode'
|
import { decodeCQCode } from '../../cqcode'
|
||||||
import { dbUtil } from '../../../common/db'
|
import { dbUtil } from '../../../common/db'
|
||||||
import { ALLOW_SEND_TEMP_MSG, getConfigUtil } from '../../../common/config'
|
import { ALLOW_SEND_TEMP_MSG, getConfigUtil } from '../../../common/config'
|
||||||
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 { uri2local } from '../../../common/utils'
|
import { uri2local } from '../../../common/utils'
|
||||||
import { NTQQGroupApi } from '../../../ntqqapi/api'
|
import { NTQQGroupApi, NTQQMsgApi, NTQQUserApi, NTQQFriendApi } from '@/ntqqapi/api'
|
||||||
import { CustomMusicSignPostData, IdMusicSignPostData, MusicSign, MusicSignPostData } from '../../../common/utils/sign'
|
import { CustomMusicSignPostData, IdMusicSignPostData, MusicSign, MusicSignPostData } from '@/common/utils/sign'
|
||||||
import { Peer } from '../../../ntqqapi/types/msg'
|
import { Peer } from '@/ntqqapi/types/msg'
|
||||||
|
|
||||||
function checkSendMessage(sendMsgList: OB11MessageData[]) {
|
|
||||||
function checkUri(uri: string): boolean {
|
|
||||||
const pattern = /^(file:\/\/|http:\/\/|https:\/\/|base64:\/\/)/
|
|
||||||
return pattern.test(uri)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let msg of sendMsgList) {
|
|
||||||
if (msg['type'] && msg['data']) {
|
|
||||||
let type = msg['type']
|
|
||||||
let data = msg['data']
|
|
||||||
if (type === 'text' && !data['text']) {
|
|
||||||
return 400
|
|
||||||
}
|
|
||||||
else if (['image', 'voice', 'record'].includes(type)) {
|
|
||||||
if (!data['file']) {
|
|
||||||
return 400
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (checkUri(data['file'])) {
|
|
||||||
return 200
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 400
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type === 'at' && !data['qq']) {
|
|
||||||
return 400
|
|
||||||
}
|
|
||||||
else if (type === 'reply' && !data['id']) {
|
|
||||||
return 400
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 400
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 200
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ReturnDataType {
|
export interface ReturnDataType {
|
||||||
message_id: number
|
message_id: number
|
||||||
@@ -351,13 +308,11 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (payload.user_id && payload.message_type !== 'group') {
|
if (payload.user_id && payload.message_type !== 'group') {
|
||||||
if (!(await getFriend(payload.user_id))) {
|
const uid = await NTQQUserApi.getUidByUin(payload.user_id.toString())
|
||||||
if (!ALLOW_SEND_TEMP_MSG && !(await dbUtil.getReceivedTempUinMap())[payload.user_id.toString()]) {
|
const isBuddy = await NTQQFriendApi.isBuddy(uid!)
|
||||||
return {
|
// 此处有问题
|
||||||
valid: false,
|
if (!isBuddy) {
|
||||||
message: `不能发送临时消息`,
|
//return { valid: false, message: '异常消息' }
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import BaseAction from '../BaseAction'
|
import BaseAction from '../BaseAction'
|
||||||
import { getFriend, getUidByUin, uidMaps } from '../../../common/data'
|
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
import { NTQQFriendApi } from '../../../ntqqapi/api/friend'
|
import { NTQQUserApi } from '@/ntqqapi/api'
|
||||||
import { log } from '../../../common/utils/log'
|
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
user_id: number
|
user_id: number
|
||||||
@@ -13,19 +11,12 @@ export default class SendLike extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.SendLike
|
actionName = ActionName.SendLike
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
log('点赞参数', payload)
|
|
||||||
try {
|
try {
|
||||||
const qq = payload.user_id.toString()
|
const qq = payload.user_id.toString()
|
||||||
const friend = await getFriend(qq)
|
const uid: string = await NTQQUserApi.getUidByUin(qq) || ''
|
||||||
let uid: string
|
const result = await NTQQUserApi.like(uid, parseInt(payload.times?.toString()) || 1)
|
||||||
if (!friend) {
|
|
||||||
uid = getUidByUin(qq)!
|
|
||||||
} else {
|
|
||||||
uid = friend.uid
|
|
||||||
}
|
|
||||||
let result = await NTQQFriendApi.likeFriend(uid, parseInt(payload.times?.toString()) || 1)
|
|
||||||
if (result.result !== 0) {
|
if (result.result !== 0) {
|
||||||
throw result.errMsg
|
throw Error(result.errMsg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw `点赞失败 ${e}`
|
throw `点赞失败 ${e}`
|
||||||
|
@@ -26,7 +26,7 @@ import {
|
|||||||
VideoElement,
|
VideoElement,
|
||||||
FriendV2
|
FriendV2
|
||||||
} from '../ntqqapi/types'
|
} from '../ntqqapi/types'
|
||||||
import { deleteGroup, getFriend, getGroupMember, selfInfo, tempGroupCodeMap, uidMaps } from '../common/data'
|
import { deleteGroup, getGroupMember, selfInfo, tempGroupCodeMap, uidMaps } from '../common/data'
|
||||||
import { EventType } from './event/OB11BaseEvent'
|
import { EventType } from './event/OB11BaseEvent'
|
||||||
import { encodeCQCode } from './cqcode'
|
import { encodeCQCode } from './cqcode'
|
||||||
import { dbUtil } from '../common/db'
|
import { dbUtil } from '../common/db'
|
||||||
@@ -34,9 +34,6 @@ import { OB11GroupIncreaseEvent } from './event/notice/OB11GroupIncreaseEvent'
|
|||||||
import { OB11GroupBanEvent } from './event/notice/OB11GroupBanEvent'
|
import { OB11GroupBanEvent } from './event/notice/OB11GroupBanEvent'
|
||||||
import { OB11GroupUploadNoticeEvent } from './event/notice/OB11GroupUploadNoticeEvent'
|
import { OB11GroupUploadNoticeEvent } from './event/notice/OB11GroupUploadNoticeEvent'
|
||||||
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent'
|
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent'
|
||||||
import { NTQQUserApi } from '../ntqqapi/api/user'
|
|
||||||
import { NTQQFileApi } from '../ntqqapi/api/file'
|
|
||||||
import { NTQQMsgApi } from '../ntqqapi/api/msg'
|
|
||||||
import { calcQQLevel } from '../common/utils/qqlevel'
|
import { calcQQLevel } from '../common/utils/qqlevel'
|
||||||
import { log } from '../common/utils/log'
|
import { log } from '../common/utils/log'
|
||||||
import { isNull, sleep } from '../common/utils/helper'
|
import { isNull, sleep } from '../common/utils/helper'
|
||||||
@@ -44,7 +41,7 @@ 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'
|
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'
|
||||||
import { NTQQGroupApi } from '../ntqqapi/api'
|
import { NTQQGroupApi, NTQQUserApi, NTQQFileApi, NTQQMsgApi } from '../ntqqapi/api'
|
||||||
import { OB11GroupMsgEmojiLikeEvent } from './event/notice/OB11MsgEmojiLikeEvent'
|
import { OB11GroupMsgEmojiLikeEvent } from './event/notice/OB11MsgEmojiLikeEvent'
|
||||||
import { mFaceCache } from '../ntqqapi/constructor'
|
import { mFaceCache } from '../ntqqapi/constructor'
|
||||||
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent'
|
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent'
|
||||||
@@ -54,8 +51,6 @@ import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11Poke
|
|||||||
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'
|
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'
|
||||||
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'
|
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'
|
||||||
|
|
||||||
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()
|
let config = getConfigUtil().getConfig()
|
||||||
@@ -99,10 +94,7 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
else if (msg.chatType == ChatType.friend) {
|
else if (msg.chatType == ChatType.friend) {
|
||||||
resMsg.sub_type = 'friend'
|
resMsg.sub_type = 'friend'
|
||||||
const friend = await getFriend(msg.senderUin!)
|
resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick
|
||||||
if (friend) {
|
|
||||||
resMsg.sender.nickname = friend.nick
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (msg.chatType == ChatType.temp) {
|
else if (msg.chatType == ChatType.temp) {
|
||||||
resMsg.sub_type = 'group'
|
resMsg.sub_type = 'group'
|
||||||
|
Reference in New Issue
Block a user