Merge pull request #45 from po-lan/main

对 get_group_member_list 增强
This commit is contained in:
手瓜一十雪 authored and GitHub committed 2024-05-28 22:49:21 +08:00
commit e1f049229c
3 files changed
+5 -4

No files matched your search

+1 -3
View File
@@ -484,7 +484,6 @@ 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(
@@ -492,7 +491,6 @@ class DBUtil extends DBUtilBase {
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 (?,?,?)`,
@@ -504,7 +502,7 @@ class DBUtil extends DBUtilBase {
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,6 +14,7 @@ export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
this.user_id = userId; this.user_id = userId;
this.sub_type = subType; this.sub_type = subType;
if((ob11Config.GroupLocalTimeRecord[0] == -1 || ob11Config.GroupLocalTimeRecord.includes(groupId)))
dbUtil.insertJoinTime(groupId, userId, Math.floor(Date.now() / 1000)) dbUtil.insertJoinTime(groupId, userId, Math.floor(Date.now() / 1000))
} }
+2 -1
View File
@@ -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') {