mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
26 lines
844 B
TypeScript
26 lines
844 B
TypeScript
import { BaseAction, Schema } from '../BaseAction'
|
|
import { OB11User } from '../../types'
|
|
import { OB11Entities } from '../../entities'
|
|
import { ActionName } from '../types'
|
|
import { getBuildVersion } from '@/common/utils'
|
|
import { parseBool } from '@/common/utils/misc'
|
|
|
|
interface Payload {
|
|
no_cache: boolean
|
|
}
|
|
|
|
export class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
|
actionName = ActionName.GetFriendList
|
|
payloadSchema = Schema.object({
|
|
no_cache: Schema.union([Boolean, Schema.transform(String, parseBool)]).default(false)
|
|
})
|
|
|
|
protected async _handle(payload: Payload) {
|
|
const refresh = payload.no_cache
|
|
if (getBuildVersion() >= 26702) {
|
|
return OB11Entities.friendsV2(await this.ctx.ntFriendApi.getBuddyV2(refresh))
|
|
}
|
|
return OB11Entities.friends(await this.ctx.ntFriendApi.getFriends())
|
|
}
|
|
}
|