forked from jtgi/automod
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbot-or-not.ts
More file actions
49 lines (43 loc) · 1.44 KB
/
bot-or-not.ts
File metadata and controls
49 lines (43 loc) · 1.44 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
import axios from "axios";
import { CheckFunction, CheckFunctionArgs, RuleDefinition } from "~/rules/rules.type";
type BotOrNotResponse = { fid: number; result: { bot?: boolean; status: "complete" | "analyzing" } };
async function isHuman(args: CheckFunctionArgs) {
const { user } = args;
const rsp = await axios.get<BotOrNotResponse>(
`https://cast-action-bot-or-not.vercel.app/api/botornot/mod/v1?fid=${user.fid}&forceAnalyzeIfEmpty=true`,
{
timeout: 5_000,
timeoutErrorMessage: "Bot or Not API timed out",
}
);
const isBot = rsp.data.result.bot;
if (isBot === undefined) {
// retry later
throw new Error(`Bot or not status for fid #${rsp.data.fid}: ${rsp.data.result.status}`);
}
return {
result: !isBot,
message: isBot ? "Bot detected by Bot Or Not" : "Human detected by Bot Or Not",
};
}
type RuleName = "isHuman";
export const botOrNotRulesFunction: Record<RuleName, CheckFunction> = {
isHuman: isHuman,
};
export const botOrNotRulesDefinitions: Record<RuleName, RuleDefinition> = {
isHuman: {
name: "isHuman",
author: "botornot",
authorUrl: "https://warpcast.com/botornot",
authorIcon: `/icons/botornot.png`,
allowMultiple: false,
checkType: "user",
category: "all",
friendlyName: "Proof of Human, by Bot or Not",
description: "Check if the user is a human using Bot Or Not",
hidden: false,
fidGated: [5179],
invertable: false,
args: {},
},
};