mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix
This commit is contained in:
parent
3da49fbfba
commit
544682fe41
@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^5.0.0",
|
||||||
"@types/fluent-ffmpeg": "^2.1.26",
|
"@types/fluent-ffmpeg": "^2.1.26",
|
||||||
"@types/node": "^20.14.15",
|
"@types/node": "^20.14.15",
|
||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.5.12",
|
||||||
@ -40,7 +40,7 @@
|
|||||||
"electron-vite": "^2.3.0",
|
"electron-vite": "^2.3.0",
|
||||||
"protobufjs-cli": "^1.1.3",
|
"protobufjs-cli": "^1.1.3",
|
||||||
"typescript": "^5.6.2",
|
"typescript": "^5.6.2",
|
||||||
"vite": "^5.4.7",
|
"vite": "^5.4.8",
|
||||||
"vite-plugin-cp": "^4.0.8"
|
"vite-plugin-cp": "^4.0.8"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.5.0"
|
"packageManager": "yarn@4.5.0"
|
||||||
|
@ -4,7 +4,7 @@ import { ActionName } from '../types'
|
|||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number | string
|
group_id: number | string
|
||||||
user_id: number | string
|
user_id: number | string
|
||||||
duration: number
|
duration: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupBan extends BaseAction<Payload, null> {
|
export default class SetGroupBan extends BaseAction<Payload, null> {
|
||||||
@ -12,7 +12,7 @@ export default class SetGroupBan extends BaseAction<Payload, null> {
|
|||||||
payloadSchema = Schema.object({
|
payloadSchema = Schema.object({
|
||||||
group_id: Schema.union([Number, String]).required(),
|
group_id: Schema.union([Number, String]).required(),
|
||||||
user_id: Schema.union([Number, String]).required(),
|
user_id: Schema.union([Number, String]).required(),
|
||||||
duration: Schema.number().default(30 * 60)
|
duration: Schema.union([Number, String]).default(30 * 60)
|
||||||
})
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
@ -21,7 +21,7 @@ export default class SetGroupBan extends BaseAction<Payload, null> {
|
|||||||
const uid = await this.ctx.ntUserApi.getUidByUin(uin, groupCode)
|
const uid = await this.ctx.ntUserApi.getUidByUin(uin, groupCode)
|
||||||
if (!uid) throw new Error('无法获取用户信息')
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
await this.ctx.ntGroupApi.banMember(groupCode, [
|
await this.ctx.ntGroupApi.banMember(groupCode, [
|
||||||
{ uid, timeStamp: payload.duration },
|
{ uid, timeStamp: +payload.duration },
|
||||||
])
|
])
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
GroupNotifyType,
|
GroupNotifyType,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
BuddyReqType,
|
BuddyReqType,
|
||||||
Peer,
|
|
||||||
FriendRequest,
|
FriendRequest,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
GroupMemberRole,
|
GroupMemberRole,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import http from 'node:http'
|
import http from 'node:http'
|
||||||
import cors from 'cors'
|
import cors from 'cors'
|
||||||
import crypto from 'node:crypto'
|
import crypto from 'node:crypto'
|
||||||
import express, { Express, Request, Response } from 'express'
|
import express, { Express, Request, Response, NextFunction } from 'express'
|
||||||
import { BaseAction } from '../action/BaseAction'
|
import { BaseAction } from '../action/BaseAction'
|
||||||
import { Context } from 'cordis'
|
import { Context } from 'cordis'
|
||||||
import { llonebotError, selfInfo } from '@/common/globalVars'
|
import { llonebotError, selfInfo } from '@/common/globalVars'
|
||||||
@ -76,7 +76,7 @@ class OB11Http {
|
|||||||
Object.assign(this.config, config)
|
Object.assign(this.config, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
private authorize(req: Request, res: Response, next: () => void) {
|
private authorize(req: Request, res: Response, next: NextFunction) {
|
||||||
const serverToken = this.config.token
|
const serverToken = this.config.token
|
||||||
if (!serverToken) return next()
|
if (!serverToken) return next()
|
||||||
|
|
||||||
@ -95,12 +95,13 @@ class OB11Http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clientToken !== serverToken) {
|
if (clientToken !== serverToken) {
|
||||||
return res.status(403).json({ message: 'token verify failed!' })
|
res.status(403).json({ message: 'token verify failed!' })
|
||||||
}
|
} else {
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async handleRequest(req: Request, res: Response, next: () => void) {
|
private async handleRequest(req: Request, res: Response, next: NextFunction) {
|
||||||
if (req.path === '/') return next()
|
if (req.path === '/') return next()
|
||||||
let payload = req.body
|
let payload = req.body
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
"module": "CommonJS",
|
"module": "CommonJS",
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"isolatedModules": true,
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user