From aa8bf1dcd0281e5e794696ff4400c3fc3aa3a1a3 Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Fri, 15 Jun 2018 06:45:10 +0200 Subject: [PATCH] Unfollow a user if them has changed their mind about the #nobot tag --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8ce5745..9d17b2a 100644 --- a/index.js +++ b/index.js @@ -20,8 +20,10 @@ for (const file of commandFiles) { commands.set(command.name, command) } -// Start the bot and populate following +// Start the bot client.start().then(() => { + + // Populate following list client.following_list().then((result) => { for (const account of result) following.add(account.acct) @@ -59,6 +61,13 @@ function follow_or_not_follow(msg) { if (striptags(msg.account.note).match(/#nobot/i)) { client.mute_user(id); console.log("MUTED #nobot: " + acct); + + // Check if the bot already followed the user + // A.K.A. Did the user add a #nobot tag after I follow them ? + if (following.has(acct)) { + client.unfollow(id); + console.log("UNFOLLOW: " + acct) + } return; } -- GitLab