Browse Source

added mention to de status message when is a direct message

Pablo Barrera Yaksic 2 months ago
parent
commit
4b080c7359
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/agents/fortune/index.ts

+ 5 - 1
src/agents/fortune/index.ts

@@ -14,7 +14,7 @@ export default class Fortune {
     this._mastodonRestClient = createRestAPIClient({ url: config.MASTODON_API_URL, accessToken });
     this._mastodonRestClient = createRestAPIClient({ url: config.MASTODON_API_URL, accessToken });
   }
   }
 
 
-  private async reply(inReplyToId: string | undefined, user: string, visibility, iteration = 1, count = 1): Promise<void> {
+  private async reply(inReplyToId: string | undefined, user: string, visibility: mastodon.v1.StatusVisibility, iteration = 1, count = 1): Promise<void> {
     let status = "";
     let status = "";
     let spoilerText;
     let spoilerText;
     let stop = false;
     let stop = false;
@@ -61,6 +61,10 @@ export default class Fortune {
         stop = true;
         stop = true;
     }
     }
 
 
+    if (visibility == "direct" && count != 1) {
+      status += `\n@${user}`;
+    }
+
     console.log("Sending status\n", status);
     console.log("Sending status\n", status);
     result = await this._mastodonRestClient.v1.statuses.create({ inReplyToId, spoilerText, status, visibility });
     result = await this._mastodonRestClient.v1.statuses.create({ inReplyToId, spoilerText, status, visibility });