Skip to content

Commit

Permalink
#419 QuotedTweets are now considered when using a FilteredStream. The…
Browse files Browse the repository at this point in the history
… MatchedTweetReceivedEventArgs now contains new matching properties for the QuotedTweets.
  • Loading branch information
linvi committed Dec 15, 2016
1 parent 217f3ba commit 0da97bc
Show file tree
Hide file tree
Showing 8 changed files with 479 additions and 245 deletions.
9 changes: 9 additions & 0 deletions Tweetinvi.Core/Core/Extensions/DictionaryExtensions.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;

namespace Tweetinvi.Core.Extensions
{
Expand Down Expand Up @@ -32,5 +33,13 @@ public static class DictionaryExtensions
dictionary.Add(key, value);
}
}

public static IDictionary<T1, T2> MergeWith<T1, T2>(this Dictionary<T1, T2> source, Dictionary<T1, T2> other)
{
var dictionaries = new[] { source, other };
return dictionaries.SelectMany(dict => dict)
.ToLookup(pair => pair.Key, pair => pair.Value)
.ToDictionary(group => group.Key, group => group.First());
}
}
}
6 changes: 6 additions & 0 deletions Tweetinvi.Core/Public/Events/TweetEventArgs.cs
Expand Up @@ -47,6 +47,12 @@ public MatchedTweetReceivedEventArgs(ITweet tweet, string json) : base(tweet, js
public ILocation[] MatchingLocations { get; set; }
public long[] MatchingFollowers { get; set; }
public MatchOn MatchOn { get; set; }


public string[] QuotedTweetMatchingTracks { get; set; }
public ILocation[] QuotedTweetMatchingLocations { get; set; }
public long[] QuotedTweetMatchingFollowers { get; set; }
public MatchOn QuotedTweetMatchOn { get; set; }
}

public class TweetDeletedEventArgs : EventArgs
Expand Down
403 changes: 403 additions & 0 deletions Tweetinvi.Streams/FilterStreamTweetMatcher.cs

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions Tweetinvi.Streams/FilterStreamTweetMatcherFactory.cs
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using Tweetinvi.Core.Streaming;
using Tweetinvi.Models;

namespace Tweetinvi.Streams
{
public interface IFilterStreamTweetMatcherFactory
{
IFilterStreamTweetMatcher Create(
IStreamTrackManager<ITweet> streamTrackManager,
Dictionary<ILocation, Action<ITweet>> locations,
Dictionary<long?, Action<ITweet>> followingUserIds);
}

public class FilterStreamTweetMatcherFactory : IFilterStreamTweetMatcherFactory
{
public IFilterStreamTweetMatcher Create(
IStreamTrackManager<ITweet> streamTrackManager,
Dictionary<ILocation, Action<ITweet>> locations,
Dictionary<long?, Action<ITweet>> followingUserIds)
{
return new FilterStreamTweetMatcher(streamTrackManager, locations, followingUserIds);
}
}
}
274 changes: 29 additions & 245 deletions Tweetinvi.Streams/FilteredStream.cs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Tweetinvi.Streams/StreaminviModule.cs
Expand Up @@ -24,6 +24,9 @@ public void Initialize()
_container.RegisterType<ITrackedStream, TrackedStream>();
_container.RegisterType<IFilteredStream, FilteredStream>();

_container.RegisterType<IFilterStreamTweetMatcher, FilterStreamTweetMatcher>();
_container.RegisterType<IFilterStreamTweetMatcherFactory, FilterStreamTweetMatcherFactory>(RegistrationLifetime.InstancePerApplication);

_container.RegisterType<IWarningMessage, WarningMessage>();
_container.RegisterType<IWarningMessageTooManyFollowers, WarningMessageTooManyFollowers>();
_container.RegisterType<IWarningMessageFallingBehind, WarningMessageFallingBehind>();
Expand Down
2 changes: 2 additions & 0 deletions Tweetinvi.Streams/Tweetinvi.Streams.csproj
Expand Up @@ -55,6 +55,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="FilteredStream.cs" />
<Compile Include="FilterStreamTweetMatcher.cs" />
<Compile Include="FilterStreamTweetMatcherFactory.cs" />
<Compile Include="Helpers\QueryGeneratorHelper.cs" />
<Compile Include="Helpers\StreamResultGenerator.cs" />
<Compile Include="Helpers\StreamTrackManager.cs" />
Expand Down
1 change: 1 addition & 0 deletions Tweetinvi.sln.DotSettings
Expand Up @@ -3,4 +3,5 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DTO/@EntryIndexedValue">DTO</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>

0 comments on commit 0da97bc

Please sign in to comment.