Better startup

This commit is contained in:
2026-02-28 01:35:18 +00:00
parent 350301c63d
commit 76da69ce1f
3 changed files with 40 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
using System.Globalization;
using System.Text.Json;
using Valour.Sdk.Models;
using Valour.Sdk.Client;
namespace SkyAI
{
@@ -78,5 +79,32 @@ namespace SkyAI
timer.AutoReset = true;
timer.Start();
}
public static async Task InitializePlanetsAsync(ValourClient client, Dictionary<long, Channel> channelCache, HashSet<long> initializedPlanets)
{
foreach (var planet in client.PlanetService.JoinedPlanets)
{
if (initializedPlanets.Contains(planet.Id))
continue;
Console.WriteLine($"Initializing Planet: {planet.Name}");
await planet.EnsureReadyAsync();
await planet.FetchInitialDataAsync();
foreach (var channel in planet.Channels)
{
channelCache[channel.Id] = channel;
if (channel.ChannelType == Valour.Shared.Models.ChannelTypeEnum.PlanetChat)
{
await channel.OpenWithResult("SkyBot");
Console.WriteLine($"Realtime opened for: {planet.Name} -> {channel.Name}");
}
}
initializedPlanets.Add(planet.Id);
}
}
};
};