//native
type Greip = {
apiKey: string;
};
/**
* Detect profanity in a given text
* This method helps safeguard your website or app by detecting offensive or inappropriate language in user inputs. By screening for profanity and other harmful content before it’s made public, you can maintain a positive user environment, protect your brand, and prevent abusive behavior on your platform.
*/
export async function main(
auth: Greip,
text: string,
listBadWords: string | undefined,
scoreOnly: string | undefined,
format: string | undefined,
userID: string | undefined,
mode: string | undefined,
callback: string | undefined,
) {
const url = new URL(`https://greipapi.com/scoring/profanity`);
for (const [k, v] of [
["text", text],
["listBadWords", listBadWords],
["scoreOnly", scoreOnly],
["format", format],
["userID", userID],
["mode", mode],
["callback", callback],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago