mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Cleaning up projects, project is building
This commit is contained in:
@@ -4,8 +4,16 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using NadekoBot.Common.Configs;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Modules.Administration;
|
||||
using NadekoBot.Modules.Gambling;
|
||||
using NadekoBot.Modules.Help;
|
||||
using NadekoBot.Modules.Music;
|
||||
using NadekoBot.Modules.NadekoExpressions;
|
||||
using NadekoBot.Modules.Patronage;
|
||||
using NadekoBot.Modules.Permissions;
|
||||
using NadekoBot.Modules.Searches;
|
||||
using NadekoBot.Modules.Utility;
|
||||
using NadekoBot.Modules.Xp;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using Ninject;
|
||||
using Ninject.Planning;
|
||||
@@ -94,6 +102,15 @@ public sealed class Bot : IBot
|
||||
|
||||
// modules
|
||||
typeof(NadekoExpressions).Assembly,
|
||||
typeof(Administration).Assembly,
|
||||
typeof(Gambling).Assembly,
|
||||
typeof(Help).Assembly,
|
||||
typeof(Music).Assembly,
|
||||
typeof(Patronage).Assembly,
|
||||
typeof(Permissions).Assembly,
|
||||
typeof(Searches).Assembly,
|
||||
typeof(Utility).Assembly,
|
||||
typeof(Xp).Assembly,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -161,7 +178,6 @@ public sealed class Bot : IBot
|
||||
//initialize Services
|
||||
Services = kernel;
|
||||
Services.GetRequiredService<IBehaviorHandler>().Initialize();
|
||||
Services.GetRequiredService<CurrencyRewardService>();
|
||||
|
||||
if (Client.ShardId == 0)
|
||||
ApplyConfigMigrations();
|
||||
|
@@ -17,7 +17,7 @@ public class MedusaAssemblyLoadContext : AssemblyLoadContext
|
||||
var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
|
||||
if (assemblyPath != null)
|
||||
{
|
||||
Assembly assembly = LoadFromAssemblyPath(assemblyPath);
|
||||
var assembly = LoadFromAssemblyPath(assemblyPath);
|
||||
LoadDependencies(assembly);
|
||||
return assembly;
|
||||
}
|
||||
|
@@ -6,10 +6,12 @@ using Ninject.Modules;
|
||||
using Ninject.Planning;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Nadeko.Medusa;
|
||||
|
||||
public sealed class MedusaNinjectModule : NinjectModule
|
||||
{
|
||||
public override string Name { get; }
|
||||
private volatile bool _isLoaded = false;
|
||||
private volatile bool isLoaded = false;
|
||||
private readonly Dictionary<Type, Type[]> _types;
|
||||
|
||||
public MedusaNinjectModule(Assembly assembly, string name)
|
||||
@@ -24,7 +26,7 @@ public sealed class MedusaNinjectModule : NinjectModule
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (_isLoaded)
|
||||
if (isLoaded)
|
||||
return;
|
||||
|
||||
foreach (var (type, data) in _types)
|
||||
@@ -44,7 +46,7 @@ public sealed class MedusaNinjectModule : NinjectModule
|
||||
}
|
||||
}
|
||||
|
||||
_isLoaded = true;
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
private Func<IContext, object?> GetScope(Lifetime lt)
|
||||
@@ -52,14 +54,15 @@ public sealed class MedusaNinjectModule : NinjectModule
|
||||
{
|
||||
Lifetime.Singleton => this,
|
||||
Lifetime.Transient => null,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
public override void Unload()
|
||||
{
|
||||
if (!_isLoaded)
|
||||
if (!isLoaded)
|
||||
return;
|
||||
|
||||
var planner = (RemovablePlanner)Kernel.Components.Get<IPlanner>();
|
||||
var planner = (RemovablePlanner)Kernel!.Components.Get<IPlanner>();
|
||||
var cache = Kernel.Components.Get<ICache>();
|
||||
foreach (var binding in this.Bindings)
|
||||
{
|
||||
@@ -90,6 +93,6 @@ public sealed class MedusaNinjectModule : NinjectModule
|
||||
var clearCacheMethod = updateHandlerType?.GetMethod("ClearCache", BindingFlags.Static | BindingFlags.Public);
|
||||
clearCacheMethod?.Invoke(null, new object?[] { null });
|
||||
|
||||
_isLoaded = false;
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
@@ -16,7 +16,6 @@ namespace Nadeko.Medusa;
|
||||
public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, INService
|
||||
{
|
||||
private readonly CommandService _cmdService;
|
||||
private readonly IServiceProvider _botServices;
|
||||
private readonly IBehaviorHandler _behHandler;
|
||||
private readonly IPubSub _pubSub;
|
||||
private readonly IMedusaConfigService _medusaConfig;
|
||||
|
@@ -12,5 +12,5 @@ public sealed record ResolvedMedusa(
|
||||
IReadOnlyCollection<ICustomBehavior> Execs
|
||||
)
|
||||
{
|
||||
public INinjectModule KernelModule { get; set; }
|
||||
public required INinjectModule KernelModule { get; set; }
|
||||
}
|
@@ -4,7 +4,7 @@ using NadekoBot.Modules.Gambling.Services;
|
||||
namespace NadekoBot.Modules.Gambling;
|
||||
|
||||
// todo do we need both currencyprovider and currencyservice
|
||||
public sealed class CurrencyProvider : ICurrencyProvider
|
||||
public sealed class CurrencyProvider : ICurrencyProvider, INService
|
||||
{
|
||||
private readonly GamblingConfigService _cs;
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
namespace NadekoBot.Modules;
|
||||
using NadekoBot.Modules;
|
||||
|
||||
namespace NadekoBot.Modules;
|
||||
|
||||
public interface IMedusaeRepositoryService
|
||||
{
|
||||
|
@@ -1,6 +1,8 @@
|
||||
public class ModuleItem
|
||||
namespace NadekoBot.Modules;
|
||||
|
||||
public sealed class ModuleItem
|
||||
{
|
||||
public string Name { get; init; }
|
||||
public string Description { get; init; }
|
||||
public string Command { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public required string Description { get; init; }
|
||||
public required string Command { get; init; }
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
namespace NadekoBot.Modules;
|
||||
|
||||
public class ModuleItem
|
||||
{
|
||||
public string Name { get; init; }
|
||||
public string Description { get; init; }
|
||||
public string Command { get; init; }
|
||||
}
|
@@ -24,94 +24,97 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<Publish>True</Publish>
|
||||
</PackageReference>
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.101.58" />
|
||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
|
||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.58.0.2874" />
|
||||
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.51.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.51.0">
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.101.58"/>
|
||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6"/>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
|
||||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110"/>
|
||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138"/>
|
||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.60.0.2945"/>
|
||||
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084"/>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.22.1"/>
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.52.0"/>
|
||||
<PackageReference Include="Grpc.Tools" Version="2.53.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Html2Markdown" Version="5.1.0.703" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.4.0" />
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Html2Markdown" Version="5.1.0.703"/>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.5.0"/>
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0"/>
|
||||
|
||||
<PackageReference Include="MorseCode.ITask" Version="2.0.3"/>
|
||||
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.0.0"/>
|
||||
|
||||
<PackageReference Include="MorseCode.ITask" Version="2.0.3" />
|
||||
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.2.0" />
|
||||
|
||||
<!-- DI -->
|
||||
<PackageReference Include="Ninject" Version="3.3.6" />
|
||||
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
|
||||
<!-- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />-->
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<!-- <PackageReference Include="Scrutor" Version="4.2.0" />-->
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="NonBlocking" Version="2.1.1" />
|
||||
<PackageReference Include="OneOf" Version="3.0.223" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
|
||||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta17" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
|
||||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.6.90" />
|
||||
<PackageReference Include="YamlDotNet" Version="12.3.1" />
|
||||
|
||||
<PackageReference Include="Ninject" Version="3.3.6"/>
|
||||
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0"/>
|
||||
<!-- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />-->
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0"/>
|
||||
<!-- <PackageReference Include="Scrutor" Version="4.2.0" />-->
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||
<PackageReference Include="NonBlocking" Version="2.1.1"/>
|
||||
<PackageReference Include="OneOf" Version="3.0.243"/>
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2"/>
|
||||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta17"/>
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3"/>
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14"/>
|
||||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009"/>
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.6.104"/>
|
||||
<PackageReference Include="YamlDotNet" Version="13.0.2"/>
|
||||
|
||||
<PackageReference Include="Humanizer" Version="2.14.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<Publish>True</Publish>
|
||||
</PackageReference>
|
||||
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
|
||||
|
||||
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1"/>
|
||||
|
||||
|
||||
<!-- Db-related packages -->
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
<PackageReference Include="linq2db.EntityFrameworkCore" Version="7.1.0" />
|
||||
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.1" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
|
||||
|
||||
<PackageReference Include="EFCore.NamingConventions" Version="7.0.2" />
|
||||
|
||||
<PackageReference Include="linq2db.EntityFrameworkCore" Version="7.3.0"/>
|
||||
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4"/>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3"/>
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0"/>
|
||||
|
||||
<PackageReference Include="EFCore.NamingConventions" Version="7.0.2"/>
|
||||
|
||||
<!-- Used by stream notifications -->
|
||||
<PackageReference Include="TwitchLib.Api" Version="3.4.1" />
|
||||
|
||||
<PackageReference Include="TwitchLib.Api" Version="3.4.1"/>
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ayu\Ayu.Discord.Voice\Ayu.Discord.Voice.csproj" />
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Music\Nadeko.Bot.Modules.Music.csproj" />
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Permisssions\Nadeko.Bot.Modules.Permisssions.csproj" />
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Utility\Nadeko.Bot.Modules.Utility.csproj" />
|
||||
<!-- <ProjectReference Include="..\Nadeko.Common\Nadeko.Common.csproj" />-->
|
||||
<ProjectReference Include="..\Nadeko.Econ\Nadeko.Econ.csproj" />
|
||||
<ProjectReference Include="..\Nadeko.Medusa\Nadeko.Medusa.csproj" />
|
||||
<ProjectReference Include="..\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj" />
|
||||
<ProjectReference Include="..\NadekoBot.Generators\NadekoBot.Generators.csproj" OutputItemType="Analyzer" />
|
||||
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Expresssions\Nadeko.Bot.Modules.Expresssions.csproj" />
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Gambling\Nadeko.Bot.Modules.Gambling.csproj" />
|
||||
<ProjectReference Include="..\ayu\Ayu.Discord.Voice\Ayu.Discord.Voice.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Econ\Nadeko.Econ.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Medusa\Nadeko.Medusa.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Administration\Nadeko.Bot.Modules.Administration.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Help\Nadeko.Bot.Modules.Help.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Music\Nadeko.Bot.Modules.Music.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Patronage\Nadeko.Bot.Modules.Patronage.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Permisssions\Nadeko.Bot.Modules.Permisssions.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Utility\Nadeko.Bot.Modules.Utility.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Xp\Nadeko.Bot.Modules.Xp.csproj"/>
|
||||
<!-- <ProjectReference Include="..\Nadeko.Common\Nadeko.Common.csproj" />-->
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Expresssions\Nadeko.Bot.Modules.Expresssions.csproj"/>
|
||||
<ProjectReference Include="..\Nadeko.Bot.Modules.Gambling\Nadeko.Bot.Modules.Gambling.csproj"/>
|
||||
|
||||
<ProjectReference Include="..\Nadeko.Bot.Generators.Cloneable\Nadeko.Bot.Generators.Cloneable.csproj" OutputItemType="Analyzer"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Protobuf Include="..\NadekoBot.Coordinator\Protos\coordinator.proto" GrpcServices="Client">
|
||||
@@ -128,7 +131,7 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Common\TypeReaders\" />
|
||||
<Folder Include="Common\TypeReaders\"/>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||
|
@@ -24,10 +24,12 @@ public sealed class PermissionChecker : IPermissionChecker, INService
|
||||
IMessageChannel channel,
|
||||
IUser author,
|
||||
string module,
|
||||
string cmd)
|
||||
string? cmd)
|
||||
{
|
||||
module = module.ToLowerInvariant();
|
||||
cmd = cmd?.ToLowerInvariant();
|
||||
// todo add proper string
|
||||
if (await _cmdCds.TryBlock(guild, author, cmd))
|
||||
if (cmd is not null && await _cmdCds.TryBlock(guild, author, cmd))
|
||||
return new Error<LocStr>(new());
|
||||
|
||||
try
|
||||
|
@@ -989,6 +989,7 @@
|
||||
"module_description_searches": "Search for jokes, images of animals, anime and manga",
|
||||
"module_description_xp": "Gain xp based on chat activity, check users' xp cards",
|
||||
"module_description_medusa": "**Bot Owner only.** Load, unload and handle dynamic modules. Read more [here](https://nadekobot.readthedocs.io/en/latest/medusa/creating-a-medusa/)",
|
||||
"module_description_patronage": "Commands related to supporting the bot",
|
||||
"module_description_missing": "Description is missing for this module.",
|
||||
"purge_user_confirm": "Are you sure that you want to purge {0} from the database?",
|
||||
"expr_import_no_input": "Invalid input. No valid file upload or input text found.",
|
||||
|
Reference in New Issue
Block a user