mirror of
https://github.com/crystelf/crystelf-core.git
synced 2025-07-04 14:49:19 +00:00
修复类型错误
This commit is contained in:
parent
c5e787eb33
commit
72b9b8e4ec
@ -46,7 +46,7 @@ class BotController {
|
|||||||
* ```json
|
* ```json
|
||||||
* {
|
* {
|
||||||
* token: ‘114514’,
|
* token: ‘114514’,
|
||||||
* groupId: ‘114514’
|
* groupId: 114514
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
* @param req
|
* @param req
|
||||||
@ -56,7 +56,7 @@ class BotController {
|
|||||||
try {
|
try {
|
||||||
const token = req.body.token;
|
const token = req.body.token;
|
||||||
if (tools.checkToken(token.toString())) {
|
if (tools.checkToken(token.toString())) {
|
||||||
const groupId = req.body.groupId.toString();
|
const groupId: number = req.body.groupId;
|
||||||
let returnData = await BotService.getGroupInfo({ groupId: groupId });
|
let returnData = await BotService.getGroupInfo({ groupId: groupId });
|
||||||
if (returnData) {
|
if (returnData) {
|
||||||
await response.success(res, returnData);
|
await response.success(res, returnData);
|
||||||
|
@ -9,12 +9,12 @@ class BotService {
|
|||||||
/**
|
/**
|
||||||
* 获取botId数组
|
* 获取botId数组
|
||||||
*/
|
*/
|
||||||
public async getBotId(): Promise<{ uin: string; nickName: string }[]> {
|
public async getBotId(): Promise<{ uin: number; nickName: string }[]> {
|
||||||
logger.debug('GetBotId..');
|
logger.debug('GetBotId..');
|
||||||
const userPath = paths.get('userData');
|
const userPath = paths.get('userData');
|
||||||
const botsPath = path.join(userPath, '/crystelfBots');
|
const botsPath = path.join(userPath, '/crystelfBots');
|
||||||
const dirData = await fs.readdir(botsPath);
|
const dirData = await fs.readdir(botsPath);
|
||||||
const uins: { uin: string; nickName: string }[] = [];
|
const uins: { uin: number; nickName: string }[] = [];
|
||||||
|
|
||||||
for (const fileName of dirData) {
|
for (const fileName of dirData) {
|
||||||
if (!fileName.endsWith('.json')) continue;
|
if (!fileName.endsWith('.json')) continue;
|
||||||
@ -53,12 +53,12 @@ class BotService {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
public async getGroupInfo(data: {
|
public async getGroupInfo(data: {
|
||||||
botId?: string;
|
botId?: number;
|
||||||
groupId: string;
|
groupId: number;
|
||||||
clientId?: string;
|
clientId?: string;
|
||||||
}): Promise<any> {
|
}): Promise<any> {
|
||||||
logger.debug('GetGroupInfo..');
|
logger.debug('GetGroupInfo..');
|
||||||
const sendBot: string | undefined = data.botId
|
const sendBot: number | undefined = data.botId
|
||||||
? data.botId
|
? data.botId
|
||||||
: await this.getGroupBot(data.groupId);
|
: await this.getGroupBot(data.groupId);
|
||||||
if (!sendBot) {
|
if (!sendBot) {
|
||||||
@ -87,7 +87,7 @@ class BotService {
|
|||||||
* @param botId
|
* @param botId
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async getBotClient(botId: string): Promise<string | undefined> {
|
private async getBotClient(botId: number): Promise<string | undefined> {
|
||||||
const userPath = paths.get('userData');
|
const userPath = paths.get('userData');
|
||||||
const botsPath = path.join(userPath, '/crystelfBots');
|
const botsPath = path.join(userPath, '/crystelfBots');
|
||||||
const dirData = await fs.readdir(botsPath);
|
const dirData = await fs.readdir(botsPath);
|
||||||
@ -95,7 +95,7 @@ class BotService {
|
|||||||
if (!clientId.endsWith('.json')) continue;
|
if (!clientId.endsWith('.json')) continue;
|
||||||
try {
|
try {
|
||||||
const raw:
|
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);
|
| undefined = await redisService.fetch('crystelfBots', clientId);
|
||||||
if (!raw) continue;
|
if (!raw) continue;
|
||||||
if (raw.find((bot) => bot.uin == botId)) return clientId;
|
if (raw.find((bot) => bot.uin == botId)) return clientId;
|
||||||
@ -111,7 +111,7 @@ class BotService {
|
|||||||
* @param groupId
|
* @param groupId
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async getGroupBot(groupId: string): Promise<string | undefined> {
|
private async getGroupBot(groupId: number): Promise<number | undefined> {
|
||||||
const userPath = paths.get('userData');
|
const userPath = paths.get('userData');
|
||||||
const botsPath = path.join(userPath, '/crystelfBots');
|
const botsPath = path.join(userPath, '/crystelfBots');
|
||||||
const dirData = await fs.readdir(botsPath);
|
const dirData = await fs.readdir(botsPath);
|
||||||
@ -119,7 +119,7 @@ class BotService {
|
|||||||
if (!clientId.endsWith('.json')) continue;
|
if (!clientId.endsWith('.json')) continue;
|
||||||
try {
|
try {
|
||||||
const raw:
|
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);
|
| undefined = await redisService.fetch('crystelfBots', clientId);
|
||||||
if (!raw) continue;
|
if (!raw) continue;
|
||||||
raw.forEach((bot) => {
|
raw.forEach((bot) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user