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

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
import { import {
type Friend, type Friend,
type Group, type Group,
type GroupMember, GroupNotify, type GroupMember,
type SelfInfo, type SelfInfo,
BuddyCategoryType type BuddyCategoryType
} from './entities'; } from './entities';
import { isNumeric } from '@/common/utils/helper'; import { isNumeric } from '@/common/utils/helper';
import { NTQQGroupApi } from '@/core/apis'; 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 }> { 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( const messages = normalize(
payload.message, payload.message,

View File

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

View File

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