mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
commit
e1f049229c
@ -484,27 +484,25 @@ class DBUtil extends DBUtilBase {
|
|||||||
userId: number,
|
userId: number,
|
||||||
time: number
|
time: number
|
||||||
) {
|
) {
|
||||||
if (ob11Config.GroupLocalTimeRecord[0] == -1 || ob11Config.GroupLocalTimeRecord.includes(groupId))
|
this.LURCache.set(groupId, userId, time)
|
||||||
this.LURCache.set(groupId, userId, time)
|
|
||||||
}
|
}
|
||||||
async insertJoinTime(
|
async insertJoinTime(
|
||||||
groupId: number,
|
groupId: number,
|
||||||
userId: number,
|
userId: number,
|
||||||
time: number
|
time: number
|
||||||
) {
|
) {
|
||||||
if (ob11Config.GroupLocalTimeRecord[0] == -1 || ob11Config.GroupLocalTimeRecord.includes(groupId)){
|
await this.createGroupInfoTimeTableIfNotExist(groupId);
|
||||||
await this.createGroupInfoTimeTableIfNotExist(groupId);
|
this.db!.all(
|
||||||
this.db!.all(
|
`INSERT OR REPLACE INTO "${groupId}" (user_id, last_sent_time, join_time) VALUES (?,?,?)`,
|
||||||
`INSERT OR REPLACE INTO "${groupId}" (user_id, last_sent_time, join_time) VALUES (?,?,?)`,
|
[userId, time, time],
|
||||||
[userId, time, time],
|
(err) => {
|
||||||
(err) => {
|
if (err)
|
||||||
if (err)
|
logError(err),
|
||||||
logError(err),
|
Promise.reject(),
|
||||||
Promise.reject(),
|
console.log("插入入群时间失败", userId, groupId);
|
||||||
console.log("插入入群时间失败", userId, groupId);
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||||
import { dbUtil } from '@/common/utils/db';
|
import { dbUtil } from '@/common/utils/db';
|
||||||
|
import { ob11Config } from '@/onebot11/config';
|
||||||
|
|
||||||
type GroupIncreaseSubType = 'approve' | 'invite';
|
type GroupIncreaseSubType = 'approve' | 'invite';
|
||||||
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
||||||
@ -13,7 +14,8 @@ export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
|||||||
this.user_id = userId;
|
this.user_id = userId;
|
||||||
this.sub_type = subType;
|
this.sub_type = subType;
|
||||||
|
|
||||||
dbUtil.insertJoinTime(groupId, userId, Math.floor(Date.now() / 1000))
|
if((ob11Config.GroupLocalTimeRecord[0] == -1 || ob11Config.GroupLocalTimeRecord.includes(groupId)))
|
||||||
|
dbUtil.insertJoinTime(groupId, userId, Math.floor(Date.now() / 1000))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,8 @@ export class NapCatOnebot11 {
|
|||||||
}
|
}
|
||||||
if (msg.post_type === 'message') {
|
if (msg.post_type === 'message') {
|
||||||
logMessage(msg as OB11Message).then().catch(logError);
|
logMessage(msg as OB11Message).then().catch(logError);
|
||||||
if (msg.message_type == 'group' && msg.group_id && (ob11Config.GroupLocalTimeRecord as Array<number>).find((item) => item == msg.group_id)) {
|
// 大概测试了一下,10000个以内 includes 和 find 性能差距不大
|
||||||
|
if (msg.message_type == 'group' && msg.group_id && (ob11Config.GroupLocalTimeRecord[0] === -1 || ob11Config.GroupLocalTimeRecord.find(gid=>gid == msg.group_id))) {
|
||||||
dbUtil.insertLastSentTime(msg.group_id, msg.user_id, msg.time);
|
dbUtil.insertLastSentTime(msg.group_id, msg.user_id, msg.time);
|
||||||
}
|
}
|
||||||
} else if (msg.post_type === 'notice') {
|
} else if (msg.post_type === 'notice') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user