nadekobot almost builds

This commit is contained in:
Kwoth
2023-03-16 02:41:40 +01:00
parent 7a60868632
commit db2328cdaf
170 changed files with 397 additions and 202 deletions

View File

@@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Db", "src\Nadeko
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Common", "src\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj", "{02ABC10E-3323-4698-A388-C61D7D03797E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Common", "src\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj", "{02ABC10E-3323-4698-A388-C61D7D03797E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Generators.Cloneable", "src\Nadeko.Bot.Generators.Cloneable\Nadeko.Bot.Generators.Cloneable.csproj", "{A5E71EE3-786E-438C-95C0-5BC558FCECCF}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -120,6 +122,12 @@ Global
{02ABC10E-3323-4698-A388-C61D7D03797E}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU {02ABC10E-3323-4698-A388-C61D7D03797E}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
{02ABC10E-3323-4698-A388-C61D7D03797E}.Release|Any CPU.ActiveCfg = Release|Any CPU {02ABC10E-3323-4698-A388-C61D7D03797E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02ABC10E-3323-4698-A388-C61D7D03797E}.Release|Any CPU.Build.0 = Release|Any CPU {02ABC10E-3323-4698-A388-C61D7D03797E}.Release|Any CPU.Build.0 = Release|Any CPU
{A5E71EE3-786E-438C-95C0-5BC558FCECCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5E71EE3-786E-438C-95C0-5BC558FCECCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5E71EE3-786E-438C-95C0-5BC558FCECCF}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
{A5E71EE3-786E-438C-95C0-5BC558FCECCF}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
{A5E71EE3-786E-438C-95C0-5BC558FCECCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5E71EE3-786E-438C-95C0-5BC558FCECCF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -138,6 +146,7 @@ Global
{92E239B9-C230-4475-9506-BED20174FD20} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2} {92E239B9-C230-4475-9506-BED20174FD20} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
{02499E3E-3B04-4BC8-9B3C-D9494661F78E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2} {02499E3E-3B04-4BC8-9B3C-D9494661F78E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
{02ABC10E-3323-4698-A388-C61D7D03797E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2} {02ABC10E-3323-4698-A388-C61D7D03797E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
{A5E71EE3-786E-438C-95C0-5BC558FCECCF} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4} SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}

View File

@@ -5,7 +5,7 @@ public interface IBotCredentials
{ {
string Token { get; } string Token { get; }
string GoogleApiKey { get; } string GoogleApiKey { get; }
ICollection<ulong> OwnerIds { get; } ICollection<ulong> OwnerIds { get; set; }
bool UsePrivilegedIntents { get; } bool UsePrivilegedIntents { get; }
string RapidApiKey { get; } string RapidApiKey { get; }

View File

@@ -0,0 +1,13 @@
#nullable disable
using YamlDotNet.Serialization;
namespace NadekoBot.Services;
public sealed class CommandStrings
{
[YamlMember(Alias = "desc")]
public string Desc { get; set; }
[YamlMember(Alias = "args")]
public string[] Args { get; set; }
}

View File

@@ -12,6 +12,6 @@ public interface IBotStrings
string GetText(string key, ulong? guildId = null, params object[] data); string GetText(string key, ulong? guildId = null, params object[] data);
string GetText(string key, CultureInfo locale, params object[] data); string GetText(string key, CultureInfo locale, params object[] data);
void Reload(); void Reload();
ICommandStrings GetCommandStrings(string commandName, ulong? guildId = null); CommandStrings GetCommandStrings(string commandName, ulong? guildId = null);
ICommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo); CommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo);
} }

View File

@@ -24,5 +24,5 @@ public interface IBotStringsProvider
/// </summary> /// </summary>
/// <param name="localeName">Language name</param> /// <param name="localeName">Language name</param>
/// <param name="commandName">Command name</param> /// <param name="commandName">Command name</param>
ICommandStrings GetCommandStrings(string localeName, string commandName); CommandStrings GetCommandStrings(string localeName, string commandName);
} }

View File

@@ -1,8 +0,0 @@
#nullable disable
namespace NadekoBot.Services;
public interface ICommandStrings
{
string Desc { get; set; }
string[] Args { get; set; }
}

View File

@@ -1,4 +1,5 @@
#nullable disable #nullable disable
namespace NadekoBot.Services; namespace NadekoBot.Services;
/// <summary> /// <summary>
@@ -12,5 +13,5 @@ public interface IStringsSource
/// <returns>Dictionary(localename, Dictionary(key, response))</returns> /// <returns>Dictionary(localename, Dictionary(key, response))</returns>
Dictionary<string, Dictionary<string, string>> GetResponseStrings(); Dictionary<string, Dictionary<string, string>> GetResponseStrings();
Dictionary<string, Dictionary<string, ICommandStrings>> GetCommandStrings(); Dictionary<string, Dictionary<string, CommandStrings>> GetCommandStrings();
} }

View File

@@ -1,13 +1,13 @@
namespace NadekoBot.Common; // namespace NadekoBot.Common;
//
public readonly struct LocStr // public readonly struct LocStr
{ // {
public readonly string Key; // public readonly string Key;
public readonly object[] Params; // public readonly object[] Params;
//
public LocStr(string key, params object[] data) // public LocStr(string key, params object[] data)
{ // {
Key = key; // Key = key;
Params = data; // Params = data;
} // }
} // }

