mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
17 lines
575 B
TypeScript
17 lines
575 B
TypeScript
import { PluginData } from "knub";
|
|
import { CensorPluginType } from "../types";
|
|
import { SavedMessage } from "src/data/entities/SavedMessage";
|
|
import { applyFiltersToMsg } from "./applyFiltersToMsg";
|
|
|
|
export async function onMessageCreate(pluginData: PluginData<CensorPluginType>, savedMessage: SavedMessage) {
|
|
if (savedMessage.is_bot) return;
|
|
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);
|
|
|
|
const wasDeleted = await applyFiltersToMsg(pluginData, savedMessage);
|
|
|
|
if (wasDeleted) {
|
|
lock.interrupt();
|
|
} else {
|
|
lock.unlock();
|
|
}
|
|
}
|