some abstraction and I'm gonna kill myself
This commit is contained in:
29
src/util.ts
29
src/util.ts
@ -34,6 +34,34 @@ const recordPendingResponse = async (notification: Notification) => {
|
||||
}
|
||||
};
|
||||
|
||||
const shouldContinue = (notification: Notification) => {
|
||||
// wow this is bad
|
||||
try {
|
||||
const { botAccountId } = envConfig;
|
||||
const statusContent = trimInputData(notification.status.content);
|
||||
if (
|
||||
notification.status.visibility !== "private" &&
|
||||
!notification.account.bot &&
|
||||
notification.type === "mention"
|
||||
) {
|
||||
if (notification.status.in_reply_to_account_id === botAccountId) {
|
||||
return true;
|
||||
} else if (
|
||||
notification.status.in_reply_to_account_id !== botAccountId &&
|
||||
statusContent.includes("Lexi")
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const isFromWhitelistedDomain = (notification: Notification): boolean => {
|
||||
try {
|
||||
const domain = notification.status.account.fqn.split("@")[1];
|
||||
@ -76,4 +104,5 @@ export {
|
||||
trimInputData,
|
||||
recordPendingResponse,
|
||||
isFromWhitelistedDomain,
|
||||
shouldContinue,
|
||||
};
|
||||
|
Reference in New Issue
Block a user