使用 twit npm 从 user_timeline 获取最新推文

Get latest tweet from user_timeline with twit npm

我正在尝试创建一个带有新推文通知的 discord 机器人。

我为此使用 T.stream('statuses/filter', { follow : ['798934987978510337'] });,但它也显示提及。

我可以只获取来自 twit 用户的推文吗?

不,statuses/filter 流 API 确实也包含转推。如果您不想将转推传递给 Discord,则需要在您自己的代码中过滤掉转推。

以下代码适合我。参考https://twittercommunity.com/t/only-receive-latest-tweet-from-specific-user-twit-npm/151478

var twitParams =
{
  exclude_replies: false,
  count: 1,
  screen_name: "your screen name excluding @"
}

T.get("statuses/user_timeline", twitParams, function(err, data, response) {
  console.log(data);
});