Browse Source

filtered type of notifications

Pablo Barrera Yaksic 2 months ago
parent
commit
c95fd8d785
1 changed files with 11 additions and 3 deletions
  1. 11 3
      src/agents/fortune/index.ts

+ 11 - 3
src/agents/fortune/index.ts

@@ -78,9 +78,17 @@ export default class Fortune {
     for await (const event of this._mastodonStreamingClient.user.notification.subscribe()) {
       switch(event.event) {
         case "notification":
-          const {id, createdAt, url, content} = event.payload.status ?? {};
-          console.log("Event received\n", { id, createdAt, url, content });
-          await this.reply(event.payload.status?.id, event.payload.account.displayName, Math.floor(Math.random() * 10));
+          if (event.payload.type == "mention") {
+            const {id, createdAt, url, content} = event.payload.status ?? {};
+
+            if (config.DEVELOP) {
+              console.log("Event received\n", event.payload);
+            } else {
+              console.log("Event received\n", { id, createdAt, url, content });
+            }
+
+            await this.reply(event.payload.status?.id, event.payload.account.displayName, Math.floor(Math.random() * 10));
+            }
           break;
       }
     };