feat: FriendAddNotice

This commit is contained in:
linyuchen
2024-04-30 23:06:50 +08:00
parent bcb6b51241
commit 59cd28a2fd
17 changed files with 124 additions and 34 deletions

View File

@@ -3,11 +3,25 @@ import { OB11Constructor } from '../../constructor'
import { friends } from '../../../common/data'
import BaseAction from '../BaseAction'
import { ActionName } from '../types'
import { NTQQFriendApi } from '../../../ntqqapi/api'
import { log } from '../../../common/utils'
class GetFriendList extends BaseAction<null, OB11User[]> {
interface Payload{
no_cache: boolean | string
}
class GetFriendList extends BaseAction<Payload, OB11User[]> {
actionName = ActionName.GetFriendList
protected async _handle(payload: null) {
protected async _handle(payload: Payload) {
if (friends.length === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
const _friends = await NTQQFriendApi.getFriends(true)
// log('强制刷新好友列表,结果: ', _friends)
if (_friends.length > 0) {
friends.length = 0
friends.push(..._friends)
}
}
return OB11Constructor.friends(friends)
}
}