mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Merge branch 'dev'
This commit is contained in:
commit
825c7c8e29
@ -4,7 +4,7 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "实现 OneBot 11 和 Satori 协议,用于 QQ 机器人开发",
|
||||
"version": "4.2.2",
|
||||
"version": "4.3.0",
|
||||
"icon": "./icon.webp",
|
||||
"authors": [
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ import {
|
||||
NTQQWindowApi
|
||||
} from '../ntqqapi/api'
|
||||
import { existsSync, mkdirSync } from 'node:fs'
|
||||
import { NTQQSystemApi } from '@/ntqqapi/api/system'
|
||||
|
||||
declare module 'cordis' {
|
||||
interface Events {
|
||||
@ -74,6 +75,7 @@ function onLoad() {
|
||||
ctx.plugin(NTQQWebApi)
|
||||
ctx.plugin(NTQQWindowApi)
|
||||
ctx.plugin(Database)
|
||||
ctx.plugin(NTQQSystemApi)
|
||||
|
||||
let started = false
|
||||
|
||||
|
@ -107,7 +107,8 @@ export class NTQQFriendApi extends Service {
|
||||
return ret.arkMsg
|
||||
}
|
||||
|
||||
async setBuddyRemark(uid: string, remark: string) {
|
||||
async setBuddyRemark(uid: string, remark?: string) {
|
||||
remark = remark ?? ''
|
||||
return await invoke('nodeIKernelBuddyService/setBuddyRemark', [{
|
||||
remarkParams: { uid, remark }
|
||||
}])
|
||||
@ -122,4 +123,8 @@ export class NTQQFriendApi extends Service {
|
||||
}
|
||||
}])
|
||||
}
|
||||
|
||||
async setBuddyCategory(uid: string, categoryId: number) {
|
||||
return await invoke('nodeIKernelBuddyService/setBuddyCategory', [{uid, categoryId}])
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,12 @@ 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']
|
||||
|
||||
@ -341,4 +347,13 @@ export class NTQQGroupApi extends Service {
|
||||
[{ groupId }]
|
||||
)
|
||||
}
|
||||
|
||||
async setGroupMsgMask(groupCode: string, msgMask: GroupMsgMask){
|
||||
return await invoke('nodeIKernelGroupService/setGroupMsgMask', [{ groupCode, msgMask }])
|
||||
}
|
||||
|
||||
async setGroupRemark(groupCode: string, groupRemark?: string) {
|
||||
groupRemark = groupRemark ?? ''
|
||||
return await invoke('nodeIKernelGroupService/modifyGroupRemark', [{ groupCode, groupRemark }])
|
||||
}
|
||||
}
|
||||
|
39
src/ntqqapi/api/system.ts
Normal file
39
src/ntqqapi/api/system.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Context, Service } from 'cordis'
|
||||
import { invoke, NTClass } from '@/ntqqapi/ntcall'
|
||||
|
||||
declare module 'cordis' {
|
||||
interface Context {
|
||||
ntSystemApi: NTQQSystemApi
|
||||
}
|
||||
}
|
||||
|
||||
export class NTQQSystemApi extends Service {
|
||||
static inject = ['ntUserApi']
|
||||
|
||||
constructor(protected ctx: Context) {
|
||||
super(ctx, 'ntSystemApi', true)
|
||||
}
|
||||
|
||||
async restart(){
|
||||
// todo: 调用此接口后会将 NTQQ 设置里面的自动登录和无需手机确认打开,重启后将状态恢复到之前的状态
|
||||
|
||||
// 设置自动登录
|
||||
await this.setSettingAutoLogin(true)
|
||||
// 退出账号
|
||||
invoke('quitAccount', [], {
|
||||
className: NTClass.BUSINESS_API
|
||||
}).then()
|
||||
invoke('notifyQQClose', [{ type: 1 }], { className: NTClass.QQ_EX_API }).then()
|
||||
// 等待登录界面,模拟点击登录按钮?还是直接调用登录方法?
|
||||
}
|
||||
|
||||
// 是否自动登录
|
||||
async getSettingAutoLogin(): Promise<boolean>{
|
||||
return invoke('nodeIKernelNodeMiscService/queryAutoRun', [])
|
||||
}
|
||||
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 = false
|
||||
const logHook = true
|
||||
|
||||
const receiveHooks: Map<string, {
|
||||
method: ReceiveCmdS[]
|
||||
|
@ -29,7 +29,8 @@ export enum NTClass {
|
||||
SKEY_API = 'ns-SkeyApi',
|
||||
GROUP_HOME_WORK = 'ns-GroupHomeWork',
|
||||
GROUP_ESSENCE = 'ns-GroupEssence',
|
||||
NODE_STORE_API = 'ns-NodeStoreApi'
|
||||
NODE_STORE_API = 'ns-NodeStoreApi',
|
||||
QQ_EX_API = 'ns-QQEXApi',
|
||||
}
|
||||
|
||||
export enum NTMethod {
|
||||
|
@ -80,6 +80,11 @@ import { GetGroupFileSystemInfo } from './go-cqhttp/GetGroupFileSystemInfo'
|
||||
import { GetCredentials } from './system/GetCredentials'
|
||||
import { SetGroupSpecialTitle } from '@/onebot11/action/go-cqhttp/SetGroupSpecialTitle'
|
||||
import { SendGroupSign } from '@/onebot11/action/go-cqhttp/SendGroupSign'
|
||||
import { SetRestart } from '@/onebot11/action/system/SetRestart'
|
||||
import { SetFriendCategory } from '@/onebot11/action/llonebot/SetFriendCategory'
|
||||
import { SetFriendRemark } from '@/onebot11/action/llonebot/SetFriendRemark'
|
||||
import { SetGroupMsgMask } from '@/onebot11/action/llonebot/SetGroupMsgMask'
|
||||
import { SetGroupRemark } from '@/onebot11/action/llonebot/SetGroupRemark'
|
||||
|
||||
export function initActionMap(adapter: Adapter) {
|
||||
const actionHandlers = [
|
||||
@ -100,6 +105,10 @@ export function initActionMap(adapter: Adapter) {
|
||||
new GetRobotUinRange(adapter),
|
||||
new GroupPoke(adapter),
|
||||
new FriendPoke(adapter),
|
||||
new SetFriendCategory(adapter),
|
||||
new SetFriendRemark(adapter),
|
||||
new SetGroupMsgMask(adapter),
|
||||
new SetGroupRemark(adapter),
|
||||
// onebot11
|
||||
new SendLike(adapter),
|
||||
new GetMsg(adapter),
|
||||
@ -133,6 +142,7 @@ export function initActionMap(adapter: Adapter) {
|
||||
new ForwardFriendSingleMsg(adapter),
|
||||
new ForwardGroupSingleMsg(adapter),
|
||||
new GetCredentials(adapter),
|
||||
new SetRestart(adapter),
|
||||
// go-cqhttp
|
||||
new GetEssenceMsgList(adapter),
|
||||
new GetGroupHonorInfo(adapter),
|
||||
|
17
src/onebot11/action/llonebot/SetFriendCategory.ts
Normal file
17
src/onebot11/action/llonebot/SetFriendCategory.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
user_id: string,
|
||||
category_id: number
|
||||
}
|
||||
|
||||
export class SetFriendCategory extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.SetFriendCategory
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
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)
|
||||
}
|
||||
}
|
17
src/onebot11/action/llonebot/SetFriendRemark.ts
Normal file
17
src/onebot11/action/llonebot/SetFriendRemark.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
user_id: string,
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export class SetFriendRemark extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.SetFriendRemark
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||
if (!uid) throw new Error('无法获取好友信息')
|
||||
return this.ctx.ntFriendApi.setBuddyRemark(uid, payload.remark || '')
|
||||
}
|
||||
}
|
16
src/onebot11/action/llonebot/SetGroupMsgMask.ts
Normal file
16
src/onebot11/action/llonebot/SetGroupMsgMask.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
import { GroupMsgMask } from '@/ntqqapi/api'
|
||||
|
||||
interface Payload {
|
||||
group_id: string,
|
||||
mask: GroupMsgMask
|
||||
}
|
||||
|
||||
export class SetGroupMsgMask extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetGroupMsgMask
|
||||
|
||||
protected async _handle(payload: Payload): Promise<unknown>{
|
||||
return this.ctx.ntGroupApi.setGroupMsgMask(payload.group_id.toString(), +payload.mask)
|
||||
}
|
||||
}
|
15
src/onebot11/action/llonebot/SetGroupRemark.ts
Normal file
15
src/onebot11/action/llonebot/SetGroupRemark.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { BaseAction } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
group_id: string,
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export class SetGroupRemark extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetGroupRemark
|
||||
|
||||
protected async _handle(payload: Payload): Promise<unknown>{
|
||||
return this.ctx.ntGroupApi.setGroupRemark(payload.group_id.toString(), payload.remark)
|
||||
}
|
||||
}
|
10
src/onebot11/action/system/SetRestart.ts
Normal file
10
src/onebot11/action/system/SetRestart.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { BaseAction } from '@/onebot11/action/BaseAction'
|
||||
import { ActionName } from '@/onebot11/action/types'
|
||||
|
||||
export class SetRestart extends BaseAction<null, void> {
|
||||
actionName = ActionName.SetRestart
|
||||
|
||||
protected async _handle() {
|
||||
await this.ctx.ntSystemApi.restart()
|
||||
}
|
||||
}
|
@ -29,6 +29,10 @@ export enum ActionName {
|
||||
GetRobotUinRange = 'get_robot_uin_range',
|
||||
GroupPoke = 'group_poke',
|
||||
FriendPoke = 'friend_poke',
|
||||
SetFriendRemark = 'set_friend_remark',
|
||||
SetFriendCategory = 'set_friend_category',
|
||||
SetGroupMsgMask = 'set_group_msg_mask',
|
||||
SetGroupRemark = 'set_group_remark',
|
||||
// onebot 11
|
||||
SendLike = 'send_like',
|
||||
GetLoginInfo = 'get_login_info',
|
||||
@ -47,6 +51,7 @@ export enum ActionName {
|
||||
SetGroupLeave = 'set_group_leave',
|
||||
GetVersionInfo = 'get_version_info',
|
||||
GetStatus = 'get_status',
|
||||
SetRestart = 'set_restart',
|
||||
CanSendRecord = 'can_send_record',
|
||||
CanSendImage = 'can_send_image',
|
||||
SetGroupKick = 'set_group_kick',
|
||||
|
@ -1 +1 @@
|
||||
export const version = '4.2.2'
|
||||
export const version = '4.3.0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user