koishi-plugin-emojiluna
Version:
Smart emoji management plugin with AI categorization
93 lines (92 loc) • 2.68 kB
TypeScript
import { Context } from 'koishi';
import { Config } from './config';
import { ImageContentType } from './types';
import { ImageMetadata } from './imageProcessor';
export interface AutoCollectOptions {
minSize: number;
maxSize: number;
similarityThreshold: number;
whitelistGroups: string[];
emojiFrequencyThreshold: number;
groupAutoCollectLimit: Record<string, {
hourLimit: number;
dayLimit: number;
}>;
enableImageTypeFilter: boolean;
acceptedImageTypes: ImageContentType[];
}
export interface ImageInfo {
buffer: Buffer;
size: number;
hash: string;
metadata: ImageMetadata;
}
export interface FrameFeatures {
hash: string;
histogram: number[];
}
export interface ImageFeatures {
frames: FrameFeatures[];
aspectRatio: number;
dimensions: {
width: number;
height: number;
};
frameCount: number;
}
export interface FrequencyRecord {
hash: string;
timestamps: number[];
groupId: string;
}
export declare class AutoCollector {
private ctx;
private config;
private options;
private emojiHashes;
private imageFeatures;
private frequencyTracker;
private hashesReady;
private static readonly MAX_HASHES;
private static readonly FREQUENCY_WINDOW;
private static readonly SIMILARITY_FRAME_SAMPLES;
private static readonly HASH_WIDTH;
private static readonly HASH_HEIGHT;
private static readonly HISTOGRAM_WIDTH;
private static readonly HISTOGRAM_HEIGHT;
private static readonly HISTOGRAM_BINS;
private groupAutoCollectLimit;
constructor(ctx: Context, config: Config);
private loadExistingHashes;
private checkHitLimit;
private registerCommands;
start(): void;
private shouldProcessMessage;
private trackImageFrequency;
private cleanupFrequencyTracker;
private processImage;
private getImageInfo;
private checkFileSize;
private calculateImageHash;
private extractImageFeatures;
private calculateDifferenceHash;
private calculateHistogramFromPixels;
private hammingDistance;
private histogramSimilarity;
private calculateSimilarityScore;
private calculateFrameSetSimilarity;
private calculateFrameSimilarity;
private calculateDimensionSimilarity;
private isSimilarToExisting;
private saveEmoji;
private getDuplicateReason;
updateConfig(config: Config): void;
getStats(): {
totalHashes: number;
frequencyRecords: number;
isEnabled: boolean;
options: AutoCollectOptions;
imageTypeFilterEnabled: boolean;
acceptedImageTypes: ImageContentType[];
};
}