style: code lint

This commit is contained in:
手瓜一十雪
2024-07-13 18:12:38 +08:00
parent 0afbbe7c7a
commit cc34aef47e
7 changed files with 37 additions and 37 deletions

View File

@@ -1,4 +1,4 @@
import { logError, logDebug } from "@/common/utils/log";
import { logError, logDebug } from '@/common/utils/log';
type group_id = number;
type user_id = number;
@@ -45,7 +45,7 @@ class LRU<T> {
// 移除LRU节点
private removeLRUNode(node: cacheNode<T>) {
logDebug(
"removeLRUNode",
'removeLRUNode',
node.groupId,
node.userId,
node.value,
@@ -74,19 +74,19 @@ class LRU<T> {
if (!removeObject[current.groupId]) removeObject[current.groupId] = [];
removeObject[current.groupId].push({ userId: current.userId, value: current.value });
// 删除LRU节点
delete this.cache[current.groupId][current.userId]
delete this.cache[current.groupId][current.userId];
current = current.prev;
totalNodeNum++;
this.currentSize--
this.currentSize--;
}
if (!totalNodeNum) return;
// 跟新链表指向
if (current) { current.next = null } else { this.head = null }
this.tail = current
if (current) { current.next = null; } else { this.head = null; }
this.tail = current;
this.onFuncs.forEach(func => func(removeObject))
this.onFuncs.forEach(func => func(removeObject));
}
private addNode(node: cacheNode<T>) {

View File

@@ -124,45 +124,45 @@ class DBUtil extends DBUtilBase {
Object.entries(nodeObject).forEach(async ([_groupId, datas]) => {
const userIds = datas.map(v => v.userId);
const groupId = Number(_groupId)
const groupId = Number(_groupId);
logDebug('插入发言时间', _groupId);
await this.createGroupInfoTimeTableIfNotExist(groupId);
const needCreatUsers = await this.getNeedCreatList(groupId, userIds);
const updateList = needCreatUsers.length > 0 ? datas.filter(user => !needCreatUsers.includes(user.userId)) : datas;
const insertList = needCreatUsers.map(userId => datas.find(e => userId == e.userId)!)
const insertList = needCreatUsers.map(userId => datas.find(e => userId == e.userId)!);
logDebug(`updateList`, updateList);
logDebug(`insertList`, insertList)
logDebug('updateList', updateList);
logDebug('insertList', insertList);
if (insertList.length) {
const insertSql = `INSERT INTO "${groupId}" (last_sent_time, user_id) VALUES ${insertList.map(() => '(?, ?)').join(', ')};`
const insertSql = `INSERT INTO "${groupId}" (last_sent_time, user_id) VALUES ${insertList.map(() => '(?, ?)').join(', ')};`;
this.db!.all(insertSql, insertList.map(v => [v.value, v.userId]).flat(), err => {
if (err) {
logError(`${groupId} 插入失败`)
logError(`更新Sql : ${insertSql}`)
logError(`${groupId} 插入失败`);
logError(`更新Sql : ${insertSql}`);
}
})
});
}
if (updateList.length) {
const updateSql =
`UPDATE "${groupId}" SET last_sent_time = CASE ` +
updateList.map(v => `WHEN user_id = ${v.userId} THEN ${v.value}`).join(" ") +
" ELSE last_sent_time END WHERE user_id IN " +
`(${updateList.map(v => v.userId).join(", ")});`
updateList.map(v => `WHEN user_id = ${v.userId} THEN ${v.value}`).join(' ') +
' ELSE last_sent_time END WHERE user_id IN ' +
`(${updateList.map(v => v.userId).join(', ')});`;
this.db!.all(updateSql, [], err => {
if (err) {
logError(`${groupId} 跟新失败`)
logError(`更新Sql : ${updateSql}`)
logError(`${groupId} 跟新失败`);
logError(`更新Sql : ${updateSql}`);
}
})
});
}
})
});
});
@@ -187,14 +187,14 @@ class DBUtil extends DBUtilBase {
const needCreatUsers = unhas.filter(userId => !has.includes(userId));
if (needCreatUsers.length == 0) {
logDebug('数据库全部命中')
logDebug('数据库全部命中');
} else {
logDebug('数据库未全部命中')
logDebug('数据库未全部命中');
}
resolve(needCreatUsers)
})
})
resolve(needCreatUsers);
});
});
}
@@ -439,7 +439,7 @@ class DBUtil extends DBUtilBase {
logError('查询发言时间失败', groupId);
return resolve(cache.map(e => ({ ...e, join_time: 0 })));
}
Object.assign(rows, cache)
Object.assign(rows, cache);
logDebug('查询发言时间成功', groupId, rows);
resolve(rows);
});
@@ -465,8 +465,8 @@ class DBUtil extends DBUtilBase {
(err) => {
if (err)
logError(err),
Promise.reject(),
logError('插入入群时间失败', userId, groupId);
Promise.reject(),
logError('插入入群时间失败', userId, groupId);
}
);

View File

@@ -7,7 +7,7 @@ export class RequestUtil {
static async HttpsGetCookies(url: string): Promise<{ [key: string]: string }> {
const client = url.startsWith('https') ? https : http;
return new Promise((resolve, reject) => {
let req = client.get(url, (res) => {
const req = client.get(url, (res) => {
let cookies: { [key: string]: string } = {};
const handleRedirect = (res: http.IncomingMessage) => {
//console.log(res.headers.location);
@@ -44,7 +44,7 @@ export class RequestUtil {
});
}
});
req.on('error', (error: any) => {
req.on('error', (error: any) => {
reject(error);
});
});

View File

@@ -1,9 +1,9 @@
import {
type Friend,
type Group,
type GroupMember, GroupNotify,
type GroupMember,
type SelfInfo,
BuddyCategoryType
type BuddyCategoryType
} from './entities';
import { isNumeric } from '@/common/utils/helper';
import { NTQQGroupApi } from '@/core/apis';

View File

@@ -145,7 +145,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
}
protected async _handle(payload: OB11PostSendMsg): Promise<{ message_id: number }> {
let { peer, group } = await createContext(payload, this.contextMode);
const { peer, group } = await createContext(payload, this.contextMode);
const messages = normalize(
payload.message,

View File

@@ -87,7 +87,7 @@ export class ReverseWebsocket {
'X-Self-ID': selfInfo.uin,
'Authorization': `Bearer ${token}`,
'x-client-role': 'Universal', // koishi-adapter-onebot 需要这个字段
"User-Agent": "OneBot/11",
'User-Agent': 'OneBot/11',
}
});
registerWsEventSender(this.websocket);

View File

@@ -60,7 +60,7 @@ export enum OB11MessageDataType {
dice = 'dice',
RPS = 'rps',
miniapp = 'miniapp',//json类
Location = "location"
Location = 'location'
}
export interface OB11MessageMFace {