Big Update!
Joins planets 100% of the time on startup Finds channels on planet join while bot is on
This commit is contained in:
33
utils.cs
33
utils.cs
@@ -1,8 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text.Json;
|
||||
using Valour.Sdk.Models;
|
||||
using Valour.Sdk.Client;
|
||||
|
||||
namespace SkyBot
|
||||
{
|
||||
@@ -80,5 +79,35 @@ namespace SkyBot
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user