diff --git a/Services/BotService.cs b/Services/BotService.cs index 61d213b..5478b6b 100644 --- a/Services/BotService.cs +++ b/Services/BotService.cs @@ -88,6 +88,8 @@ namespace Reactor.Services } }; + + //Bot is active and ready Console.WriteLine("Bot ready and listening..."); } diff --git a/Services/PlanetService.cs b/Services/PlanetService.cs index 08b1817..360d589 100644 --- a/Services/PlanetService.cs +++ b/Services/PlanetService.cs @@ -1,4 +1,5 @@ using Valour.Sdk.Client; +using Valour.Sdk.ModelLogic; using Valour.Sdk.Models; using Valour.Shared.Models; @@ -20,6 +21,7 @@ namespace Reactor.Services await planet.EnsureReadyAsync(); await planet.FetchInitialDataAsync(); + foreach (var channel in planet.Channels) { @@ -32,6 +34,28 @@ namespace Reactor.Services } } + Action> channelChangedHandler = (evt) => + { + _ = Task.Run(async () => + { + foreach (var channel in planet.Channels) + { + if (channelCache.ContainsKey(channel.Id)) + continue; + + channelCache[channel.Id] = channel; + + if (channel.ChannelType == ChannelTypeEnum.PlanetChat) + { + await channel.OpenWithResult("Reactor"); + Console.WriteLine($"New channel detected: {planet.Name} -> {channel.Name}"); + } + } + }); + }; + + planet.Channels.Changed += channelChangedHandler; + initializedPlanets.Add(planet.Id); } }