mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-16 12:51:39 +00:00
feat(api): implement guild.get
This commit is contained in:
parent
8e38e33069
commit
6e499f499f
11
packages/engine-chronocat-api/src/api/guild/get.ts
Normal file
11
packages/engine-chronocat-api/src/api/guild/get.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import type { ChronocatContext, Guild, GuildGetPayload } from '@chronocat/shell'
|
||||
|
||||
export const buildGuildGet =
|
||||
(_ctx: ChronocatContext) =>
|
||||
async ({ guild_id }: GuildGetPayload): Promise<Guild> => {
|
||||
return {
|
||||
id: guild_id,
|
||||
name: undefined as unknown as string,
|
||||
avatar: `https://p.qlogo.cn/gh/${guild_id}/${guild_id}/640`,
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import { buildChannelGet } from './api/channel/get'
|
||||
import { buildChannelList } from './api/channel/list'
|
||||
import { buildChannelMemberMute } from './api/channel/member/mute'
|
||||
import { buildChannelMute } from './api/channel/mute'
|
||||
import { buildGuildGet } from './api/guild/get'
|
||||
import { buildAssetsGet } from './api/internal/assets/get'
|
||||
import { qfaceGet, qfaceList } from './api/internal/qface'
|
||||
import { buildLoginGet } from './api/login/get'
|
||||
@ -30,6 +31,7 @@ export const apply = async (ctx: ChronocatContext) => {
|
||||
register('unsafe.channel.mute', buildChannelMute(ctx))
|
||||
register('unsafe.channel.member.mute', buildChannelMemberMute(ctx))
|
||||
register('user.channel.create', buildUserChannelCreate(ctx))
|
||||
register('guild.get', buildGuildGet(ctx))
|
||||
register('message.create', buildMessageCreate(ctx))
|
||||
register('login.get', buildLoginGet(ctx))
|
||||
register('chronocat.internal.message.create.forward', buildMessageCreate(ctx))
|
||||
|
29
packages/shell/src/satori/routes/guild/get.ts
Normal file
29
packages/shell/src/satori/routes/guild/get.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import type { GuildGetPayload } from '../../types'
|
||||
import type { RouteContext } from '../types'
|
||||
|
||||
export const guildGet = async ({
|
||||
cctx,
|
||||
path,
|
||||
req,
|
||||
res,
|
||||
json,
|
||||
}: RouteContext) => {
|
||||
const payload = (await json()) as GuildGetPayload
|
||||
|
||||
const validateResult =
|
||||
await cctx.chronocat.validate('GuildGetPayload')(payload)
|
||||
|
||||
if (validateResult) {
|
||||
const err = `解析 ${path} 请求时出现问题,来自 ${req.socket.remoteAddress}。${validateResult}`
|
||||
|
||||
cctx.chronocat.l.error(err, {
|
||||
code: 400,
|
||||
})
|
||||
|
||||
res.writeHead(400)
|
||||
res.end(`400 bad request\n${err}`)
|
||||
return
|
||||
}
|
||||
|
||||
return await cctx.chronocat.api['guild.get'](payload)
|
||||
}
|
@ -6,7 +6,7 @@ import { channelMute } from './channel/mute'
|
||||
// import { friendList } from './friend/list'
|
||||
// import { friendRemove } from './friend/remove'
|
||||
// import { guildApprove } from './guild/approve'
|
||||
// import { guildGet } from './guild/get'
|
||||
import { guildGet } from './guild/get'
|
||||
// import { guildList } from './guild/list'
|
||||
// import { guildMemberGet } from './guild/member/get'
|
||||
// import { guildMemberKick } from './guild/member/kick'
|
||||
@ -31,7 +31,7 @@ const routesIntl = {
|
||||
'unsafe.channel.mute': channelMute,
|
||||
'unsafe.channel.member.mute': channelMemberMute,
|
||||
'user.channel.create': userChannelCreate,
|
||||
// 'guild.get': guildGet,
|
||||
'guild.get': guildGet,
|
||||
// 'guild.list': guildList,
|
||||
// 'guild.approve': guildApprove,
|
||||
// 'unsafe.guild.remove': guildRemove,
|
||||
|
@ -9,13 +9,17 @@ export type {
|
||||
ChannelMemberMutePayload,
|
||||
ChannelMutePayload,
|
||||
FriendListResponse,
|
||||
GuildGetPayload,
|
||||
GuildListResponse,
|
||||
GuildMemberGetPayload,
|
||||
GuildMemberKickPayload,
|
||||
GuildMemberListPayload,
|
||||
GuildMemberListResponse,
|
||||
GuildRemovePayload,
|
||||
MessageDeletePayload,
|
||||
MessageGetPayload,
|
||||
Next,
|
||||
UserGetPayload,
|
||||
UserPayload,
|
||||
} from './satoriPayloadEntity'
|
||||
|
||||
|
@ -10,6 +10,8 @@ import type {
|
||||
ChannelMemberMutePayload,
|
||||
ChannelMutePayload,
|
||||
Event,
|
||||
Guild,
|
||||
GuildGetPayload,
|
||||
Login,
|
||||
Message,
|
||||
MessageCreatePayload,
|
||||
@ -90,6 +92,8 @@ export interface Methods {
|
||||
]
|
||||
'user.channel.create': [[UserPayload], Channel]
|
||||
|
||||
'guild.get': [[GuildGetPayload], Guild]
|
||||
|
||||
'message.create': [
|
||||
[MessageCreatePayload, ChronocatSatoriServerConfig],
|
||||
Message[],
|
||||
|
Loading…
Reference in New Issue
Block a user