Last active
April 21, 2022 05:50
-
-
Save tajuszk/9d001c91e226c3949b2f884b6b794205 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 retweetLatest () { | |
// 最新のツイートのツイートIDを取得する | |
const accountName = 'belltreeszk' // 対象のアカウントの @~~~~ の部分を記入 | |
const includeRT = false // RTを含むか(他のユーザーのツイートのRTも再度RTします) | |
const retweetCount = 3 // 直近何件のツイートをRTするか | |
const tweetIds = client.pickupTweetsLatest(accountName, includeRT, retweetCount); | |
// URLが含まれているものを除く | |
const tweetShowUrl = 'https://api.twitter.com/1.1/statuses/show.json'; | |
for (let i = tweetIds.length - 1; i >= 0; i--) { | |
const tweetShowParam = { | |
id: tweetIds[i], | |
} | |
const tweetShowResult = client.getRequest(tweetShowUrl, tweetShowParam); | |
// ここでURLの有無をチェック | |
if (tweetShowResult.entities.urls.length > 0) { | |
tweetIds.splice(i, 1); | |
} | |
} | |
// 受け取ったツイートIDのツイートをすべてリツイートする | |
client.retweet(tweetIds) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment