Skip to content

Commit

Permalink
Implemented Twitter API v2 Mentions and User timelines. (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeMayo authored Dec 21, 2020
1 parent d14830e commit 990f7d9
Show file tree
Hide file tree
Showing 6 changed files with 602 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ internal static async Task RunAsync(TwitterContext twitterCtx)
Console.WriteLine("\n\tUn-Hiding a reply...\n");
await UnHideReplyAsync(twitterCtx);
break;
case '4':
Console.WriteLine("\n\tGetting the Mentions Timeline...\n");
await GetMentionsTimelineAsync(twitterCtx);
break;
case '5':
Console.WriteLine("\n\tGetting the User Timeline...\n");
await GetUserTimelineAsync(twitterCtx);
break;
case 'q':
case 'Q':
Console.WriteLine("\nReturning...\n");
Expand All @@ -56,6 +64,8 @@ static void ShowMenu()
Console.WriteLine("\t 1. Multi-Tweet Lookup");
Console.WriteLine("\t 2. Hide a Reply");
Console.WriteLine("\t 3. Un-Hide a Reply");
Console.WriteLine("\t 4. Mentions Timeline");
Console.WriteLine("\t 5. User Timeline");
Console.WriteLine();
Console.Write("\t Q. Return to Main menu");
}
Expand Down Expand Up @@ -153,5 +163,47 @@ static async Task UnHideReplyAsync(TwitterContext twitterCtx)

Console.WriteLine($"Is Hidden: {isHidden}");
}

static async Task GetMentionsTimelineAsync(TwitterContext twitterCtx)
{
string userID = "15411837";

TweetQuery? tweetResponse =
await
(from tweet in twitterCtx.Tweets
where tweet.Type == TweetType.MentionsTimeline &&
tweet.ID == userID
select tweet)
.SingleOrDefaultAsync();

if (tweetResponse?.Tweets != null)
tweetResponse.Tweets.ForEach(tweet =>
Console.WriteLine(
$"\nUser: {tweet.ID}" +
$"\nTweet: {tweet.Text}"));
else
Console.WriteLine("No entries found.");
}

static async Task GetUserTimelineAsync(TwitterContext twitterCtx)
{
string userID = "15411837";

TweetQuery? tweetResponse =
await
(from tweet in twitterCtx.Tweets
where tweet.Type == TweetType.UserTimeline &&
tweet.ID == userID
select tweet)
.SingleOrDefaultAsync();

if (tweetResponse?.Tweets != null)
tweetResponse.Tweets.ForEach(tweet =>
Console.WriteLine(
$"\nUser: {tweet.ID}" +
$"\nTweet: {tweet.Text}"));
else
Console.WriteLine("No entries found.");
}
}
}
Loading

0 comments on commit 990f7d9

Please sign in to comment.