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:
parent
0e9f65e0d5
commit
0f0728bc1c
18 changed files with 133 additions and 38 deletions
|
@ -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";
|
||||
|
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 &&
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import * as t from "io-ts";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { PluginData } from "knub";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import { RecentAction } from "../types";
|
||||
|
||||
export function sumRecentActionCounts(actions: RecentAction[]) {
|
||||
return actions.reduce((total, action) => total + action.count, 0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue