mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
sync
This commit is contained in:
@@ -5,9 +5,8 @@ import {
|
|||||||
type Group,
|
type Group,
|
||||||
type GroupMember,
|
type GroupMember,
|
||||||
type SelfInfo,
|
type SelfInfo,
|
||||||
User,
|
|
||||||
} from '../ntqqapi/types'
|
} from '../ntqqapi/types'
|
||||||
import { type FileCache, type LLOneBotError } from './types'
|
import { type LLOneBotError } from './types'
|
||||||
import { NTQQGroupApi } from '../ntqqapi/api/group'
|
import { NTQQGroupApi } from '../ntqqapi/api/group'
|
||||||
import { log } from './utils/log'
|
import { log } from './utils/log'
|
||||||
import { isNumeric } from './utils/helper'
|
import { isNumeric } from './utils/helper'
|
||||||
@@ -26,7 +25,6 @@ export const WebGroupData = {
|
|||||||
}
|
}
|
||||||
export let groups: Group[] = []
|
export let groups: Group[] = []
|
||||||
export let friends: Friend[] = []
|
export let friends: Friend[] = []
|
||||||
export let friendRequests: Map<number, FriendRequest> = new Map<number, FriendRequest>()
|
|
||||||
export const llonebotError: LLOneBotError = {
|
export const llonebotError: LLOneBotError = {
|
||||||
ffmpegError: '',
|
ffmpegError: '',
|
||||||
httpServerError: '',
|
httpServerError: '',
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// 运行在 Electron 主进程 下的插件入口
|
// 运行在 Electron 主进程 下的插件入口
|
||||||
|
|
||||||
import { BrowserWindow, dialog, ipcMain } from 'electron'
|
import { BrowserWindow, dialog, ipcMain } from 'electron'
|
||||||
import * as fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import { Config } from '../common/types'
|
import { Config } from '../common/types'
|
||||||
import {
|
import {
|
||||||
CHANNEL_CHECK_VERSION,
|
CHANNEL_CHECK_VERSION,
|
||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
import { ob11WebsocketServer } from '../onebot11/server/ws/WebsocketServer'
|
import { ob11WebsocketServer } from '../onebot11/server/ws/WebsocketServer'
|
||||||
import { DATA_DIR } from '../common/utils'
|
import { DATA_DIR } from '../common/utils'
|
||||||
import {
|
import {
|
||||||
friendRequests,
|
|
||||||
getGroupMember,
|
getGroupMember,
|
||||||
llonebotError,
|
llonebotError,
|
||||||
selfInfo,
|
selfInfo,
|
||||||
@@ -28,24 +27,23 @@ import {
|
|||||||
GroupNotifies,
|
GroupNotifies,
|
||||||
GroupNotifyTypes,
|
GroupNotifyTypes,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
|
BuddyReqType,
|
||||||
} from '../ntqqapi/types'
|
} from '../ntqqapi/types'
|
||||||
import { httpHeart, ob11HTTPServer } from '../onebot11/server/http'
|
import { httpHeart, ob11HTTPServer } from '../onebot11/server/http'
|
||||||
import { postOb11Event } from '../onebot11/server/post-ob11-event'
|
import { postOb11Event } from '../onebot11/server/post-ob11-event'
|
||||||
import { ob11ReverseWebsockets } from '../onebot11/server/ws/ReverseWebsocket'
|
import { ob11ReverseWebsockets } from '../onebot11/server/ws/ReverseWebsocket'
|
||||||
import { OB11GroupRequestEvent } from '../onebot11/event/request/OB11GroupRequest'
|
import { OB11GroupRequestEvent } from '../onebot11/event/request/OB11GroupRequest'
|
||||||
import { OB11FriendRequestEvent } from '../onebot11/event/request/OB11FriendRequest'
|
import { OB11FriendRequestEvent } from '../onebot11/event/request/OB11FriendRequest'
|
||||||
import * as path from 'node:path'
|
import path from 'node:path'
|
||||||
import { dbUtil } from '../common/db'
|
import { dbUtil } from '../common/db'
|
||||||
import { setConfig } from './setConfig'
|
import { setConfig } from './setConfig'
|
||||||
import { NTQQUserApi } from '../ntqqapi/api/user'
|
import { NTQQUserApi, NTQQGroupApi, sentMessages } from '../ntqqapi/api'
|
||||||
import { NTQQGroupApi } from '../ntqqapi/api/group'
|
|
||||||
import { checkNewVersion, upgradeLLOneBot } from '../common/utils/upgrade'
|
import { checkNewVersion, upgradeLLOneBot } from '../common/utils/upgrade'
|
||||||
import { log } from '../common/utils/log'
|
import { log } from '../common/utils/log'
|
||||||
import { getConfigUtil } from '../common/config'
|
import { getConfigUtil } from '../common/config'
|
||||||
import { checkFfmpeg } from '../common/utils/video'
|
import { checkFfmpeg } from '../common/utils/video'
|
||||||
import { GroupDecreaseSubType, OB11GroupDecreaseEvent } from '../onebot11/event/notice/OB11GroupDecreaseEvent'
|
import { GroupDecreaseSubType, OB11GroupDecreaseEvent } from '../onebot11/event/notice/OB11GroupDecreaseEvent'
|
||||||
import '../ntqqapi/wrapper'
|
import '../ntqqapi/wrapper'
|
||||||
import { sentMessages } from '@/ntqqapi/api'
|
|
||||||
import { NTEventDispatch } from '../common/utils/EventTask'
|
import { NTEventDispatch } from '../common/utils/EventTask'
|
||||||
import { wrapperConstructor, getSession } from '../ntqqapi/wrapper'
|
import { wrapperConstructor, getSession } from '../ntqqapi/wrapper'
|
||||||
|
|
||||||
@@ -284,6 +282,7 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
log('收到群通知', notify)
|
log('收到群通知', notify)
|
||||||
await dbUtil.addGroupNotify(notify)
|
await dbUtil.addGroupNotify(notify)
|
||||||
|
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type
|
||||||
// let member2: GroupMember;
|
// let member2: GroupMember;
|
||||||
// if (notify.user2.uid) {
|
// if (notify.user2.uid) {
|
||||||
// member2 = await getGroupMember(notify.group.groupCode, null, notify.user2.uid);
|
// member2 = await getGroupMember(notify.group.groupCode, null, notify.user2.uid);
|
||||||
@@ -342,48 +341,47 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
else if ([GroupNotifyTypes.JOIN_REQUEST, GroupNotifyTypes.JOIN_REQUEST_BY_INVITED].includes(notify.type)) {
|
else if ([GroupNotifyTypes.JOIN_REQUEST, GroupNotifyTypes.JOIN_REQUEST_BY_INVITED].includes(notify.type)) {
|
||||||
log('有加群请求')
|
log('有加群请求')
|
||||||
let requestQQ = uidMaps[notify.user1.uid]
|
let requestQQ = ''
|
||||||
if (!requestQQ) {
|
try {
|
||||||
try {
|
// uid-->uin
|
||||||
|
requestQQ = (await NTQQUserApi.getUinByUid(notify.user1.uid))
|
||||||
|
if (isNaN(parseInt(requestQQ))) {
|
||||||
requestQQ = (await NTQQUserApi.getUserDetailInfo(notify.user1.uid)).uin
|
requestQQ = (await NTQQUserApi.getUserDetailInfo(notify.user1.uid)).uin
|
||||||
} catch (e) {
|
|
||||||
log('获取加群人QQ号失败', e)
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log('获取加群人QQ号失败 Uid:', notify.user1.uid, e)
|
||||||
}
|
}
|
||||||
let invitorId: number
|
let invitorId: string
|
||||||
if (notify.type == GroupNotifyTypes.JOIN_REQUEST_BY_INVITED) {
|
if (notify.type == GroupNotifyTypes.JOIN_REQUEST_BY_INVITED) {
|
||||||
// groupRequestEvent.sub_type = 'invite'
|
// groupRequestEvent.sub_type = 'invite'
|
||||||
let invitorQQ = uidMaps[notify.user2.uid]
|
try {
|
||||||
if (!invitorQQ) {
|
// uid-->uin
|
||||||
try {
|
invitorId = (await NTQQUserApi.getUinByUid(notify.user2.uid))
|
||||||
let invitor = (await NTQQUserApi.getUserDetailInfo(notify.user2.uid))
|
if (isNaN(parseInt(invitorId))) {
|
||||||
invitorId = parseInt(invitor.uin)
|
invitorId = (await NTQQUserApi.getUserDetailInfo(notify.user2.uid)).uin
|
||||||
} catch (e) {
|
|
||||||
invitorId = 0
|
|
||||||
log('获取邀请人QQ号失败', e)
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
invitorId = ''
|
||||||
|
log('获取邀请人QQ号失败 Uid:', notify.user2.uid, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const groupRequestEvent = new OB11GroupRequestEvent(
|
const groupRequestEvent = new OB11GroupRequestEvent(
|
||||||
parseInt(notify.group.groupCode),
|
parseInt(notify.group.groupCode),
|
||||||
parseInt(requestQQ) || 0,
|
parseInt(requestQQ) || 0,
|
||||||
notify.seq,
|
flag,
|
||||||
notify.postscript,
|
notify.postscript,
|
||||||
invitorId!,
|
invitorId! === undefined ? undefined : +invitorId,
|
||||||
'add'
|
'add'
|
||||||
)
|
)
|
||||||
postOb11Event(groupRequestEvent)
|
postOb11Event(groupRequestEvent)
|
||||||
}
|
}
|
||||||
else if (notify.type == GroupNotifyTypes.INVITE_ME) {
|
else if (notify.type == GroupNotifyTypes.INVITE_ME) {
|
||||||
log('收到邀请我加群通知')
|
log('收到邀请我加群通知')
|
||||||
let userId = uidMaps[notify.user2.uid]
|
const userId = (await NTQQUserApi.getUinByUid(notify.user2.uid)) || ''
|
||||||
if (!userId) {
|
|
||||||
userId = (await NTQQUserApi.getUserDetailInfo(notify.user2.uid))?.uin
|
|
||||||
}
|
|
||||||
const groupInviteEvent = new OB11GroupRequestEvent(
|
const groupInviteEvent = new OB11GroupRequestEvent(
|
||||||
parseInt(notify.group.groupCode),
|
parseInt(notify.group.groupCode),
|
||||||
parseInt(userId),
|
parseInt(userId),
|
||||||
notify.seq,
|
flag,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
'invite'
|
'invite'
|
||||||
@@ -402,20 +400,24 @@ function onLoad() {
|
|||||||
|
|
||||||
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
|
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
|
||||||
for (const req of payload.data.buddyReqs) {
|
for (const req of payload.data.buddyReqs) {
|
||||||
const flag = req.friendUid + req.reqTime
|
if (!!req.isInitiator || (req.isDecide && req.reqType !== BuddyReqType.KMEINITIATORWAITPEERCONFIRM)) {
|
||||||
if (req.isUnread && parseInt(req.reqTime) > startTime / 1000) {
|
continue
|
||||||
friendRequests[flag] = req
|
|
||||||
log('有新的好友请求', req)
|
|
||||||
let userId: number
|
|
||||||
try {
|
|
||||||
const requester = await NTQQUserApi.getUserDetailInfo(req.friendUid)
|
|
||||||
userId = parseInt(requester.uin)
|
|
||||||
} catch (e) {
|
|
||||||
log('获取加好友者QQ号失败', e)
|
|
||||||
}
|
|
||||||
const friendRequestEvent = new OB11FriendRequestEvent(userId!, req.extWords, flag)
|
|
||||||
postOb11Event(friendRequestEvent)
|
|
||||||
}
|
}
|
||||||
|
let userId = 0
|
||||||
|
try {
|
||||||
|
const requesterUin = await NTQQUserApi.getUinByUid(req.friendUid)
|
||||||
|
userId = parseInt(requesterUin!)
|
||||||
|
} catch (e) {
|
||||||
|
log('获取加好友者QQ号失败', e)
|
||||||
|
}
|
||||||
|
const flag = req.friendUid + '|' + req.reqTime
|
||||||
|
const comment = req.extWords
|
||||||
|
const friendRequestEvent = new OB11FriendRequestEvent(
|
||||||
|
userId,
|
||||||
|
comment,
|
||||||
|
flag
|
||||||
|
)
|
||||||
|
postOb11Event(friendRequestEvent)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { Friend, FriendRequest, FriendV2 } from '../types'
|
import { Friend, 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 { getSession } 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'
|
||||||
@@ -49,24 +48,18 @@ export class NTQQFriendApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async handleFriendRequest(flag: string, accept: boolean) {
|
static async handleFriendRequest(flag: string, accept: boolean) {
|
||||||
const request: FriendRequest = friendRequests[flag]
|
const data = flag.split('|')
|
||||||
if (!request) {
|
if (data.length < 2) {
|
||||||
throw `flat: ${flag}, 对应的好友请求不存在`
|
return
|
||||||
}
|
}
|
||||||
const result = await callNTQQApi<GeneralCallResult>({
|
const friendUid = data[0]
|
||||||
methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST,
|
const reqTime = data[1]
|
||||||
args: [
|
const session = getSession()
|
||||||
{
|
return session?.getBuddyService().approvalFriendRequest({
|
||||||
approvalInfo: {
|
friendUid,
|
||||||
friendUid: request.friendUid,
|
reqTime,
|
||||||
reqTime: request.reqTime,
|
accept
|
||||||
accept,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
delete friendRequests[flag]
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
static async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { Group, GroupMember, GroupMemberRole, GroupNotifies, GroupRequestOperateTypes } from '../types'
|
import { Group, GroupMember, GroupMemberRole, GroupNotifies, GroupRequestOperateTypes } from '../types'
|
||||||
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
||||||
import { deleteGroup } from '../../common/data'
|
|
||||||
import { dbUtil } from '../../common/db'
|
|
||||||
import { log } from '../../common/utils/log'
|
|
||||||
import { NTQQWindowApi, NTQQWindows } from './window'
|
import { NTQQWindowApi, NTQQWindows } from './window'
|
||||||
import { getSession } from '../wrapper'
|
import { getSession } from '../wrapper'
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask'
|
import { NTEventDispatch } from '@/common/utils/EventTask'
|
||||||
@@ -103,130 +100,64 @@ export class NTQQGroupApi {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
static async handleGroupRequest(seq: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
static async handleGroupRequest(flag: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
||||||
const notify = await dbUtil.getGroupNotify(seq)
|
const flagitem = flag.split('|')
|
||||||
if (!notify) {
|
const groupCode = flagitem[0]
|
||||||
throw `${seq}对应的加群通知不存在`
|
const seq = flagitem[1]
|
||||||
}
|
const type = parseInt(flagitem[2])
|
||||||
// delete groupNotifies[seq]
|
const session = getSession()
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return session?.getGroupService().operateSysNotify(
|
||||||
methodName: NTQQApiMethod.HANDLE_GROUP_REQUEST,
|
false,
|
||||||
args: [
|
{
|
||||||
{
|
'operateType': operateType, // 2 拒绝
|
||||||
doubt: false,
|
'targetMsg': {
|
||||||
operateMsg: {
|
'seq': seq, // 通知序列号
|
||||||
operateType: operateType, // 2 拒绝
|
'type': type,
|
||||||
targetMsg: {
|
'groupCode': groupCode,
|
||||||
seq: seq, // 通知序列号
|
'postscript': reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
||||||
type: notify.type,
|
}
|
||||||
groupCode: notify.group.groupCode,
|
})
|
||||||
postscript: reason,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async quitGroup(groupQQ: string) {
|
static async quitGroup(groupQQ: string) {
|
||||||
const result = await callNTQQApi<GeneralCallResult>({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.QUIT_GROUP,
|
return session?.getGroupService().quitGroup(groupQQ)
|
||||||
args: [{ groupCode: groupQQ }, null],
|
|
||||||
})
|
|
||||||
if (result.result === 0) {
|
|
||||||
deleteGroup(groupQQ)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async kickMember(
|
static async kickMember(
|
||||||
groupQQ: string,
|
groupQQ: string,
|
||||||
kickUids: string[],
|
kickUids: string[],
|
||||||
refuseForever: boolean = false,
|
refuseForever = false,
|
||||||
kickReason: string = '',
|
kickReason = '',
|
||||||
) {
|
) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.KICK_MEMBER,
|
return session?.getGroupService().kickMember(groupQQ, kickUids, refuseForever, kickReason)
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
kickUids,
|
|
||||||
refuseForever,
|
|
||||||
kickReason,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async banMember(groupQQ: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
static async banMember(groupQQ: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
||||||
// timeStamp为秒数, 0为解除禁言
|
// timeStamp为秒数, 0为解除禁言
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.MUTE_MEMBER,
|
return session?.getGroupService().setMemberShutUp(groupQQ, memList)
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
memList,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async banGroup(groupQQ: string, shutUp: boolean) {
|
static async banGroup(groupQQ: string, shutUp: boolean) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.MUTE_GROUP,
|
return session?.getGroupService().setGroupShutUp(groupQQ, shutUp)
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
shutUp,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
static async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
||||||
NTQQGroupApi.activateMemberListChange().then().catch(log)
|
const session = getSession()
|
||||||
const res = await callNTQQApi<GeneralCallResult>({
|
return session?.getGroupService().modifyMemberCardName(groupQQ, memberUid, cardName)
|
||||||
methodName: NTQQApiMethod.SET_MEMBER_CARD,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
uid: memberUid,
|
|
||||||
cardName,
|
|
||||||
},
|
|
||||||
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>({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.SET_MEMBER_ROLE,
|
return session?.getGroupService().modifyMemberRole(groupQQ, memberUid, role)
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
uid: memberUid,
|
|
||||||
role,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setGroupName(groupQQ: string, groupName: string) {
|
static async setGroupName(groupQQ: string, groupName: string) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
const session = getSession()
|
||||||
methodName: NTQQApiMethod.SET_GROUP_NAME,
|
return session?.getGroupService().modifyGroupName(groupQQ, groupName, false)
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
groupName,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getGroupAtAllRemainCount(groupCode: string) {
|
static async getGroupAtAllRemainCount(groupCode: string) {
|
||||||
@@ -251,19 +182,13 @@ export class NTQQGroupApi {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getGroupRemainAtTimes(GroupCode: string) {
|
||||||
|
const session = getSession()
|
||||||
|
return session?.getGroupService().getGroupRemainAtTimes(GroupCode)!
|
||||||
|
}
|
||||||
|
|
||||||
// 头衔不可用
|
// 头衔不可用
|
||||||
static async setGroupTitle(groupQQ: string, uid: string, title: string) {
|
static async setGroupTitle(groupQQ: string, uid: string, title: string) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
|
||||||
methodName: NTQQApiMethod.SET_GROUP_TITLE,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
uid,
|
|
||||||
title,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static publishGroupBulletin(groupQQ: string, title: string, content: string) { }
|
static publishGroupBulletin(groupQQ: string, title: string, content: string) { }
|
||||||
|
@@ -291,4 +291,49 @@ export class NTQQUserApi {
|
|||||||
Uin
|
Uin
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getUinByUidV1(Uid: string) {
|
||||||
|
const ret = await NTEventDispatch.CallNoListenerEvent
|
||||||
|
<(Uin: string[]) => Promise<{ uinInfo: Map<string, string> }>>(
|
||||||
|
'NodeIKernelUixConvertService/getUin',
|
||||||
|
5000,
|
||||||
|
[Uid]
|
||||||
|
)
|
||||||
|
let uin = ret.uinInfo.get(Uid)
|
||||||
|
if (!uin) {
|
||||||
|
//从Buddy缓存获取Uin
|
||||||
|
friends.forEach((t) => {
|
||||||
|
if (t.uid == Uid) {
|
||||||
|
uin = t.uin
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!uin) {
|
||||||
|
uin = (await NTQQUserApi.getUserDetailInfo(Uid)).uin //从QQ Native 转换
|
||||||
|
}
|
||||||
|
return uin
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUinByUidV2(Uid: string) {
|
||||||
|
const session = getSession()
|
||||||
|
let uin = (await session?.getProfileService().getUinByUid('FriendsServiceImpl', [Uid]))?.get(Uid)
|
||||||
|
if (uin) return uin
|
||||||
|
uin = (await session?.getGroupService().getUinByUids([Uid]))?.uins.get(Uid)
|
||||||
|
if (uin) return uin
|
||||||
|
uin = (await session?.getUixConvertService().getUin([Uid]))?.uinInfo.get(Uid)
|
||||||
|
if (uin) return uin
|
||||||
|
uin = (await NTQQFriendApi.getBuddyIdMapCache(true)).getKey(Uid) //从Buddy缓存获取Uin
|
||||||
|
if (uin) return uin
|
||||||
|
uin = (await NTQQFriendApi.getBuddyIdMap(true)).getKey(Uid)
|
||||||
|
if (uin) return uin
|
||||||
|
uin = (await NTQQUserApi.getUserDetailInfo(Uid)).uin //从QQ Native 转换
|
||||||
|
return uin
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUinByUid(Uid: string) {
|
||||||
|
if (getBuildVersion() >= 26702) {
|
||||||
|
return await NTQQUserApi.getUinByUidV2(Uid)
|
||||||
|
}
|
||||||
|
return await NTQQUserApi.getUinByUidV1(Uid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,8 +48,28 @@ export enum GroupRequestOperateTypes {
|
|||||||
reject = 2,
|
reject = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum BuddyReqType {
|
||||||
|
KMEINITIATOR,
|
||||||
|
KPEERINITIATOR,
|
||||||
|
KMEAGREED,
|
||||||
|
KMEAGREEDANDADDED,
|
||||||
|
KPEERAGREED,
|
||||||
|
KPEERAGREEDANDADDED,
|
||||||
|
KPEERREFUSED,
|
||||||
|
KMEREFUSED,
|
||||||
|
KMEIGNORED,
|
||||||
|
KMEAGREEANYONE,
|
||||||
|
KMESETQUESTION,
|
||||||
|
KMEAGREEANDADDFAILED,
|
||||||
|
KMSGINFO,
|
||||||
|
KMEINITIATORWAITPEERCONFIRM
|
||||||
|
}
|
||||||
|
|
||||||
export interface FriendRequest {
|
export interface FriendRequest {
|
||||||
|
isInitiator?: boolean
|
||||||
|
isDecide: boolean
|
||||||
friendUid: string
|
friendUid: string
|
||||||
|
reqType: BuddyReqType
|
||||||
reqTime: string // 时间戳,秒
|
reqTime: string // 时间戳,秒
|
||||||
extWords: string // 申请人填写的验证消息
|
extWords: string // 申请人填写的验证消息
|
||||||
isUnread: boolean
|
isUnread: boolean
|
||||||
|
@@ -5,22 +5,19 @@ import { NTQQGroupApi } from '../../../ntqqapi/api/group'
|
|||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
flag: string
|
flag: string
|
||||||
// sub_type: "add" | "invite",
|
approve?: boolean | string
|
||||||
// type: "add" | "invite"
|
reason?: string
|
||||||
approve: boolean
|
|
||||||
reason: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupAddRequest
|
actionName = ActionName.SetGroupAddRequest
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const seq = payload.flag.toString()
|
const flag = payload.flag.toString()
|
||||||
const approve = payload.approve.toString() === 'true'
|
const approve = payload.approve?.toString() !== 'false'
|
||||||
await NTQQGroupApi.handleGroupRequest(
|
await NTQQGroupApi.handleGroupRequest(flag,
|
||||||
seq,
|
|
||||||
approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
||||||
payload.reason,
|
payload.reason || ''
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ import { NTQQFriendApi } from '../../../ntqqapi/api/friend'
|
|||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
flag: string
|
flag: string
|
||||||
approve: boolean
|
approve?: boolean | string
|
||||||
remark?: string
|
remark?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ export default class SetFriendAddRequest extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.SetFriendAddRequest
|
actionName = ActionName.SetFriendAddRequest
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const approve = payload.approve.toString() === 'true'
|
const approve = payload.approve?.toString() !== 'false'
|
||||||
await NTQQFriendApi.handleFriendRequest(payload.flag, approve)
|
await NTQQFriendApi.handleFriendRequest(payload.flag, approve)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user