forked from kale5195/ModBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paragrah.ts
44 lines (40 loc) · 1.5 KB
/
paragrah.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
import { checkSubscribesOnParagraph } from "~/lib/neynar.server";
import { CheckFunction, CheckFunctionArgs, RuleDefinition } from "~/rules/rules.type";
async function subscribesOnParagraph(args: CheckFunctionArgs) {
const { user, rule } = args;
const { farcasterUser } = rule.args as { farcasterUser: { value: number; label: string; icon: string } };
const isSubbed = await checkSubscribesOnParagraph({ fid: user.fid, value: farcasterUser.value });
return {
result: isSubbed,
message: isSubbed
? `User is subscribed to @${farcasterUser.label} on Paragraph `
: `User is not subscribed to @${farcasterUser.label} on Paragraph`,
};
}
type RuleName = "subscribesOnParagraph";
export const paragraphRulesFunction: Record<RuleName, CheckFunction> = {
subscribesOnParagraph,
};
export const paragraphRulesDefinitions: Record<RuleName, RuleDefinition> = {
subscribesOnParagraph: {
name: "subscribesOnParagraph",
author: "Paragraph",
authorUrl: "https://paragraph.xyz",
authorIcon: `/icons/paragraph2.png`,
allowMultiple: true,
category: "all",
friendlyName: "Subscribes on Paragraph",
checkType: "user",
description: "Check if the user 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.",
},
},
},
};