mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-16 05:10:34 +00:00
commit
ba1542bd31
@ -4,6 +4,7 @@ import sqlite3 from 'sqlite3';
|
|||||||
import { log, logDebug, logError } from '@/common/utils/log';
|
import { log, logDebug, logError } from '@/common/utils/log';
|
||||||
import { NTQQMsgApi } from '@/core';
|
import { NTQQMsgApi } from '@/core';
|
||||||
import LRU from "@/common/utils/LRUCache";
|
import LRU from "@/common/utils/LRUCache";
|
||||||
|
import { ob11Config } from '@/onebot11/config';
|
||||||
|
|
||||||
export interface IRember {
|
export interface IRember {
|
||||||
last_sent_time: number;
|
last_sent_time: number;
|
||||||
@ -483,24 +484,27 @@ class DBUtil extends DBUtilBase {
|
|||||||
userId: number,
|
userId: number,
|
||||||
time: number
|
time: number
|
||||||
) {
|
) {
|
||||||
this.LURCache.set(groupId, userId, time)
|
if (ob11Config.GroupLocalTimeRecord[0] == -1 || ob11Config.GroupLocalTimeRecord.includes(groupId))
|
||||||
|
this.LURCache.set(groupId, userId, time)
|
||||||
}
|
}
|
||||||
async insertJoinTime(
|
async insertJoinTime(
|
||||||
groupId: number,
|
groupId: number,
|
||||||
userId: number,
|
userId: number,
|
||||||
time: number
|
time: number
|
||||||
) {
|
) {
|
||||||
await this.createGroupInfoTimeTableIfNotExist(groupId);
|
if (ob11Config.GroupLocalTimeRecord[0] == -1 || ob11Config.GroupLocalTimeRecord.includes(groupId)){
|
||||||
this.db!.all(
|
await this.createGroupInfoTimeTableIfNotExist(groupId);
|
||||||
`INSERT OR REPLACE INTO "${groupId}" (user_id, last_sent_time, join_time) VALUES (?,?,?)`,
|
this.db!.all(
|
||||||
[userId, time, time],
|
`INSERT OR REPLACE INTO "${groupId}" (user_id, last_sent_time, join_time) VALUES (?,?,?)`,
|
||||||
(err) => {
|
[userId, time, time],
|
||||||
if (err)
|
(err) => {
|
||||||
logError(err),
|
if (err)
|
||||||
Promise.reject(),
|
logError(err),
|
||||||
console.log("插入入群时间失败", userId, groupId);
|
Promise.reject(),
|
||||||
}
|
console.log("插入入群时间失败", userId, groupId);
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export interface OB11Config {
|
|||||||
reportSelfMessage: boolean;
|
reportSelfMessage: boolean;
|
||||||
token: string;
|
token: string;
|
||||||
|
|
||||||
GroupLocalTimeRecord: Array<string>;
|
GroupLocalTimeRecord: Array<number>;
|
||||||
|
|
||||||
read(): OB11Config;
|
read(): OB11Config;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class Config extends ConfigBase<OB11Config> implements OB11Config {
|
|||||||
reportSelfMessage = false;
|
reportSelfMessage = false;
|
||||||
token = '';
|
token = '';
|
||||||
|
|
||||||
GroupLocalTimeRecord = [];
|
GroupLocalTimeRecord = [] as Array<number>;
|
||||||
|
|
||||||
getConfigPath() {
|
getConfigPath() {
|
||||||
return path.join(this.getConfigDir(), `onebot11_${selfInfo.uin}.json`);
|
return path.join(this.getConfigDir(), `onebot11_${selfInfo.uin}.json`);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||||
|
import { dbUtil } from '@/common/utils/db';
|
||||||
|
|
||||||
type GroupIncreaseSubType = 'approve' | 'invite';
|
type GroupIncreaseSubType = 'approve' | 'invite';
|
||||||
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
||||||
@ -11,5 +12,8 @@ export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
|||||||
this.operator_id = operatorId;
|
this.operator_id = operatorId;
|
||||||
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))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user