diff --git a/src/modules/bot/bot.controller.ts b/src/modules/bot/bot.controller.ts index e9e9b3f..a974a29 100644 --- a/src/modules/bot/bot.controller.ts +++ b/src/modules/bot/bot.controller.ts @@ -46,7 +46,7 @@ class BotController { * ```json * { * token: ‘114514’, - * groupId: ‘114514’ + * groupId: 114514 * } * ``` * @param req @@ -56,7 +56,7 @@ class BotController { try { const token = req.body.token; if (tools.checkToken(token.toString())) { - const groupId = req.body.groupId.toString(); + const groupId: number = req.body.groupId; let returnData = await BotService.getGroupInfo({ groupId: groupId }); if (returnData) { await response.success(res, returnData); diff --git a/src/modules/bot/bot.service.ts b/src/modules/bot/bot.service.ts index 9089e09..ac63dba 100644 --- a/src/modules/bot/bot.service.ts +++ b/src/modules/bot/bot.service.ts @@ -9,12 +9,12 @@ class BotService { /** * 获取botId数组 */ - public async getBotId(): Promise<{ uin: string; nickName: string }[]> { + public async getBotId(): Promise<{ uin: number; nickName: string }[]> { logger.debug('GetBotId..'); const userPath = paths.get('userData'); const botsPath = path.join(userPath, '/crystelfBots'); const dirData = await fs.readdir(botsPath); - const uins: { uin: string; nickName: string }[] = []; + const uins: { uin: number; nickName: string }[] = []; for (const fileName of dirData) { if (!fileName.endsWith('.json')) continue; @@ -53,12 +53,12 @@ class BotService { * @param data */ public async getGroupInfo(data: { - botId?: string; - groupId: string; + botId?: number; + groupId: number; clientId?: string; }): Promise { logger.debug('GetGroupInfo..'); - const sendBot: string | undefined = data.botId + const sendBot: number | undefined = data.botId ? data.botId : await this.getGroupBot(data.groupId); if (!sendBot) { @@ -87,7 +87,7 @@ class BotService { * @param botId * @private */ - private async getBotClient(botId: string): Promise { + private async getBotClient(botId: number): Promise { const userPath = paths.get('userData'); const botsPath = path.join(userPath, '/crystelfBots'); const dirData = await fs.readdir(botsPath); @@ -95,7 +95,7 @@ class BotService { if (!clientId.endsWith('.json')) continue; try { const raw: - | { uin: string; groups: { group_id: string; group_name: string }[]; nickName: string }[] + | { uin: number; groups: { group_id: number; group_name: string }[]; nickName: string }[] | undefined = await redisService.fetch('crystelfBots', clientId); if (!raw) continue; if (raw.find((bot) => bot.uin == botId)) return clientId; @@ -111,7 +111,7 @@ class BotService { * @param groupId * @private */ - private async getGroupBot(groupId: string): Promise { + private async getGroupBot(groupId: number): Promise { const userPath = paths.get('userData'); const botsPath = path.join(userPath, '/crystelfBots'); const dirData = await fs.readdir(botsPath); @@ -119,7 +119,7 @@ class BotService { if (!clientId.endsWith('.json')) continue; try { const raw: - | { uin: string; groups: { group_id: string; group_name: string }[]; nickName: string }[] + | { uin: number; groups: { group_id: number; group_name: string }[]; nickName: string }[] | undefined = await redisService.fetch('crystelfBots', clientId); if (!raw) continue; raw.forEach((bot) => {