forked from kale5195/ModBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.type.ts
136 lines (125 loc) · 3.13 KB
/
rules.type.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { ModeratedChannel } from "@prisma/client";
import { PlanType } from "~/lib/utils";
import { z } from "zod";
import { Cast } from "@neynar/nodejs-sdk/build/neynar-api/v2";
export const ruleNames = [
"and",
"or",
"isHuman",
"alwaysInclude",
"manuallyApprove",
"airstackSocialCapitalRank",
"openRankGlobalEngagement",
"openRankChannel",
"subscribesOnParagraph",
"holdsFanToken",
"holdsChannelFanToken",
"userProfileContainsText",
"userDisplayNameContainsText",
"webhook",
"userIsChannelMember",
"userFollowerCount",
"userDoesNotFollow",
"userIsNotFollowedBy",
"userDoesNotHoldPowerBadge",
"userFidInList",
"userFidInRange",
"requireActiveHypersub",
"requiresErc1155",
"requiresErc721",
"requiresErc20",
"hasIcebreakerHuman",
"hasIcebreakerBot",
"hasIcebreakerQBuilder",
"hasIcebreakerVerified",
"hasIcebreakerCredential",
"hasIcebreakerLinkedAccount",
"hasPOAP",
"hasGuildRole",
"membershipFeeRequired",
"containsText",
"containsEmbeds",
"textMatchesPattern",
"textMatchesLanguage",
"castLength",
"containsTooManyMentions",
"containsLinks",
] as const;
export type RuleName = (typeof ruleNames)[number];
export type RuleDefinition = {
name: RuleName;
author: string;
authorUrl?: string;
authorIcon?: string;
minimumPlan?: PlanType;
icon?: string;
friendlyName: string;
// Gate rule access to fids
fidGated?: Array<number>;
// Gate rule access to channels
channelGated?: Array<string>;
checkType: "user" | "cast";
description: string;
// Where this rule can be used
category: "all" | "inclusion" | "exclusion" | "cast";
// Whether this rule can be used multiple times in a rule set
// example: containsText can be used many times, power badge can't
allowMultiple: boolean;
invertedDescription?: string;
hidden: boolean | (() => boolean);
invertable: boolean;
args: Record<
string,
{
type: string;
defaultValue?: string | number | boolean;
placeholder?: string;
friendlyName: string;
description: string;
pattern?: string;
tooltip?: string;
required?: boolean;
options?: Array<{ value: string; label: string; hint?: string }>;
}
>;
};
export type CheckFunctionResult = {
result: boolean;
message: string;
};
export type CheckFunction = (props: CheckFunctionArgs) => CheckFunctionResult | Promise<CheckFunctionResult>;
export const BaseRuleSchema = z.object({
name: z.enum(ruleNames),
type: z.union([z.literal("CONDITION"), z.literal("LOGICAL")]),
args: z.record(z.any()),
operation: z.union([z.literal("AND"), z.literal("OR")]).optional(),
});
export type Rule = z.infer<typeof BaseRuleSchema> & {
conditions?: Rule[];
};
export type User = {
fid: number;
verifications: string[];
custody_address: string;
username: string;
display_name?: string;
follower_count: number;
following_count: number;
pfp_url?: string;
profile: {
bio: {
text: string;
};
};
};
export type CheckFunctionArgs = {
channel: ModeratedChannel;
user: User;
rule: Rule;
cast?: Cast;
};
export type SelectOption = {
label: string;
value: number;
icon?: string;
};