Commit fd0f23a8 authored by Robert Rudman's avatar Robert Rudman

Add extension to filter only to messages

parent 8e623c8b
......@@ -52,13 +52,9 @@ namespace StackExchangeChat.Console
// var result = apiThing.TotalQuestionsByTag("design").GetAwaiter().GetResult();
var chatClient = serviceProvider.GetService<ChatClient>();
chatClient.SubscribeToEvents(ChatSite.StackExchange, 86421).Subscribe(System.Console.WriteLine);
chatClient.SubscribeToEvents(ChatSite.StackExchange, 86421)
.Where(c =>
c.EventDetails.EventType == EventType.MessagePosted
|| c.EventDetails.EventType == EventType.MessageEdited
|| c.EventDetails.EventType == EventType.UserMentioned
)
chatClient
.SubscribeToEvents(ChatSite.StackExchange, 86421)
.OnlyMessages()
.Subscribe(async chatEvent =>
{
try
......
......@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2041
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchangeChat.Console", "StackExchangeChat.Console\StackExchangeChat.Console.csproj", "{09DF63E9-E7A0-4C9A-BBFD-37E8102E7D8B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchangeChat.Console", "StackExchangeChat.Console\StackExchangeChat.Console.csproj", "{09DF63E9-E7A0-4C9A-BBFD-37E8102E7D8B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchangeChat", "StackExchangeChat\StackExchangeChat.csproj", "{3B555F10-2376-4072-9866-7B8462AB056E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchangeChat", "StackExchangeChat\StackExchangeChat.csproj", "{3B555F10-2376-4072-9866-7B8462AB056E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchangeApi", "StackExchangeApi\StackExchangeApi.csproj", "{EADAD8A1-AEBF-49DE-9D99-72EA23984133}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchangeApi", "StackExchangeApi\StackExchangeApi.csproj", "{EADAD8A1-AEBF-49DE-9D99-72EA23984133}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
using System;
using System.Reactive.Linq;
namespace StackExchangeChat.Utilities
{
public static class EventFilters
{
public static IObservable<ChatEvent> OnlyMessages(this IObservable<ChatEvent> observable)
{
return observable.Where(c =>
c.EventDetails.EventType == EventType.MessagePosted ||
c.EventDetails.EventType == EventType.MessageEdited);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment