feat(api): implement chronocat.internal.uix.uin.get

This commit is contained in:
Il Harper 2024-08-23 13:43:00 +08:00
parent c3b9a4b82b
commit 92133ce831
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
3 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,29 @@
import type { ChronocatContext } from '@chronocat/shell'
import { getMemberInfo } from '../../definitions/groupService'
import { getUserDetailInfoWithBizInfo } from '../../definitions/profileService'
export const buildGetUin = (ctx: ChronocatContext) => async (uid: string) => {
await getUserDetailInfoWithBizInfo({
uid,
keys: [0],
})
return new Promise<string>((res, rej) => {
ctx.chronocat.uix.once(uid, res)
void ctx.chronocat.sleep(5000).then(rej)
})
}
export const buildGetUinWithGroup =
(ctx: ChronocatContext) => async (uid: string, group: string) => {
await getMemberInfo({
forceUpdate: true,
groupCode: group,
uids: [uid],
})
return new Promise<string>((res, rej) => {
ctx.chronocat.uix.once(uid, res)
void ctx.chronocat.sleep(5000).then(rej)
})
}

View File

@ -8,7 +8,7 @@ export const getMemberInfo = define<
[
{
forceUpdate: boolean
groupCode: number
groupCode: string
uids: string[]
},
]

View File

@ -18,6 +18,7 @@ import { buildGuildMemberMute } from './api/guild/member/mute'
import { buildGuildRemove } from './api/guild/remove'
import { buildAssetsGet } from './api/internal/assets/get'
import { qfaceGet, qfaceList } from './api/internal/qface'
import { buildGetUin, buildGetUinWithGroup } from './api/internal/uix'
import { buildLoginGet } from './api/login/get'
import { buildMessageCreate } from './api/message/create'
import { buildMessageDelete } from './api/message/delete'
@ -72,6 +73,9 @@ export const apply = async (ctx: ChronocatContext) => {
register('friend.approve', buildFriendApprove(ctx))
register('unsafe.friend.remove', buildFriendRemove(ctx))
register('chronocat.internal.uix.uin.get', buildGetUin(ctx))
register('chronocat.internal.uix.uin.get.group', buildGetUinWithGroup(ctx))
await ctx.chronocat.whenReady()
register('chronocat.internal.qface.get', qfaceGet)