mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-11-03 08:14:28 -05:00
Added .coordreload which will reload coord.yml when using NadekoBot.Coordinator
- bots with more than 1 shard will now use redis strings provider
This commit is contained in:
@@ -105,7 +105,7 @@ namespace NadekoBot
|
|||||||
.AddSingleton<ISeria, JsonSeria>()
|
.AddSingleton<ISeria, JsonSeria>()
|
||||||
.AddSingleton<IPubSub, RedisPubSub>()
|
.AddSingleton<IPubSub, RedisPubSub>()
|
||||||
.AddSingleton<IConfigSeria, YamlSeria>()
|
.AddSingleton<IConfigSeria, YamlSeria>()
|
||||||
.AddBotStringsServices()
|
.AddBotStringsServices(_creds.TotalShards)
|
||||||
.AddConfigServices()
|
.AddConfigServices()
|
||||||
.AddConfigMigrators()
|
.AddConfigMigrators()
|
||||||
.AddMemoryCache()
|
.AddMemoryCache()
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ namespace NadekoBot.Extensions
|
|||||||
{
|
{
|
||||||
public static class ServiceCollectionExtensions
|
public static class ServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddBotStringsServices(this IServiceCollection services)
|
public static IServiceCollection AddBotStringsServices(this IServiceCollection services, int totalShards)
|
||||||
=> services
|
=> totalShards <= 1
|
||||||
|
? services
|
||||||
.AddSingleton<IStringsSource, LocalFileStringsSource>()
|
.AddSingleton<IStringsSource, LocalFileStringsSource>()
|
||||||
.AddSingleton<IBotStringsProvider, LocalBotStringsProvider>()
|
.AddSingleton<IBotStringsProvider, LocalBotStringsProvider>()
|
||||||
|
.AddSingleton<IBotStrings, BotStrings>()
|
||||||
|
: services.AddSingleton<IStringsSource, LocalFileStringsSource>()
|
||||||
|
.AddSingleton<IBotStringsProvider, RedisBotStringsProvider>()
|
||||||
.AddSingleton<IBotStrings, BotStrings>();
|
.AddSingleton<IBotStrings, BotStrings>();
|
||||||
|
|
||||||
public static IServiceCollection AddConfigServices(this IServiceCollection services)
|
public static IServiceCollection AddConfigServices(this IServiceCollection services)
|
||||||
|
|||||||
@@ -507,6 +507,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await ReplyConfirmLocalizedAsync(strs.bot_strings_reloaded).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync(strs.bot_strings_reloaded).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Aliases]
|
||||||
|
[OwnerOnly]
|
||||||
|
public async Task CoordReload()
|
||||||
|
{
|
||||||
|
await _coord.Reload();
|
||||||
|
await ctx.OkAsync();
|
||||||
|
}
|
||||||
|
|
||||||
private static UserStatus SettableUserStatusToUserStatus(SettableUserStatus sus)
|
private static UserStatus SettableUserStatusToUserStatus(SettableUserStatus sus)
|
||||||
{
|
{
|
||||||
switch (sus)
|
switch (sus)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Services
|
namespace NadekoBot.Services
|
||||||
{
|
{
|
||||||
@@ -10,6 +11,7 @@ namespace NadekoBot.Services
|
|||||||
bool RestartShard(int shardId);
|
bool RestartShard(int shardId);
|
||||||
IList<ShardStatus> GetAllShardStatuses();
|
IList<ShardStatus> GetAllShardStatuses();
|
||||||
int GetGuildCount();
|
int GetGuildCount();
|
||||||
|
Task Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShardStatus
|
public class ShardStatus
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ namespace NadekoBot.Services
|
|||||||
return res.Statuses.Sum(x => x.GuildCount);
|
return res.Statuses.Sum(x => x.GuildCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task Reload()
|
||||||
|
{
|
||||||
|
await _coordClient.ReloadAsync(new());
|
||||||
|
}
|
||||||
|
|
||||||
public Task OnReadyAsync()
|
public Task OnReadyAsync()
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
|
|||||||
@@ -64,5 +64,10 @@ namespace NadekoBot.Services
|
|||||||
{
|
{
|
||||||
return _client.Guilds.Count;
|
return _client.Guilds.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task Reload()
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1263,3 +1263,5 @@ imageonlychannel:
|
|||||||
- imageonlychannel
|
- imageonlychannel
|
||||||
- imageonly
|
- imageonly
|
||||||
- imagesonly
|
- imagesonly
|
||||||
|
coordreload:
|
||||||
|
- coordreload
|
||||||
@@ -2139,3 +2139,7 @@ imageonlychannel:
|
|||||||
Users who send more than a few non-image messages will be banned from using the channel.
|
Users who send more than a few non-image messages will be banned from using the channel.
|
||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
|
coordreload:
|
||||||
|
desc: "Reloads coordinator config"
|
||||||
|
args:
|
||||||
|
- ""
|
||||||
Reference in New Issue
Block a user