don't reply when not addressed

This commit is contained in:
2025-08-03 18:56:05 +00:00
parent b6ad54f40a
commit aaf4adcf06
2 changed files with 15 additions and 3 deletions

View File

@ -42,6 +42,7 @@ export const envConfig = {
adHocPostInterval: process.env.RANDOM_POST_INTERVAL
? parseInt(process.env.RANDOM_POST_INTERVAL)
: 3600000,
botAccountId: process.env.PLEROMA_ACCOUNT_ID,
};
const ollamaConfig: OllamaConfigOptions = {
@ -58,13 +59,23 @@ const ollamaConfig: OllamaConfigOptions = {
const generateOllamaRequest = async (
notification: Notification
): Promise<OllamaResponse | undefined> => {
const { whitelistOnly, ollamaModel, ollamaSystemPrompt, ollamaUrl } =
envConfig;
const {
whitelistOnly,
ollamaModel,
ollamaSystemPrompt,
ollamaUrl,
botAccountId,
} = envConfig;
try {
console.log(trimInputData(notification.status.content));
if (
// striptags(notification.status.content).includes("!prompt") &&
!notification.status.account.bot && // sanity check, sort of
notification.type === "mention" // &&
notification.type === "mention" &&
(notification.status.in_reply_to_account_id === botAccountId ||
notification.status.in_reply_to_account_id === null) &&
trimInputData(notification.status.content).split(" ").includes("Lexi")
// only reply to mentions when the bot is the direct recipient or when an @ is at the top level of a conversation chain, or when the AI is @ directly
// notification.status.visibility !== "private" // for safety, let's only respond to public messages
) {
if (whitelistOnly && !isFromWhitelistedDomain(notification)) {