don't reply when not addressed
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
DATABASE_URL="file:../dev.db" # SQLite database relative to the ./prisma path
|
||||
PLEROMA_INSTANCE_URL="https://instance.tld" # Pleroma instance full URL including scheme
|
||||
PLEROMA_INSTANCE_DOMAIN="instance.tld" # used if you want to only want to respond to people from a particular instance
|
||||
PLEROMA_ACCOUNT_ID="" # obtained from /api/v1/accounts/{nickname} - used so we don't spam mentions when not directly addressed
|
||||
ONLY_WHITELIST="true" # change to "false" if you want to accept prompts from any and all domains - *** USE WITH CAUTION ***
|
||||
WHITELISTED_DOMAINS="" # comma separated list of domains you want to allow the bot to accept prompts from (i.e. poa.st,nicecrew.digital,detroitriotcity.com,decayable.ink)
|
||||
OLLAMA_URL="http://localhost:11434" # OLLAMA connection URL
|
||||
|
17
src/main.ts
17
src/main.ts
@ -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)) {
|
||||
|
Reference in New Issue
Block a user