Comments (5)
It seems v1.1 streams are now deprecated. So you will have to migrate to v2.
https://twittercommunity.com/t/announcing-the-deprecation-of-v1-1-statuses-filter-endpoint/182960
from tweetinvi.
+1
from tweetinvi.
It seems v1.1 streams are now deprecated. So you will have to migrate to v2. https://twittercommunity.com/t/announcing-the-deprecation-of-v1-1-statuses-filter-endpoint/182960
Oh damn. Thanks for the hint.
from tweetinvi.
In v2 only works Sample Stream. Do you have an example of Filtered Stream?
from tweetinvi.
In v2 only works Sample Stream. Do you have an example of Filtered Stream?
Filteread streams will stop today (29th of April) :
https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api
But anyways here you go
public void StartFilteredStream(ITwitterBot bot, CancellationToken token)
{
_logger.LogDebug("Starting filtered stream");
// Create the twitter filtered stream
FilteredStream = bot.AuthenticatedUser.Client.Streams.CreateFilteredStream(
new CreateFilteredTweetStreamParameters
{
TweetMode = TweetMode.Extended
});
// Set the mention targets (users which will set of the OnMention event)
FilteredStream.AddTrack($"@{bot.Config.Name}");
// Only look for the users in the mentions
FilteredStream.MatchOn = MatchOn.UserMentionEntities;
// Set the event that occurs on a mention
FilteredStream.MatchingTweetReceived += async (sender, args) =>
{
var mentionedTweet = args.Tweet;
if (mentionedTweet != null)
{
// For some reason, I need to do this to get the full tweet
var (Tweet, Error) = await bot.GetTweet(mentionedTweet.Id);
if (Tweet != null)
OnMention?.Invoke(bot, Tweet);
else
if (string.IsNullOrEmpty(Error) == false)
_logger.LogWarning("Error getting tweet {id} : {err}", mentionedTweet.Id, Error);
}
};
// Set these events just for info
FilteredStream.DisconnectMessageReceived += (sender, args) =>
{
_logger.LogWarning("Stream DisconnectMessageReceived code: {code} reason: {reason} stream name: {name}",
args.DisconnectMessage?.Code, args.DisconnectMessage?.Reason, args.DisconnectMessage?.StreamName);
};
_ = Task.Run(async () =>
{
var streamFails = 0;
// Start the stream and wait for it to end
// If the stream ends prematurely, we let it having a break for 30 seconds.
// If it fails 3 times, end the stream
do
{
try
{
await FilteredStream.StartMatchingAllConditionsAsync();
}
catch (TaskCanceledException)
{
// Ignored
}
catch (TwitterException e)
{
_logger.LogError("Twitter exception while starting filtered stream: {err}", e.Message);
}
catch (Exception ex)
{
_logger.LogError("Error while starting filtered stream: {err}", ex.Message);
}
streamFails++;
await Task.Delay(30_000);
} while (streamFails < 3);
// Send a message with the telegram bot to inform that the stream has ended
await _telegramBot.SendMessage("⛔ The stream has ended. We'll try to restart the app...");
// Try to restart the app
_logger.LogDebug("Restarting app...");
Process.Start(new ProcessStartInfo("/usr/sbin/service", "saveflix restart") { Verb = "sudo" });
}, token);
}
from tweetinvi.
Related Issues (20)
- Schedules tweets support
- TrustFailure at client creation HOT 1
- PossiblySensitive being ignored
- ImpressionsCount not on Public Metrics
- .NET MAUI Blazor Hybrid (.NET 7) / TweetinviAPI 5.0.4 - Error - Operation is not supported on this platform
- Fun fact : Chat GPT-4 chose TweetInvi when I asked him a C# question about Twitter filtered stream
- How to get retweets from a particular user. HOT 1
- Twitter V2 List Lookup HOT 1
- V1.1 vs v2.0 API and deprecation HOT 5
- Timelines.GetHomeTimelineAsync HOT 2
- Get user tweets by time period
- Help! My code stopped working HOT 1
- TweetInvi Code stopped working HOT 2
- Stream cannot be read HOT 1
- Forbidden error for fetching UserTimeline HOT 4
- PublishTweetAsync does not publish anything HOT 7
- 403 Forbidden Error
- SearchTweetsV2Parameters: start_time date format is incorrect. It should return 24h format, it uses AM/PM instead HOT 1
- Twitter Tweetinvi.TweetinviContainer Post Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tweetinvi.