3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-12 21:05:02 +00:00

Automod work vol 3

This commit is contained in:
Dragory 2020-07-27 22:19:34 +03:00
parent 0e9f65e0d5
commit 0f0728bc1c
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
18 changed files with 133 additions and 38 deletions

View file

@ -1,4 +1,3 @@
import moment from "moment-timezone";
import { AutomodContext, AutomodPluginType } from "../types";
import { PluginData } from "knub";
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";

View file

@ -52,7 +52,7 @@ export function createMessageSpamTrigger(spamType: RecentActionType, prettyName:
pluginData.state.recentSpam.push({
type: spamType,
userId: context.message.user_id,
userIds: [context.message.user_id],
archiveId,
timestamp: Date.now(),
});

View file

@ -2,8 +2,8 @@ import { PluginData } from "knub";
import { AutomodPluginType } from "../types";
import { RecentActionType } from "../constants";
export function findRecentSpam(pluginData: PluginData<AutomodPluginType>, type: RecentActionType, userId: string) {
export function findRecentSpam(pluginData: PluginData<AutomodPluginType>, type: RecentActionType, userId?: string) {
return pluginData.state.recentSpam.find(spam => {
return spam.type === type && spam.userId === userId;
return spam.type === type && (!userId || spam.userIds.includes(userId));
});
}

View file

@ -7,8 +7,10 @@ export function getMatchingRecentActions(
type: RecentActionType,
identifier: string | null,
since: number,
to: number,
to?: number,
) {
to = to || Date.now();
return pluginData.state.recentActions.filter(action => {
return (
action.type === type &&

View file

@ -1,4 +1,3 @@
import * as t from "io-ts";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { resolveMember } from "../../../utils";
import { PluginData } from "knub";

View file

@ -1,5 +1,5 @@
import { PluginData } from "knub";
import { AutomodContext, AutomodPluginType, TRule } from "../types";
import { AutomodContext, AutomodPluginType } from "../types";
import { availableTriggers } from "../triggers/availableTriggers";
import { availableActions } from "../actions/availableActions";
import { AutomodTriggerMatchResult } from "../helpers";

View file

@ -0,0 +1,5 @@
import { RecentAction } from "../types";
export function sumRecentActionCounts(actions: RecentAction[]) {
return actions.reduce((total, action) => total + action.count, 0);
}