private static async void StreamThread(object callback) { Logger.Log(Logger.Info, $"Thread {Thread.CurrentThread.Name} started", Thread.CurrentThread.Name); var stream = Tweetinvi.Stream.CreateFilteredStream(); var user = User.GetAuthenticatedUser(); stream.AddTrack("EDPostcards"); stream.AddTrack("ED_Postcards"); stream.MatchingTweetReceived += (sender, args) => { Logger.Log(Logger.Info, "Received tweet matching filters."); var tweet = args.Tweet; if (!TweetService.CheckTweet(tweet, user)) { return; } Logger.Log(Logger.Neutral, $" [ TWEETING ] \n{tweet.CreatedBy.ScreenName}\n{tweet.Text}\n{tweet.Media.Count} media files", "StreamListener"); TweetService.SendTweet(tweet); }; stream.StreamStopped += (sender, args) => { stream.StartStreamMatchingAllConditions(); }; stream.StartStreamMatchingAnyCondition(); await Task.Delay(-1); }
public async Task Quote(string url = "") { try { var id = Int64.Parse(url.Split('/')[url.Split('/').Length - 1]); var tweet = Tweet.GetTweet(id); if (TweetService.CheckTweet(tweet, User.GetAuthenticatedUser())) { Logger.Log(Logger.Neutral, $"QUOTING {tweet.CreatedBy.ScreenName}\n{tweet.Text}\n{tweet.Media.Count} media files", "Discord Quote"); var response = TweetService.SendTweet(tweet); await ReplyAsync($"Tweet have been quoted : {response.Url}"); } } catch { Logger.Log(Logger.Warning, "Whoopsie", "Discord Quote"); } }