Last active
February 24, 2021 10:21
-
-
Save tajuszk/bbc07a51dc81d5f71e79b5768ad12768 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* シートに記載された人をアンフォロー | |
*/ | |
function unFollowFromSheet () { | |
const ignoreUserIds = []; | |
const whiteUserIds = TwitterClient.getUserIdsFromSheet('ホワイトリスト'); | |
for (let i in whiteUserIds) { | |
// [[123456],[234567],…] という形式で入っているのでIDだけ取り出して ignoreUserIds に入れる | |
ignoreUserIds.push(whiteUserIds[i][0].toString()); | |
} | |
// 1列目に書かれたIDからユーザー情報を取得する | |
const userIds = TwitterClient.getUserIdsFromSheet('シート1'); | |
// indexOf()とspliceを使う方法(前に書いたの不具合ありました…(>_<) | |
for (let i = userIds.length - 1; i >= 0; i--) { | |
if (ignoreUserIds.indexOf(userIds[i].toString()) !== -1) { | |
userIds.splice(i, 1); | |
} | |
} | |
// この方法でもOK | |
// このeditUserIdsを destroyFollowに入れる | |
// const editUserIds = []; | |
// for (let i in userIds) { | |
// // チェックしてOKだったものを入れる | |
// if (ignoreUserIds.indexOf(userIds[i].toString()) === -1) { | |
// editUserIds.push(userIds[i]); | |
// } | |
// } | |
// こんな方法もある | |
// ※ editUserIdsを destroyFollowに入れる | |
// const editUserIds = userIds.filter(function(userId){ | |
// return ignoreUserIds.indexOf(userId.toString()) === -1 | |
// }); | |
client.destroyFollow(userIds) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment