Skip to content

Instantly share code, notes, and snippets.

@tajuszk
Last active May 31, 2022 09:48
Show Gist options
  • Save tajuszk/496f641038a80224d62e124cd7162080 to your computer and use it in GitHub Desktop.
Save tajuszk/496f641038a80224d62e124cd7162080 to your computer and use it in GitHub Desktop.
function retweetLatest () {
const accountNames = []; // アカウント名を入れてください
for (let i in accountNames) {
const accountName = accountNames[i];
const includeRT = false // RTを含むか(他のユーザーのツイートのRTも再度RTします)
const retweetCount = 5 // 直近何件のツイートをRTするか
const tweetIds = client.pickupTweetsLatest(accountName, includeRT, retweetCount);
// チェックコード
const tweetShowUrl = 'https://api.twitter.com/1.1/statuses/show.json';
const testParams = [];
for (let i = tweetIds.length - 1; i >= 0; i--) {
const tweetShowParam = {
id: tweetIds[i],
tweet_mode: 'extended' // URLが省略されていることがあるので
}
const tweetShowResult = client.getRequest(tweetShowUrl, tweetShowParam);
const urls = tweetShowResult.entities.urls;
testParams.push({
url: 'https://twitter.com/' + accountName + '/status/' + tweetShowResult.id_str,
text: tweetShowResult.full_text,
link: urls.length > 0 ? 'リンクあり' : 'リンクなし',
media: tweetShowResult.entities.media !== undefined ? '動画あり' : '動画なし',
});
// ここでURLを除外
if (tweetShowResult.entities.urls.length > 0) {
tweetIds.splice(i, 1)
}
}
console.warn('今回のリツイート対象はこちら↓');
console.log(testParams); // ここにツイートが含まれるか確認してみる
client.retweet(tweetIds)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment