Files
SkyBot/SkyBot/Services/ChannelService.cs
2026-03-15 05:44:32 +00:00

36 lines
1.2 KiB
C#

using System.Collections.Concurrent;
using System.Security.Cryptography.X509Certificates;
using Valour.Sdk.Models;
using Valour.Shared.Models;
namespace SkyBot.Services
{
public static class ChannelService
{
public static async Task InitializeChannelsAsync(
ConcurrentDictionary<long, Channel> channelCache,
Planet planet)
{
foreach (var channel in planet.Channels)
{
channelCache[channel.Id] = channel;
}
_ = Task.Run(async () =>
{
foreach (var channel in planet.Channels.Where(c => c.ChannelType == ChannelTypeEnum.PlanetChat)){
try
{
await channel.OpenWithResult("SkyBot");
Console.WriteLine($"Realtime opened for: {planet.Name} (ID: {planet.Id}) -> {channel.Name} (ID: {channel.Id})");
} catch (Exception ex)
{
Console.WriteLine($"Error opening realtime for {channel.Id}: {ex.Message}");
}
}
Console.WriteLine($"All channels opened for {planet.Name}.");
});
}
}
}