mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
27 lines
793 B
TypeScript
27 lines
793 B
TypeScript
import { BaseAction, Schema } from '../BaseAction'
|
|
import { ActionName } from '../types'
|
|
|
|
interface Payload {
|
|
domain: string
|
|
}
|
|
|
|
interface Response {
|
|
cookies: string
|
|
bkn: string
|
|
}
|
|
|
|
export class GetCookies extends BaseAction<Payload, Response> {
|
|
actionName = ActionName.GetCookies
|
|
payloadSchema = Schema.object({
|
|
domain: Schema.string().required()
|
|
})
|
|
|
|
protected async _handle(payload: Payload) {
|
|
const cookiesObject = await this.ctx.ntUserApi.getCookies(payload.domain)
|
|
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
|
|
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ')
|
|
const bkn = cookiesObject.skey ? this.ctx.ntWebApi.genBkn(cookiesObject.skey) : ''
|
|
return { cookies, bkn }
|
|
}
|
|
}
|