mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-13 05:15:02 +00:00
automod: tweaks/fixes to spam detection
This commit is contained in:
parent
4931c95872
commit
80fb9d7b6b
7 changed files with 18 additions and 11 deletions
|
@ -9,19 +9,17 @@ export function getMatchingMessageRecentActions(
|
|||
pluginData: PluginData<AutomodPluginType>,
|
||||
message: SavedMessage,
|
||||
type: RecentActionType,
|
||||
identifier: string,
|
||||
count: number,
|
||||
within: number,
|
||||
perChannel: boolean,
|
||||
) {
|
||||
const since = moment.utc(message.posted_at).valueOf() - within;
|
||||
const to = moment.utc(message.posted_at).valueOf();
|
||||
const identifier = perChannel ? `${message.channel_id}-${message.user_id}` : message.user_id;
|
||||
const recentActions = getMatchingRecentActions(pluginData, type, identifier, since, to);
|
||||
const totalCount = recentActions.reduce((total, action) => total + action.count, 0);
|
||||
|
||||
if (totalCount >= count) {
|
||||
return {
|
||||
identifier,
|
||||
recentActions,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue