mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
parent
c8d5eebe5d
commit
fafcf058b1
@ -107,8 +107,7 @@ export class NTQQFriendApi extends Service {
|
||||
return ret.arkMsg
|
||||
}
|
||||
|
||||
async setBuddyRemark(uid: string, remark?: string) {
|
||||
remark = remark ?? ''
|
||||
async setBuddyRemark(uid: string, remark = '') {
|
||||
return await invoke('nodeIKernelBuddyService/setBuddyRemark', [{
|
||||
remarkParams: { uid, remark }
|
||||
}])
|
||||
@ -125,6 +124,6 @@ export class NTQQFriendApi extends Service {
|
||||
}
|
||||
|
||||
async setBuddyCategory(uid: string, categoryId: number) {
|
||||
return await invoke('nodeIKernelBuddyService/setBuddyCategory', [{uid, categoryId}])
|
||||
return await invoke('nodeIKernelBuddyService/setBuddyCategory', [{ uid, categoryId }])
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ import {
|
||||
PublishGroupBulletinReq,
|
||||
GroupAllInfo,
|
||||
GroupFileInfo,
|
||||
GroupBulletinListResult
|
||||
GroupBulletinListResult,
|
||||
GroupMsgMask
|
||||
} from '../types'
|
||||
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||
import { GeneralCallResult } from '../services'
|
||||
@ -22,12 +23,6 @@ declare module 'cordis' {
|
||||
}
|
||||
}
|
||||
|
||||
export enum GroupMsgMask {
|
||||
ALLOW_NOTIFY = 1, // 允许提醒
|
||||
ALLOW_NOT_NOTIFY = 4, // 接受消息不提醒
|
||||
BOX_NOT_NOTIFY = 2, // 收进群助手不提醒
|
||||
NOT_ALLOW = 3, // 屏蔽
|
||||
}
|
||||
export class NTQQGroupApi extends Service {
|
||||
static inject = ['ntWindowApi']
|
||||
|
||||
@ -348,12 +343,11 @@ export class NTQQGroupApi extends Service {
|
||||
)
|
||||
}
|
||||
|
||||
async setGroupMsgMask(groupCode: string, msgMask: GroupMsgMask){
|
||||
async setGroupMsgMask(groupCode: string, msgMask: GroupMsgMask) {
|
||||
return await invoke('nodeIKernelGroupService/setGroupMsgMask', [{ groupCode, msgMask }])
|
||||
}
|
||||
|
||||
async setGroupRemark(groupCode: string, groupRemark?: string) {
|
||||
groupRemark = groupRemark ?? ''
|
||||
async setGroupRemark(groupCode: string, groupRemark = '') {
|
||||
return await invoke('nodeIKernelGroupService/modifyGroupRemark', [{ groupCode, groupRemark }])
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,11 @@ declare module 'cordis' {
|
||||
}
|
||||
|
||||
export class NTQQSystemApi extends Service {
|
||||
static inject = ['ntUserApi']
|
||||
|
||||
constructor(protected ctx: Context) {
|
||||
super(ctx, 'ntSystemApi', true)
|
||||
}
|
||||
|
||||
async restart(){
|
||||
async restart() {
|
||||
// todo: 调用此接口后会将 NTQQ 设置里面的自动登录和无需手机确认打开,重启后将状态恢复到之前的状态
|
||||
|
||||
// 设置自动登录
|
||||
@ -27,13 +25,14 @@ export class NTQQSystemApi extends Service {
|
||||
// 等待登录界面,模拟点击登录按钮?还是直接调用登录方法?
|
||||
}
|
||||
|
||||
// 是否自动登录
|
||||
async getSettingAutoLogin(): Promise<boolean>{
|
||||
async getSettingAutoLogin() {
|
||||
// 查询是否自动登录
|
||||
return invoke('nodeIKernelNodeMiscService/queryAutoRun', [])
|
||||
}
|
||||
async setSettingAutoLogin(state: boolean){
|
||||
await invoke('nodeIKernelSettingService/setNeedConfirmSwitch', [{state: 1}]) // 1:不需要手机确认,2:需要手机确认
|
||||
|
||||
await invoke('nodeIKernelSettingService/setAutoLoginSwitch', [{state}])
|
||||
async setSettingAutoLogin(state: boolean) {
|
||||
await invoke('nodeIKernelSettingService/setNeedConfirmSwitch', [{ state: 1 }]) // 1:不需要手机确认,2:需要手机确认
|
||||
|
||||
await invoke('nodeIKernelSettingService/setAutoLoginSwitch', [{ state }])
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export enum ReceiveCmdS {
|
||||
MEDIA_UPLOAD_COMPLETE = 'nodeIKernelMsgListener/onRichMediaUploadComplete',
|
||||
}
|
||||
|
||||
const logHook = true
|
||||
const logHook = false
|
||||
|
||||
const receiveHooks: Map<string, {
|
||||
method: ReceiveCmdS[]
|
||||
|
@ -13,7 +13,7 @@ export interface NodeIKernelBuddyService {
|
||||
}[]
|
||||
}>
|
||||
|
||||
setBuddyRemark(arg: unknown): void
|
||||
setBuddyRemark(arg: unknown): Promise<GeneralCallResult>
|
||||
|
||||
isBuddy(uid: string): boolean
|
||||
|
||||
|
@ -12,4 +12,6 @@ export interface NodeIKernelNodeMiscService {
|
||||
score: ''
|
||||
}[]
|
||||
}>
|
||||
|
||||
queryAutoRun(): Promise<boolean>
|
||||
}
|
||||
|
@ -1,10 +1,3 @@
|
||||
export enum GroupListUpdateType {
|
||||
REFRESHALL,
|
||||
GETALL,
|
||||
MODIFIED,
|
||||
REMOVE
|
||||
}
|
||||
|
||||
export interface Group {
|
||||
groupCode: string
|
||||
maxMember: number
|
||||
@ -188,3 +181,10 @@ export interface GroupBulletinListResult {
|
||||
nextIndex: number
|
||||
jointime: string
|
||||
}
|
||||
|
||||
export enum GroupMsgMask {
|
||||
AllowNotify = 1, // 允许提醒
|
||||
AllowNotNotify = 4, // 接受消息不提醒
|
||||
BoxNotNotify = 2, // 收进群助手不提醒
|
||||
NotAllow = 3, // 屏蔽
|
||||
}
|
||||
|
@ -1,15 +1,19 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { BaseAction, Schema } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
user_id: string,
|
||||
category_id: number
|
||||
user_id: number | string
|
||||
category_id: number | string
|
||||
}
|
||||
|
||||
export class SetFriendCategory extends BaseAction<Payload, null> {
|
||||
export class SetFriendCategory extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetFriendCategory
|
||||
payloadSchema = Schema.object({
|
||||
user_id: Schema.union([Number, String]).required(),
|
||||
category_id: Schema.union([Number, String]).required()
|
||||
})
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
protected async _handle(payload: Payload) {
|
||||
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||
if (!uid) throw new Error('无法获取好友信息')
|
||||
return this.ctx.ntFriendApi.setBuddyCategory(uid, +payload.category_id)
|
||||
|
@ -1,15 +1,19 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { BaseAction, Schema } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
user_id: string,
|
||||
user_id: number | string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export class SetFriendRemark extends BaseAction<Payload, null> {
|
||||
export class SetFriendRemark extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetFriendRemark
|
||||
payloadSchema = Schema.object({
|
||||
user_id: Schema.union([Number, String]).required(),
|
||||
remark: Schema.string()
|
||||
})
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
protected async _handle(payload: Payload) {
|
||||
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||
if (!uid) throw new Error('无法获取好友信息')
|
||||
return this.ctx.ntFriendApi.setBuddyRemark(uid, payload.remark || '')
|
||||
|
@ -1,16 +1,19 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { BaseAction, Schema } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
import { GroupMsgMask } from '@/ntqqapi/api'
|
||||
|
||||
interface Payload {
|
||||
group_id: string,
|
||||
mask: GroupMsgMask
|
||||
group_id: number | string
|
||||
mask: number | string // 1, 2, 3, 4
|
||||
}
|
||||
|
||||
export class SetGroupMsgMask extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetGroupMsgMask
|
||||
payloadSchema = Schema.object({
|
||||
group_id: Schema.union([Number, String]).required(),
|
||||
mask: Schema.union([Number, String]).required()
|
||||
})
|
||||
|
||||
protected async _handle(payload: Payload): Promise<unknown>{
|
||||
protected async _handle(payload: Payload) {
|
||||
return this.ctx.ntGroupApi.setGroupMsgMask(payload.group_id.toString(), +payload.mask)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user