View File

@@ -4,7 +4,6 @@ using Cloneable;
using NadekoBot.Common.Yml; using NadekoBot.Common.Yml;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using System.Globalization; using System.Globalization;
using Microsoft.EntityFrameworkCore;
using YamlDotNet.Core; using YamlDotNet.Core;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;

View File

@@ -7,6 +7,6 @@ namespace NadekoBot.Extensions;
public static class DbExtensions public static class DbExtensions
{ {
public static DiscordUser GetOrCreateUser(this NadekoContext ctx, IUser original, Func<IQueryable<DiscordUser>, IQueryable<DiscordUser>> includes = null) public static DiscordUser GetOrCreateUser(this NadekoContext ctx, IUser original, Func<IQueryable<DiscordUser>, IQueryable<DiscordUser>>? includes = null)
=> ctx.GetOrCreateUser(original.Id, original.Username, original.Discriminator, original.AvatarId, includes); => ctx.GetOrCreateUser(original.Id, original.Username, original.Discriminator, original.AvatarId, includes);
} }

View File

@@ -4,7 +4,6 @@
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -25,5 +24,14 @@
<Publish>True</Publish> <Publish>True</Publish>
</PackageReference> </PackageReference>
<ProjectReference Include="..\Nadeko.Medusa\Nadeko.Medusa.csproj" /> <ProjectReference Include="..\Nadeko.Medusa\Nadeko.Medusa.csproj" />
<ProjectReference Include="..\NadekoBot.Generators\NadekoBot.Generators.csproj" OutputItemType="Analyzer" />
</ItemGroup>
<ItemGroup>
<None Update="data\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<AdditionalFiles Include="data\strings\responses\responses.en-US.json" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,6 +1,6 @@
#nullable disable #nullable disable
using NadekoBot.Modules.Administration.Services;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NonBlocking;
namespace NadekoBot.Common; namespace NadekoBot.Common;
@@ -59,19 +59,20 @@ public class ReplacementBuilder
_reps.TryAdd("%server.members%", () => g is { } sg ? sg.MemberCount.ToString() : "?"); _reps.TryAdd("%server.members%", () => g is { } sg ? sg.MemberCount.ToString() : "?");
_reps.TryAdd("%server.boosters%", () => g.PremiumSubscriptionCount.ToString()); _reps.TryAdd("%server.boosters%", () => g.PremiumSubscriptionCount.ToString());
_reps.TryAdd("%server.boost_level%", () => ((int)g.PremiumTier).ToString()); _reps.TryAdd("%server.boost_level%", () => ((int)g.PremiumTier).ToString());
_reps.TryAdd("%server.time%", // todo fix
() => // _reps.TryAdd("%server.time%",
{ // () =>
var to = TimeZoneInfo.Local; // {
if (g is not null) // var to = TimeZoneInfo.Local;
{ // if (g is not null)
if (GuildTimezoneService.AllServices.TryGetValue(client.CurrentUser.Id, out var tz)) // {
to = tz.GetTimeZoneOrDefault(g.Id) ?? TimeZoneInfo.Local; // if (GuildTimezoneService.AllServices.TryGetValue(client.CurrentUser.Id, out var tz))
} // to = tz.GetTimeZoneOrDefault(g.Id) ?? TimeZoneInfo.Local;
// }
return TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.Utc, to).ToString("HH:mm ") //
+ to.StandardName.GetInitials(); // return TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.Utc, to).ToString("HH:mm ")
}); // + to.StandardName.GetInitials();
// });
return this; return this;
} }

View File

@@ -1,6 +1,15 @@
namespace NadekoBot.Services; using NadekoBot.Modules.Administration;
using NonBlocking;
namespace NadekoBot.Services;
public interface ICommandHandler public interface ICommandHandler
{ {
string GetPrefix(IGuild ctxGuild); string GetPrefix(IGuild ctxGuild);
string GetPrefix(ulong? id = null);
string SetDefaultPrefix(string toSet);
string SetPrefix(IGuild ctxGuild, string toSet);
ConcurrentDictionary<ulong, uint> UserMessagesSent { get; }
Task TryRunCommand(SocketGuild guild, ISocketMessageChannel channel, IUserMessage usrMsg);
} }

View File

@@ -2,7 +2,6 @@ using NadekoBot.Common.Configs;
using NadekoBot.Common.Yml; using NadekoBot.Common.Yml;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Common; using NadekoBot.Common;
namespace NadekoBot.Services; namespace NadekoBot.Services;

View File

@@ -0,0 +1,23 @@
#nullable disable
namespace NadekoBot.Common.TypeReaders;
public class CommandOrExprInfo
{
public enum Type
{
Normal,
Custom
}
public string Name { get; set; }
public Type CmdType { get; set; }
public bool IsCustom
=> CmdType == Type.Custom;
public CommandOrExprInfo(string input, Type type)
{
Name = input;
CmdType = type;
}
}

View File

@@ -15,7 +15,7 @@ public static class ReflectionExtensions
if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType) if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
return true; return true;
Type baseType = givenType.BaseType; var baseType = givenType.BaseType;
if (baseType == null) return false; if (baseType == null) return false;
return IsAssignableToGenericType(baseType, genericType); return IsAssignableToGenericType(baseType, genericType);

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1 @@
4.3.13

Some files were not shown because too many files have changed in this diff Show More