mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
parent
3394823719
commit
277e418cf3
@ -1,8 +1,7 @@
|
|||||||
import { Friend, FriendV2, SimpleInfo, CategoryFriend } from '../types'
|
import { Friend, FriendV2, SimpleInfo, CategoryFriend, BuddyListReqType } from '../types'
|
||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { invoke, NTMethod, NTClass } from '../ntcall'
|
import { invoke, NTMethod, NTClass } from '../ntcall'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { BuddyListReqType } from '../services'
|
|
||||||
import { Dict, pick } from 'cosmokit'
|
import { Dict, pick } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
|
|
||||||
|
@ -65,32 +65,30 @@ export class NTQQGroupApi extends Service {
|
|||||||
return result.result.infos
|
return result.result.infos
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMember(groupCode: string | number, memberUinOrUid: string | number) {
|
async getGroupMember(groupCode: string, memberUinOrUid: string) {
|
||||||
const groupCodeStr = groupCode.toString()
|
if (!this.groupMembers.has(groupCode)) {
|
||||||
const memberUinOrUidStr = memberUinOrUid.toString()
|
|
||||||
if (!this.groupMembers.has(groupCodeStr)) {
|
|
||||||
try {
|
try {
|
||||||
// 更新群成员列表
|
// 更新群成员列表
|
||||||
this.groupMembers.set(groupCodeStr, await this.getGroupMembers(groupCodeStr))
|
this.groupMembers.set(groupCode, await this.getGroupMembers(groupCode))
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return null
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let members = this.groupMembers.get(groupCodeStr)!
|
let members = this.groupMembers.get(groupCode)!
|
||||||
const getMember = () => {
|
const getMember = () => {
|
||||||
let member: GroupMember | undefined = undefined
|
let member: GroupMember | undefined = undefined
|
||||||
if (isNumeric(memberUinOrUidStr)) {
|
if (isNumeric(memberUinOrUid)) {
|
||||||
member = Array.from(members.values()).find(member => member.uin === memberUinOrUidStr)
|
member = Array.from(members.values()).find(member => member.uin === memberUinOrUid)
|
||||||
} else {
|
} else {
|
||||||
member = members.get(memberUinOrUidStr)
|
member = members.get(memberUinOrUid)
|
||||||
}
|
}
|
||||||
return member
|
return member
|
||||||
}
|
}
|
||||||
let member = getMember()
|
let member = getMember()
|
||||||
if (!member) {
|
if (!member) {
|
||||||
this.groupMembers.set(groupCodeStr, await this.getGroupMembers(groupCodeStr))
|
this.groupMembers.set(groupCode, await this.getGroupMembers(groupCode))
|
||||||
members = this.groupMembers.get(groupCodeStr)!
|
members = this.groupMembers.get(groupCode)!
|
||||||
member = getMember()
|
member = getMember()
|
||||||
}
|
}
|
||||||
return member
|
return member
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg, UserDetailSource, ProfileBizType } from '../types'
|
||||||
import { invoke } from '../ntcall'
|
import { invoke } from '../ntcall'
|
||||||
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
|
||||||
import { getBuildVersion } from '@/common/utils'
|
import { getBuildVersion } from '@/common/utils'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { RequestUtil } from '@/common/utils/request'
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
import { UserDetailSource, ProfileBizType } from '../services'
|
|
||||||
import { Time } from 'cosmokit'
|
import { Time } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { selfInfo } from '@/common/globalVars'
|
import { selfInfo } from '@/common/globalVars'
|
||||||
@ -157,30 +156,24 @@ export class NTQQUserApi extends Service {
|
|||||||
return uid
|
return uid
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUidByUinV2(uin: string) {
|
async getUidByUinV2(uin: string, groupCode?: string) {
|
||||||
const session = getSession()
|
let uid = (await invoke('nodeIKernelGroupService/getUidByUins', [{ uin: [uin] }])).uids.get(uin)
|
||||||
if (session) {
|
if (uid) return uid
|
||||||
let uid = (await session.getGroupService().getUidByUins([uin])).uids.get(uin)
|
uid = (await invoke('nodeIKernelProfileService/getUidByUin', [{ callFrom: 'FriendsServiceImpl', uin: [uin] }])).get(uin)
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
uid = (await session.getProfileService().getUidByUin('FriendsServiceImpl', [uin])).get(uin)
|
uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uins: [uin] }])).uidInfo.get(uin)
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
uid = (await session.getUixConvertService().getUid([uin])).uidInfo.get(uin)
|
const unveifyUid = (await this.getUserDetailInfoByUinV2(uin)).detail.uid
|
||||||
if (uid) return uid
|
if (!unveifyUid.includes('*')) return unveifyUid
|
||||||
} else {
|
if (groupCode) {
|
||||||
let uid = (await invoke('nodeIKernelGroupService/getUidByUins', [{ uin: [uin] }])).uids.get(uin)
|
const member = await this.ctx.ntGroupApi.getGroupMember(groupCode, uin)
|
||||||
if (uid) return uid
|
return member?.uid
|
||||||
uid = (await invoke('nodeIKernelProfileService/getUidByUin', [{ callFrom: 'FriendsServiceImpl', uin: [uin] }])).get(uin)
|
|
||||||
if (uid) return uid
|
|
||||||
uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uins: [uin] }])).uidInfo.get(uin)
|
|
||||||
if (uid) return uid
|
|
||||||
}
|
}
|
||||||
const unveifyUid = (await this.getUserDetailInfoByUinV2(uin)).detail.uid //从QQ Native 特殊转换
|
|
||||||
if (unveifyUid.indexOf('*') == -1) return unveifyUid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUidByUin(uin: string) {
|
async getUidByUin(uin: string, groupCode?: string) {
|
||||||
if (getBuildVersion() >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return this.getUidByUinV2(uin)
|
return this.getUidByUinV2(uin, groupCode)
|
||||||
}
|
}
|
||||||
return this.getUidByUinV1(uin)
|
return this.getUidByUinV1(uin)
|
||||||
}
|
}
|
||||||
@ -249,7 +242,7 @@ export class NTQQUserApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return await session.getTicketService().forceFetchClientKey('')
|
return await session.getTicketService().forceFetchClientKey('')
|
||||||
} else {
|
} else {
|
||||||
return await invoke('nodeIKernelTicketService/forceFetchClientKey', [{ domain: '' }, null])
|
return await invoke('nodeIKernelTicketService/forceFetchClientKey', [{ url: '' }, null])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
|
import { BuddyListReqType } from '@/ntqqapi/types'
|
||||||
import { GeneralCallResult } from './common'
|
import { GeneralCallResult } from './common'
|
||||||
|
|
||||||
export enum BuddyListReqType {
|
|
||||||
KNOMAL,
|
|
||||||
KLETTER
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeIKernelBuddyService {
|
export interface NodeIKernelBuddyService {
|
||||||
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
|
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
|
||||||
data: {
|
data: {
|
||||||
|
@ -1,36 +1,10 @@
|
|||||||
import { ElementType, MessageElement, Peer, RawMessage, SendMessageElement } from '@/ntqqapi/types'
|
import { ElementType, MessageElement, Peer, RawMessage, QueryMsgsParams, TmpChatInfoApi } from '@/ntqqapi/types'
|
||||||
import { GeneralCallResult } from './common'
|
import { GeneralCallResult } from './common'
|
||||||
|
|
||||||
export interface QueryMsgsParams {
|
|
||||||
chatInfo: Peer
|
|
||||||
filterMsgType: []
|
|
||||||
filterSendersUid: string[]
|
|
||||||
filterMsgFromTime: string
|
|
||||||
filterMsgToTime: string
|
|
||||||
pageLimit: number
|
|
||||||
isReverseOrder: boolean
|
|
||||||
isIncludeCurrent: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TmpChatInfoApi {
|
|
||||||
errMsg: string
|
|
||||||
result: number
|
|
||||||
tmpChatInfo?: TmpChatInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TmpChatInfo {
|
|
||||||
chatType: number
|
|
||||||
fromNick: string
|
|
||||||
groupCode: string
|
|
||||||
peerUid: string
|
|
||||||
sessionType: number
|
|
||||||
sig: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeIKernelMsgService {
|
export interface NodeIKernelMsgService {
|
||||||
generateMsgUniqueId(chatType: number, time: string): string
|
generateMsgUniqueId(chatType: number, time: string): string
|
||||||
|
|
||||||
sendMsg(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<unknown, unknown>): Promise<GeneralCallResult>
|
sendMsg(msgId: string, peer: Peer, msgElements: MessageElement[], map: Map<unknown, unknown>): Promise<GeneralCallResult>
|
||||||
|
|
||||||
recallMsg(peer: Peer, msgIds: string[]): Promise<GeneralCallResult>
|
recallMsg(peer: Peer, msgIds: string[]): Promise<GeneralCallResult>
|
||||||
|
|
||||||
|
@ -1,19 +1,6 @@
|
|||||||
import { SimpleInfo } from '../types'
|
import { SimpleInfo } from '../types'
|
||||||
import { GeneralCallResult } from './common'
|
import { GeneralCallResult } from './common'
|
||||||
|
|
||||||
export enum UserDetailSource {
|
|
||||||
KDB,
|
|
||||||
KSERVER
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ProfileBizType {
|
|
||||||
KALL,
|
|
||||||
KBASEEXTEND,
|
|
||||||
KVAS,
|
|
||||||
KQZONE,
|
|
||||||
KOTHER
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeIKernelProfileService {
|
export interface NodeIKernelProfileService {
|
||||||
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string, string>>
|
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string, string>>
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { GroupMemberRole } from './group'
|
import { GroupMemberRole } from './group'
|
||||||
|
import { GeneralCallResult } from '../services'
|
||||||
|
|
||||||
export interface GetFileListParam {
|
export interface GetFileListParam {
|
||||||
sortType: number
|
sortType: number
|
||||||
@ -565,3 +566,25 @@ export interface OnGroupFileInfoUpdateParams {
|
|||||||
nextIndex: number
|
nextIndex: number
|
||||||
reqId: number
|
reqId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface QueryMsgsParams {
|
||||||
|
chatInfo: Peer
|
||||||
|
filterMsgType: []
|
||||||
|
filterSendersUid: string[]
|
||||||
|
filterMsgFromTime: string
|
||||||
|
filterMsgToTime: string
|
||||||
|
pageLimit: number
|
||||||
|
isReverseOrder: boolean
|
||||||
|
isIncludeCurrent: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TmpChatInfoApi extends GeneralCallResult {
|
||||||
|
tmpChatInfo?: {
|
||||||
|
chatType: number
|
||||||
|
fromNick: string
|
||||||
|
groupCode: string
|
||||||
|
peerUid: string
|
||||||
|
sessionType: number
|
||||||
|
sig: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -344,3 +344,21 @@ export interface UserDetailInfoByUin {
|
|||||||
vipNameColorId: string
|
vipNameColorId: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum BuddyListReqType {
|
||||||
|
KNOMAL,
|
||||||
|
KLETTER
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum UserDetailSource {
|
||||||
|
KDB,
|
||||||
|
KSERVER
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ProfileBizType {
|
||||||
|
KALL,
|
||||||
|
KBASEEXTEND,
|
||||||
|
KVAS,
|
||||||
|
KQZONE,
|
||||||
|
KOTHER
|
||||||
|
}
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { GroupRequestOperateTypes } from '@/ntqqapi/types'
|
import { GroupRequestOperateTypes } from '@/ntqqapi/types'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
flag: string
|
flag: string
|
||||||
approve?: boolean | string
|
approve: boolean
|
||||||
reason?: string
|
reason?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupAddRequest
|
actionName = ActionName.SetGroupAddRequest
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
flag: Schema.string().required(),
|
||||||
|
approve: Schema.boolean().default(true),
|
||||||
|
reason: Schema.string()
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const flag = payload.flag.toString()
|
|
||||||
const approve = payload.approve?.toString() !== 'false'
|
|
||||||
await this.ctx.ntGroupApi.handleGroupRequest(
|
await this.ctx.ntGroupApi.handleGroupRequest(
|
||||||
flag,
|
payload.flag,
|
||||||
approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
payload.approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
||||||
payload.reason
|
payload.reason
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { GroupMemberRole } from '@/ntqqapi/types'
|
import { GroupMemberRole } from '@/ntqqapi/types'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
user_id: number
|
user_id: number | string
|
||||||
enable: boolean
|
enable: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupAdmin extends BaseAction<Payload, null> {
|
export default class SetGroupAdmin extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupAdmin
|
actionName = ActionName.SetGroupAdmin
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
user_id: Schema.union([Number, String]).required(),
|
||||||
|
enable: Schema.boolean().default(true)
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const member = await this.ctx.ntGroupApi.getGroupMember(payload.group_id, payload.user_id)
|
const groupCode = payload.group_id.toString()
|
||||||
const enable = payload.enable.toString() === 'true'
|
const uin = payload.user_id.toString()
|
||||||
if (!member) {
|
const uid = await this.ctx.ntUserApi.getUidByUin(uin, groupCode)
|
||||||
throw `群成员${payload.user_id}不存在`
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
}
|
|
||||||
await this.ctx.ntGroupApi.setMemberRole(
|
await this.ctx.ntGroupApi.setMemberRole(
|
||||||
payload.group_id.toString(),
|
groupCode,
|
||||||
member.uid,
|
uid,
|
||||||
enable ? GroupMemberRole.admin : GroupMemberRole.normal,
|
payload.enable ? GroupMemberRole.admin : GroupMemberRole.normal
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,27 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
user_id: number
|
user_id: number | string
|
||||||
duration: number
|
duration: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupBan extends BaseAction<Payload, null> {
|
export default class SetGroupBan extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupBan
|
actionName = ActionName.SetGroupBan
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
user_id: Schema.union([Number, String]).required(),
|
||||||
|
duration: Schema.number().default(30 * 60)
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const member = await this.ctx.ntGroupApi.getGroupMember(payload.group_id, payload.user_id)
|
const groupCode = payload.group_id.toString()
|
||||||
if (!member) {
|
const uin = payload.user_id.toString()
|
||||||
throw `群成员${payload.user_id}不存在`
|
const uid = await this.ctx.ntUserApi.getUidByUin(uin, groupCode)
|
||||||
}
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
await this.ctx.ntGroupApi.banMember(payload.group_id.toString(), [
|
await this.ctx.ntGroupApi.banMember(groupCode, [
|
||||||
{ uid: member.uid, timeStamp: parseInt(payload.duration.toString()) },
|
{ uid, timeStamp: payload.duration },
|
||||||
])
|
])
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
user_id: number
|
user_id: number | string
|
||||||
card: string
|
card: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupCard extends BaseAction<Payload, null> {
|
export default class SetGroupCard extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupCard
|
actionName = ActionName.SetGroupCard
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
user_id: Schema.union([Number, String]).required(),
|
||||||
|
card: Schema.string().default('')
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const member = await this.ctx.ntGroupApi.getGroupMember(payload.group_id, payload.user_id)
|
const groupCode = payload.group_id.toString()
|
||||||
if (!member) {
|
const uin = payload.user_id.toString()
|
||||||
throw `群成员${payload.user_id}不存在`
|
const uid = await this.ctx.ntUserApi.getUidByUin(uin, groupCode)
|
||||||
}
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
await this.ctx.ntGroupApi.setMemberCard(payload.group_id.toString(), member.uid, payload.card || '')
|
await this.ctx.ntGroupApi.setMemberCard(groupCode, uid, payload.card)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
user_id: number
|
user_id: number | string
|
||||||
reject_add_request: boolean
|
reject_add_request: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupKick extends BaseAction<Payload, null> {
|
export default class SetGroupKick extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupKick
|
actionName = ActionName.SetGroupKick
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
user_id: Schema.union([Number, String]).required(),
|
||||||
|
reject_add_request: Schema.boolean().default(false)
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const member = await this.ctx.ntGroupApi.getGroupMember(payload.group_id, payload.user_id)
|
const groupCode = payload.group_id.toString()
|
||||||
if (!member) {
|
const uin = payload.user_id.toString()
|
||||||
throw `群成员${payload.user_id}不存在`
|
const uid = await this.ctx.ntUserApi.getUidByUin(uin, groupCode)
|
||||||
}
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
await this.ctx.ntGroupApi.kickMember(payload.group_id.toString(), [member.uid], !!payload.reject_add_request)
|
await this.ctx.ntGroupApi.kickMember(groupCode, [uid], payload.reject_add_request)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
is_dismiss: boolean
|
is_dismiss?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupLeave extends BaseAction<Payload, void> {
|
export default class SetGroupLeave extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupLeave
|
actionName = ActionName.SetGroupLeave
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required()
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
try {
|
await this.ctx.ntGroupApi.quitGroup(payload.group_id.toString())
|
||||||
await this.ctx.ntGroupApi.quitGroup(payload.group_id.toString())
|
return null
|
||||||
} catch (e) {
|
|
||||||
this.ctx.logger.error('退群失败', e)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
group_name: string
|
group_name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupName extends BaseAction<Payload, null> {
|
export default class SetGroupName extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupName
|
actionName = ActionName.SetGroupName
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
group_name: Schema.string().required()
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
await this.ctx.ntGroupApi.setGroupName(payload.group_id.toString(), payload.group_name)
|
await this.ctx.ntGroupApi.setGroupName(payload.group_id.toString(), payload.group_name)
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
import { BaseAction } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number
|
group_id: number | string
|
||||||
enable: boolean
|
enable: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupWholeBan extends BaseAction<Payload, null> {
|
export default class SetGroupWholeBan extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.SetGroupWholeBan
|
actionName = ActionName.SetGroupWholeBan
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
enable: Schema.boolean().default(true)
|
||||||
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const enable = payload.enable.toString() === 'true'
|
await this.ctx.ntGroupApi.banGroup(payload.group_id.toString(), payload.enable)
|
||||||
await this.ctx.ntGroupApi.banGroup(payload.group_id.toString(), enable)
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user