-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathvalidations.server.ts
More file actions
2603 lines (2374 loc) · 72.1 KB
/
validations.server.ts
File metadata and controls
2603 lines (2374 loc) · 72.1 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { detect } from "tinyld";
import * as Sentry from "@sentry/remix";
import mimeType from "mime-types";
import RE2 from "re2";
import { z } from "zod";
import { getWarpcastChannel, getWarpcastChannelOwner } from "./warpcast.server";
import { ModeratedChannel } from "@prisma/client";
import { neynar } from "./neynar.server";
import emojiRegex from "emoji-regex";
import { clientsByChainId, hamChain } from "./viem.server";
import { erc20Abi, erc721Abi, getAddress, getContract, parseUnits } from "viem";
import {
formatHash,
getSetCache,
isWarpcastCastUrl,
validateErc1155,
validateErc20,
validateErc721,
} from "./utils.server";
import { WebhookCast } from "./types";
import { erc1155Abi, hypersubAbi721 } from "./abis";
import { languages } from "./languages";
import { chainIdToChainName, nftsByWallets } from "./simplehash.server";
import { db } from "./db.server";
import { Cast, CastId } from "@neynar/nodejs-sdk/build/neynar-api/v2";
import axios, { AxiosError } from "axios";
import { base, polygon } from "viem/chains";
import {
getVestingContractsForAddresses,
searchChannelFanToken,
farRank,
userFollowsChannel as airstackUserFollowsChannel,
} from "./airstack.server";
import { hideQuietly, mute, addToBypass, downvote, cooldown, grantRole, ban, unlike } from "./automod.server";
import { PlanType } from "~/lib/utils";
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";
// 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 }>;
}
>;
};
const hostUrl = ""; //getSharedEnv().hostUrl;
export const ruleDefinitions: Record<RuleName, RuleDefinition> = {
and: {
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
name: "and",
category: "all",
friendlyName: "And",
checkType: "cast",
description: "Combine multiple rules together",
hidden: true,
invertable: false,
args: {},
},
or: {
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
name: "or",
category: "all",
friendlyName: "Or",
checkType: "cast",
hidden: true,
invertable: false,
description: "Combine multiple rules together",
args: {},
},
alwaysInclude: {
name: "alwaysInclude",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "inclusion",
friendlyName: "Always Include",
checkType: "cast",
description: "Always includes the cast. Useful if you want to default all in except for a few rules.",
hidden: false,
invertable: false,
args: {},
},
webhook: {
name: "webhook",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Webhook",
checkType: "user",
description: "Use an external service to determine if the rule shoulud be triggered.",
hidden: false,
invertable: false,
minimumPlan: "prime",
args: {
url: {
type: "string",
friendlyName: "URL",
placeholder: "https://example.com/webhook",
required: true,
description:
"A post request will be made with { cast, user } data. If the webhook returns a 200, the rule will be triggered, if it returns a 400, it will not. Return a json response in either case with a message to include a reason in the activity logs. Maximum of 75 characters. A response must return within 5 seconds. Example: HTTP POST example.com/webhook { user, cast } -> 200 {'message': 'User belongs to mickey mouse club'}",
},
failureMode: {
type: "select",
required: true,
friendlyName: "If the webhook fails or times out...",
description:
"Example: Let's say you have only this rule in the section \"When any of the following rules are met, include the cast in Main\". If you choose 'Trigger this rule' and the webhook fails, the cast will be included in Main. If you choose 'Do not trigger this rule', the cast will not be included in Main.",
defaultValue: "doNotTrigger",
options: [
{ value: "trigger", label: "Trigger this rule" },
{ value: "doNotTrigger", label: "Do not trigger this rule" },
],
},
},
},
subscribesOnParagraph: {
name: "subscribesOnParagraph",
author: "Paragraph",
authorUrl: "https://paragraph.xyz",
authorIcon: `${hostUrl}/icons/paragraph2.png`,
allowMultiple: true,
category: "all",
friendlyName: "Subscribes on Paragraph",
checkType: "user",
description: "Check if the cast author has an active subscription on paragraph.xyz",
hidden: false,
invertable: false,
args: {
farcasterUser: {
type: "farcasterUserPicker",
friendlyName: "Farcaster Username",
required: true,
description: "The farcaster user who owns the paragraph publication.",
},
},
},
holdsFanToken: {
name: "holdsFanToken",
author: "Moxie",
authorUrl: "https://moxie.xyz",
authorIcon: `${hostUrl}/icons/moxie.png`,
allowMultiple: true,
category: "inclusion",
friendlyName: "Moxie Fan Token",
checkType: "user",
description: "Check if the cast author holds a Moxie fan token",
hidden: false,
invertable: false,
args: {
fanToken: {
type: "moxieMemberFanTokenPicker",
required: true,
friendlyName: "Fan Token",
placeholder: "Enter a username...",
description:
"If you don't see the token you're looking for, it may not be available yet. Check airstack.xyz",
},
minBalance: {
type: "string",
required: false,
placeholder: "Any Amount",
pattern: "^[0-9]+(\\.[0-9]+)?$",
friendlyName: "Minimum Balance",
description: "The minimum amount of fan tokens the user must hold.",
},
},
},
holdsChannelFanToken: {
name: "holdsChannelFanToken",
author: "Moxie",
authorUrl: "https://moxie.xyz",
authorIcon: `${hostUrl}/icons/moxie.png`,
allowMultiple: false,
category: "inclusion",
friendlyName: "Moxie Channel Fan Token",
checkType: "cast",
description: "Check if the cast author holds the fan token for your channel",
hidden: false,
invertable: false,
args: {
minBalance: {
type: "string",
required: false,
placeholder: "Any Amount",
friendlyName: "Minimum Balance",
pattern: "^[0-9]+(\\.[0-9]+)?$",
description: "The minimum amount of fan tokens the user must hold.",
},
},
},
containsText: {
name: "containsText",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Contains Text",
checkType: "cast",
description: "Check if the text contains a specific string",
hidden: false,
invertable: true,
args: {
searchText: {
type: "string",
friendlyName: "Search Text",
description: "The text to search for",
},
caseSensitive: {
type: "boolean",
friendlyName: "Case Sensitive",
description: "If checked, 'abc' is different from 'ABC'",
},
},
},
castInThread: {
name: "castInThread",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Cast is in Thread",
checkType: "cast",
description: "Check if a cast is a part of a thread",
hidden: true,
invertable: true,
args: {
identifiers: {
type: "textarea",
friendlyName: "Warpcast Links or Thread Hashes",
required: true,
placeholder: "0x05cf...c9mdi\nhttps://warpcast.com/jtgi/0x05cf551b",
description: "The first cast in the thread. One per line.",
},
},
},
isHuman: {
name: "isHuman",
author: "botornot",
authorUrl: "https://warpcast.com/botornot",
authorIcon: `${hostUrl}/icons/botornot.png`,
allowMultiple: false,
checkType: "user",
category: "all",
friendlyName: "Proof of Human, by Bot or Not",
description: "Check if the cast author is a human using Bot Or Not",
hidden: false,
fidGated: [5179],
invertable: false,
args: {},
},
containsEmbeds: {
name: "containsEmbeds",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Contains Embedded Content",
checkType: "cast",
description: "Check if the cast contains images, gifs, videos, frames or links",
hidden: false,
invertable: true,
args: {
images: {
type: "boolean",
defaultValue: true,
friendlyName: "Images",
description: "Check for images or gifs",
},
videos: {
type: "boolean",
defaultValue: true,
friendlyName: "Videos",
description: "Check for videos",
},
frames: {
type: "boolean",
defaultValue: true,
friendlyName: "Frames",
description: "Check for frames",
},
links: {
type: "boolean",
defaultValue: true,
friendlyName: "Links",
description: "Check for links",
},
casts: {
type: "boolean",
defaultValue: true,
friendlyName: "Casts",
description: "Check for quote casts",
},
domain: {
type: "string",
friendlyName: "Domain",
placeholder: "e.g. glass.com",
description:
"Check for embeds from a specific domain. Example: if you check 'Frames' and add glass.com, this check will trigger for frames from glass.com.",
},
},
},
textMatchesPattern: {
name: "textMatchesPattern",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Matches Pattern (Regex)",
checkType: "cast",
description: "Check if the text matches a specific pattern",
hidden: false,
invertable: true,
args: {
pattern: {
type: "string",
friendlyName: "Pattern",
required: true,
description: "The regular expression to match against. No leading or trailing slashes.",
},
caseInsensitive: {
type: "boolean",
friendlyName: "Ignore Case",
description: "If checked, 'abc' is the same as 'ABC'",
},
},
},
textMatchesLanguage: {
name: "textMatchesLanguage",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Matches Language",
checkType: "cast",
description: "Check if the text matches a specific language",
invertedDescription: "Check if the text is any language *but* the one specified.",
hidden: true,
invertable: true,
args: {
language: {
type: "select",
friendlyName: "Language",
description: "The language to check for",
options: languages.map((l) => ({
label: l.name,
value: l.code,
})),
},
},
},
castLength: {
name: "castLength",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Cast Length",
checkType: "cast",
description: "Check if the cast length is within a range",
hidden: false,
invertable: false,
args: {
min: {
type: "number",
friendlyName: "Less than",
description: "Setting a value of 5 would trigger this rule if the length was 0 to 4 characters.",
},
max: {
type: "number",
friendlyName: "More than",
description: "Setting a value of 10 would trigger this rule if the length was 11 or more characters.",
},
},
},
containsTooManyMentions: {
name: "containsTooManyMentions",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Contains Mentions",
checkType: "cast",
description: "Check if the text contains a certain amount of mentions",
invertable: true,
hidden: false,
args: {
maxMentions: {
type: "number",
required: true,
friendlyName: "Max Mentions",
placeholder: "0",
description: "The maximum number of mentions allowed",
},
},
},
containsLinks: {
name: "containsLinks",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Contains Links",
checkType: "cast",
description: "Check if the text contains any links",
hidden: false,
invertable: true,
args: {
maxLinks: {
type: "number",
friendlyName: "Max Links",
description: "The maximum number of links allowed",
},
},
},
downvote: {
name: "downvote",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Downvote",
checkType: "cast",
description: "Check if the cast has been downvoted by your community",
hidden: false,
invertable: false,
args: {
threshold: {
type: "number",
friendlyName: "Threshold",
description: "A threshold of 5 means when the 5th downvote is received, the rule will be violated.",
pattern: "[0-9]+",
},
},
},
userDoesNotFollow: {
name: "userDoesNotFollow",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Following",
checkType: "user",
description: "Check if the cast author follows certain accounts",
hidden: false,
invertable: false,
args: {
users: {
type: "farcasterUserPickerMulti",
required: true,
friendlyName: "Farcaster Usernames",
placeholder: "Enter a username...",
description:
"Example: If you enter jtgi and riotgoools, it will check that the cast author follows either jtgi or riotgools.",
},
},
},
userIsNotFollowedBy: {
name: "userIsNotFollowedBy",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Followed By",
checkType: "user",
description: "Check if the cast author is followed by certain accounts",
hidden: false,
invertable: true,
args: {
users: {
type: "farcasterUserPickerMulti",
required: true,
friendlyName: "Usernames",
placeholder: "Enter a username...",
description:
"Example: If you enter jtgi and riotgoools, it will check that either jtgi or riotgools follow the cast author.",
},
},
},
requireActiveHypersub: {
name: "requireActiveHypersub",
author: "Hypersub",
authorUrl: "https://hypersub.withfarbic.xyz",
authorIcon: `${hostUrl}/icons/fabric.svg`,
allowMultiple: true,
category: "all",
friendlyName: "Subscribes on Hypersub",
checkType: "user",
description: "Check if the user has an active subscription to a hypersub.",
hidden: false,
invertable: true,
args: {
chainId: {
type: "select",
friendlyName: "Chain",
description: "",
required: true,
options: [
{ value: "1", label: "Ethereum" },
{ value: "10", label: "Optimism" },
{ value: "8453", label: "Base" },
{ value: "7777777", label: "Zora" },
{ value: String(polygon.id), label: "Polygon" },
],
},
contractAddress: {
type: "string",
required: true,
pattern: "0x[a-fA-F0-9]{40}",
placeholder: "0xdead...",
friendlyName: "Contract Address",
description: "",
},
},
},
requiresErc20: {
name: "requiresErc20",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Holds ERC-20",
checkType: "user",
description: "Check that the user holds a certain amount of ERC-20 tokens in their connected wallets.",
invertedDescription: "Check for users who do hold the ERC-20",
hidden: false,
invertable: true,
args: {
chainId: {
type: "select",
friendlyName: "Chain",
description: "",
required: true,
options: [
{ value: "1", label: "Ethereum" },
{ value: "10", label: "Optimism" },
{ value: "8453", label: "Base" },
{ value: "7777777", label: "Zora" },
{ value: String(hamChain.id), label: "Ham" },
{ value: String(polygon.id), label: "Polygon" },
],
},
contractAddress: {
type: "string",
required: true,
friendlyName: "Contract Address",
pattern: "0x[a-fA-F0-9]{40}",
placeholder: "0xdead...",
description: "",
},
minBalance: {
type: "string",
required: false,
placeholder: "Any Amount",
friendlyName: "Minimum Balance (optional)",
pattern: "^[0-9]+(\\.[0-9]+)?$",
description: "",
},
},
},
airstackSocialCapitalRank: {
name: "airstackSocialCapitalRank",
author: "Airstack",
authorUrl: "https://airstack.xyz",
authorIcon: `${hostUrl}/icons/airstack.png`,
allowMultiple: false,
hidden: false,
category: "all",
friendlyName: " FarRank by Airstack",
checkType: "user",
description: "Check if a user's Airstack FarRank is high enough.",
invertable: false,
args: {
minRank: {
type: "number",
friendlyName: "Minimum Rank",
required: true,
placeholder: "e.g. 100",
description: "Example: if you enter 100, the rule will check that the user's FarRank is 1 to 100.",
},
},
},
requiresErc1155: {
name: "requiresErc1155",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Holds ERC-1155",
checkType: "user",
description: "Require users holds a certain ERC-1155 token",
invertedDescription: "Check for users who *do* hold the ERC-1155 token",
hidden: false,
invertable: true,
args: {
chainId: {
type: "select",
friendlyName: "Chain",
description: "",
required: true,
options: [
{ value: "1", label: "Ethereum" },
{ value: "10", label: "Optimism" },
{ value: "8453", label: "Base" },
{ value: "7777777", label: "Zora" },
{ value: String(polygon.id), label: "Polygon" },
],
},
contractAddress: {
type: "string",
required: true,
pattern: "0x[a-fA-F0-9]{40}",
placeholder: "0xdead...",
friendlyName: "Contract Address",
description: "",
},
tokenId: {
type: "string",
required: false,
placeholder: "Any Token",
pattern: "[0-9]+",
friendlyName: "Token ID (optional)",
description: "Optionally check for a specific token id, if left blank any token is valid.",
},
},
},
requiresErc721: {
name: "requiresErc721",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Holds ERC-721",
checkType: "user",
description: "Require users holds a certain ERC-721 token",
invertedDescription: "Check for users who *do* hold the ERC-721 token",
hidden: false,
invertable: true,
args: {
chainId: {
type: "select",
friendlyName: "Chain",
description: "",
required: true,
options: [
{ value: "1", label: "Ethereum" },
{ value: "10", label: "Optimism" },
{ value: "8453", label: "Base" },
{ value: "7777777", label: "Zora" },
{ value: String(polygon.id), label: "Polygon" },
],
},
contractAddress: {
type: "string",
required: true,
pattern: "0x[a-fA-F0-9]{40}",
placeholder: "0xdead...",
friendlyName: "Contract Address",
description: "",
},
tokenId: {
type: "string",
required: false,
placeholder: "Any Token",
pattern: "[0-9]+",
friendlyName: "Token ID (optional)",
description: "",
},
},
},
userDoesNotHoldPowerBadge: {
name: "userDoesNotHoldPowerBadge",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Power Badge",
checkType: "user",
description: "Check if the user holds a power badge",
invertedDescription: "Check for users who *do* hold the power badge",
hidden: false,
invertable: true,
args: {},
},
userIsCohost: {
name: "userIsCohost",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "Cohosts or Owner",
checkType: "user",
description: "Check if the user is a cohost or owner of the channel",
hidden: false,
invertable: true,
args: {},
},
userProfileContainsText: {
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
name: "userProfileContainsText",
allowMultiple: true,
category: "all",
friendlyName: "Profile Contains Text",
checkType: "user",
description: "Check if the user's profile contains a specific string",
hidden: false,
invertable: true,
args: {
searchText: {
type: "string",
friendlyName: "Search Text",
description: "The text to search for",
},
caseSensitive: {
type: "boolean",
friendlyName: "Case Sensitive",
description: "If checked, 'abc' is different from 'ABC'",
},
},
},
userDisplayNameContainsText: {
name: "userDisplayNameContainsText",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "User Display Name Contains Text",
checkType: "user",
description: "Check if the user's display name contains a specific string",
hidden: false,
invertable: true,
args: {
searchText: {
required: true,
type: "string",
friendlyName: "Search Text",
description: "The text to search for",
},
caseSensitive: {
type: "boolean",
friendlyName: "Case Sensitive",
description: "If checked 'abc' is different from 'ABC'",
},
},
},
userFollowsChannel: {
name: "userFollowsChannel",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: true,
category: "all",
friendlyName: "Follows Channel",
checkType: "user",
hidden: false,
invertable: false,
description: "Check if the user follows a channel",
args: {
channelSlug: {
type: "string",
friendlyName: "Channel ID",
placeholder: "dont-do-this",
required: true,
pattern: "/^[a-zA-Z0-9-]+$/",
description: "The id of the channel to check",
},
},
},
userFollowerCount: {
name: "userFollowerCount",
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
allowMultiple: false,
category: "all",
friendlyName: "User Follower Count",
checkType: "user",
hidden: false,
invertable: false,
description: "Check if the user's follower count is within a range",
args: {
min: {
type: "number",
friendlyName: "Less than",
placeholder: "No Minimum",
description: "If you enter 10, the rule will trigger if the user has less than 10 followers.",
},
max: {
type: "number",
friendlyName: "More than",
placeholder: "No Maximum",
description: "If you enter 50, the rule will trigger if the user has more than 50 followers.",
},
},
},
openRankGlobalEngagement: {
name: "openRankGlobalEngagement",
author: "OpenRank",
authorUrl: "https://openrank.com",
authorIcon: `${hostUrl}/icons/openrank.png`,
allowMultiple: false,
category: "all",
friendlyName: "Global Ranking by OpenRank",
checkType: "cast",
description: "Require the cast author to have a sufficient global ranking.",
hidden: false,
invertable: false,
args: {
minRank: {
type: "number",
friendlyName: "Minimum Rank",
required: true,
description:
"Example: if you enter 100, this rule will check for users ranked 1 to 100. Rankings are based on engagement from trusted accounts.",
},
},
},
openRankChannel: {
name: "openRankChannel",
author: "OpenRank",
authorUrl: "https://openrank.com",
authorIcon: `${hostUrl}/icons/openrank.png`,
allowMultiple: false,
category: "all",
friendlyName: "Channel Ranking by OpenRank",
channelGated: ["memes", "design", "sonata"],
checkType: "cast",
description: "Require the cast author to have a sufficient channel ranking.",
hidden: false,
invertable: false,
args: {
minRank: {
type: "number",
friendlyName: "Minimum Rank",
required: true,
description:
"Example: if you enter 100, this rule will trigger for users ranked 1 to 100 in your channel. Rankings are based on engagement from trusted accounts within your channel.",
},
},
},
userFidInList: {
name: "userFidInList",
allowMultiple: false,
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
category: "all",
friendlyName: "User in List",
checkType: "user",
description: "Check if the cast author is on a list",
hidden: false,
invertable: true,
args: {
fids: {
type: "farcasterUserPickerMulti",
friendlyName: "Farcaster Usernames",
required: true,
placeholder: "Enter a username...",
description: "",
},
},
},
userFidInRange: {
name: "userFidInRange",
allowMultiple: false,
author: "automod",
authorUrl: "https://automod.sh",
authorIcon: `${hostUrl}/icons/automod.png`,
category: "all",
friendlyName: "User FID",
checkType: "user",
description: "Check if the user's FID is less than or greater than a certain value",
hidden: false,
invertable: false,
args: {
minFid: {
type: "number",
friendlyName: "Less than",
placeholder: "No Minimum",
description: "Setting a value of 5 would trigger this rule if the fid is 1 thru 4",
},
maxFid: {
type: "number",
friendlyName: "More than",
description: "Setting a value of 10 would trigger this rule if the fid is 11 or above.",
},
},
},
} as const;
export type ActionDefinition = {
friendlyName: string;
description: string;
/**
* Hide the action from the customer facing UI
* Example: "Bypass" is hidden because it's a special action.
* Note: this is prob an abstraction leak, but it's fine for now.
*/
hidden?: boolean;
/**
* Whether the action can be applied to root casts, reply, or all
* Example: "Boost" only makes sense for root.
*/