mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Global usings and file scoped namespaces
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<EnablePreviewFeatures>True</EnablePreviewFeatures>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@@ -6,11 +6,8 @@ using NadekoBot.Common;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using NadekoBot.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
@@ -19,13 +16,11 @@ using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Common.Configs;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
using NadekoBot.Modules.Searches;
|
||||
using Serilog;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed class Bot
|
||||
{
|
||||
public sealed class Bot
|
||||
{
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly CommandService _commandService;
|
||||
private readonly DbService _db;
|
||||
@@ -361,5 +356,4 @@ namespace NadekoBot
|
||||
await RunAsync().ConfigureAwait(false);
|
||||
await Task.Delay(-1).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class AsyncLazy<T> : Lazy<Task<T>>
|
||||
{
|
||||
public class AsyncLazy<T> : Lazy<Task<T>>
|
||||
{
|
||||
public AsyncLazy(Func<T> valueFactory) :
|
||||
base(() => Task.Run(valueFactory))
|
||||
{ }
|
||||
@@ -15,6 +14,4 @@ namespace NadekoBot.Common
|
||||
{ }
|
||||
|
||||
public TaskAwaiter<T> GetAwaiter() { return Value.GetAwaiter(); }
|
||||
}
|
||||
|
||||
}
|
@@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
namespace NadekoBot.Common.Attributes
|
||||
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class AliasesAttribute : AliasAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class AliasesAttribute : AliasAttribute
|
||||
{
|
||||
public AliasesAttribute([CallerMemberName] string memberName = "")
|
||||
: base(CommandNameLoadHelper.GetAliasesFor(memberName))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord;
|
||||
|
||||
public class BotPermAttribute : RequireBotPermissionAttribute
|
||||
{
|
||||
public class BotPermAttribute : RequireBotPermissionAttribute
|
||||
{
|
||||
public BotPermAttribute(GuildPerm permission) : base((GuildPermission)permission)
|
||||
{
|
||||
}
|
||||
@@ -11,5 +11,4 @@ namespace Discord
|
||||
public BotPermAttribute(ChannelPerm permission) : base((ChannelPermission)permission)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
public static class CommandNameLoadHelper
|
||||
{
|
||||
public static class CommandNameLoadHelper
|
||||
{
|
||||
|
||||
private static YamlDotNet.Serialization.IDeserializer _deserializer
|
||||
= new YamlDotNet.Serialization.Deserializer();
|
||||
@@ -32,5 +29,4 @@ namespace NadekoBot.Common.Attributes
|
||||
: methodName;
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class DescriptionAttribute : SummaryAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class DescriptionAttribute : SummaryAttribute
|
||||
{
|
||||
// Localization.LoadCommand(memberName.ToLowerInvariant()).Desc
|
||||
public DescriptionAttribute(string text = "") : base(text)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
namespace Discord.Commands
|
||||
namespace Discord.Commands;
|
||||
|
||||
public class LeftoverAttribute : RemainderAttribute
|
||||
{
|
||||
public class LeftoverAttribute : RemainderAttribute
|
||||
{
|
||||
public LeftoverAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class NadekoCommandAttribute : CommandAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class NadekoCommandAttribute : CommandAttribute
|
||||
{
|
||||
public NadekoCommandAttribute([CallerMemberName] string memberName="")
|
||||
: base(CommandNameLoadHelper.GetCommandNameFor(memberName))
|
||||
{
|
||||
@@ -15,5 +13,4 @@ namespace NadekoBot.Common.Attributes
|
||||
}
|
||||
|
||||
public string MethodName { get; }
|
||||
}
|
||||
}
|
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using Discord.Commands;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
sealed class NadekoModuleAttribute : GroupAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
sealed class NadekoModuleAttribute : GroupAttribute
|
||||
{
|
||||
public NadekoModuleAttribute(string moduleName) : base(moduleName)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,12 @@
|
||||
using System;
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class NadekoOptionsAttribute : Attribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class NadekoOptionsAttribute : Attribute
|
||||
{
|
||||
public Type OptionType { get; set; }
|
||||
|
||||
public NadekoOptionsAttribute(Type t)
|
||||
{
|
||||
this.OptionType = t;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +1,18 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public sealed class OwnerOnlyAttribute : PreconditionAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public sealed class OwnerOnlyAttribute : PreconditionAttribute
|
||||
{
|
||||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo executingCommand, IServiceProvider services)
|
||||
{
|
||||
var creds = services.GetRequiredService<IBotCredsProvider>().GetCreds();
|
||||
|
||||
return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner")));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class RatelimitAttribute : PreconditionAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class RatelimitAttribute : PreconditionAttribute
|
||||
{
|
||||
public int Seconds { get; }
|
||||
|
||||
public RatelimitAttribute(int seconds)
|
||||
@@ -34,5 +33,4 @@ namespace NadekoBot.Common.Attributes
|
||||
|
||||
return Task.FromResult(PreconditionResult.FromError(msgContent));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
using Newtonsoft.Json;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class UsageAttribute : RemarksAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class UsageAttribute : RemarksAttribute
|
||||
{
|
||||
// public static string GetUsage(string memberName)
|
||||
// {
|
||||
// var usage = Localization.LoadCommand(memberName.ToLowerInvariant()).Usage;
|
||||
@@ -17,5 +13,4 @@ namespace NadekoBot.Common.Attributes
|
||||
public UsageAttribute(string text = "") : base(text)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public class UserPermAttribute : PreconditionAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public class UserPermAttribute : PreconditionAttribute
|
||||
{
|
||||
public RequireUserPermissionAttribute UserPermissionAttribute { get; }
|
||||
|
||||
public UserPermAttribute(GuildPerm permission)
|
||||
@@ -29,5 +28,4 @@ namespace Discord
|
||||
|
||||
return UserPermissionAttribute.CheckPermissionsAsync(context, command, services);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class CmdStrings
|
||||
{
|
||||
public class CmdStrings
|
||||
{
|
||||
public string[] Usages { get; }
|
||||
public string Description { get; }
|
||||
|
||||
@@ -16,5 +16,4 @@ namespace NadekoBot.Common
|
||||
Usages = usages;
|
||||
Description = description;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,26 +1,23 @@
|
||||
// License MIT
|
||||
// Source: https://github.com/i3arnon/ConcurrentHashSet
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace NadekoBot.Common.Collections
|
||||
namespace NadekoBot.Common.Collections;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a thread-safe hash-based unique collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items in the collection.</typeparam>
|
||||
/// <remarks>
|
||||
/// All public members of <see cref="ConcurrentHashSet{T}"/> are thread-safe and may be used
|
||||
/// concurrently from multiple threads.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a thread-safe hash-based unique collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items in the collection.</typeparam>
|
||||
/// <remarks>
|
||||
/// All public members of <see cref="ConcurrentHashSet{T}"/> are thread-safe and may be used
|
||||
/// concurrently from multiple threads.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T>
|
||||
{
|
||||
private const int DefaultCapacity = 31;
|
||||
private const int MaxLockNumber = 1024;
|
||||
|
||||
@@ -768,5 +765,4 @@ namespace NadekoBot.Common.Collections
|
||||
Next = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,25 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
|
||||
namespace NadekoBot.Common.Collections
|
||||
namespace NadekoBot.Common.Collections;
|
||||
|
||||
public static class DisposableReadOnlyListExtensions
|
||||
{
|
||||
public static class DisposableReadOnlyListExtensions
|
||||
{
|
||||
public static IDisposableReadOnlyList<T> AsDisposable<T>(this IReadOnlyList<T> arr) where T : IDisposable
|
||||
=> new DisposableReadOnlyList<T>(arr);
|
||||
|
||||
public static IDisposableReadOnlyList<KeyValuePair<TKey, TValue>> AsDisposable<TKey, TValue>(this IReadOnlyList<KeyValuePair<TKey, TValue>> arr) where TValue : IDisposable
|
||||
=> new DisposableReadOnlyList<TKey, TValue>(arr);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IDisposableReadOnlyList<T> : IReadOnlyList<T>, IDisposable
|
||||
{
|
||||
}
|
||||
public interface IDisposableReadOnlyList<T> : IReadOnlyList<T>, IDisposable
|
||||
{
|
||||
}
|
||||
|
||||
public sealed class DisposableReadOnlyList<T> : IDisposableReadOnlyList<T>
|
||||
public sealed class DisposableReadOnlyList<T> : IDisposableReadOnlyList<T>
|
||||
where T : IDisposable
|
||||
{
|
||||
{
|
||||
private readonly IReadOnlyList<T> _arr;
|
||||
|
||||
public int Count => _arr.Count;
|
||||
@@ -44,11 +42,11 @@ namespace NadekoBot.Common.Collections
|
||||
item.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DisposableReadOnlyList<T, U> : IDisposableReadOnlyList<KeyValuePair<T, U>>
|
||||
public sealed class DisposableReadOnlyList<T, U> : IDisposableReadOnlyList<KeyValuePair<T, U>>
|
||||
where U : IDisposable
|
||||
{
|
||||
{
|
||||
private readonly IReadOnlyList<KeyValuePair<T, U>> _arr;
|
||||
|
||||
public int Count => _arr.Count;
|
||||
@@ -73,5 +71,4 @@ namespace NadekoBot.Common.Collections
|
||||
item.Value.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Common.Collections
|
||||
namespace NadekoBot.Common.Collections;
|
||||
|
||||
public class IndexedCollection<T> : IList<T> where T : class, IIndexed
|
||||
{
|
||||
public class IndexedCollection<T> : IList<T> where T : class, IIndexed
|
||||
{
|
||||
public List<T> Source { get; }
|
||||
private readonly object _locker = new object();
|
||||
|
||||
@@ -137,5 +135,4 @@ namespace NadekoBot.Common.Collections
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class CommandData
|
||||
{
|
||||
public class CommandData
|
||||
{
|
||||
public string Cmd { get; set; }
|
||||
public string Desc { get; set; }
|
||||
public string[] Usage { get; set; }
|
||||
}
|
||||
}
|
@@ -1,16 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using Cloneable;
|
||||
using NadekoBot.Common.Yml;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common.Configs
|
||||
namespace NadekoBot.Common.Configs;
|
||||
|
||||
[Cloneable]
|
||||
public sealed partial class BotConfig : ICloneable<BotConfig>
|
||||
{
|
||||
[Cloneable]
|
||||
public sealed partial class BotConfig : ICloneable<BotConfig>
|
||||
{
|
||||
[Comment(@"DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 2;
|
||||
|
||||
@@ -140,11 +139,11 @@ See RotatingStatuses submodule in Administration.")]
|
||||
"can you do"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Cloneable]
|
||||
public sealed partial class BlockedConfig
|
||||
{
|
||||
[Cloneable]
|
||||
public sealed partial class BlockedConfig
|
||||
{
|
||||
public HashSet<string> Commands { get; set; }
|
||||
public HashSet<string> Modules { get; set; }
|
||||
|
||||
@@ -153,11 +152,11 @@ See RotatingStatuses submodule in Administration.")]
|
||||
Modules = new HashSet<string>();
|
||||
Commands = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Cloneable]
|
||||
public partial class ColorConfig
|
||||
{
|
||||
[Cloneable]
|
||||
public partial class ColorConfig
|
||||
{
|
||||
[Comment(@"Color used for embed responses when command successfully executes")]
|
||||
public Rgba32 Ok { get; set; }
|
||||
|
||||
@@ -173,12 +172,11 @@ See RotatingStatuses submodule in Administration.")]
|
||||
Error = Rgba32.ParseHex("ee281f");
|
||||
Pending = Rgba32.ParseHex("faa61a");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ConsoleOutputType
|
||||
{
|
||||
public enum ConsoleOutputType
|
||||
{
|
||||
Normal = 0,
|
||||
Simple = 1,
|
||||
None = 2,
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
namespace NadekoBot.Common.Configs
|
||||
namespace NadekoBot.Common.Configs;
|
||||
|
||||
/// <summary>
|
||||
/// Base interface for available config serializers
|
||||
/// </summary>
|
||||
public interface IConfigSeria
|
||||
{
|
||||
/// <summary>
|
||||
/// Base interface for available config serializers
|
||||
/// </summary>
|
||||
public interface IConfigSeria
|
||||
{
|
||||
/// <summary>
|
||||
/// Serialize the object to string
|
||||
/// </summary>
|
||||
@@ -14,5 +14,4 @@
|
||||
/// Deserialize string data into an object of the specified type
|
||||
/// </summary>
|
||||
public T Deserialize<T>(string data);
|
||||
}
|
||||
}
|
@@ -1,11 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using NadekoBot.Common.Yml;
|
||||
using YamlDotNet.Serialization;
|
||||
using NadekoBot.Common.Yml;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public sealed class Creds : IBotCredentials
|
||||
{
|
||||
public sealed class Creds : IBotCredentials
|
||||
{
|
||||
public Creds()
|
||||
{
|
||||
Version = 1;
|
||||
@@ -215,5 +213,4 @@ This should be equivalent to the DiscordsKey in your NadekoBot.Votes api appsett
|
||||
public string Args { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class DownloadTracker : INService
|
||||
{
|
||||
public class DownloadTracker : INService
|
||||
{
|
||||
private ConcurrentDictionary<ulong, DateTime> LastDownloads { get; } = new ConcurrentDictionary<ulong, DateTime>();
|
||||
private SemaphoreSlim downloadUsersSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
@@ -39,5 +38,4 @@ namespace NadekoBot.Common
|
||||
downloadUsersSemaphore.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,9 @@
|
||||
using Discord;
|
||||
using NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Extensions
|
||||
namespace NadekoBot.Extensions;
|
||||
|
||||
public static class BotCredentialsExtensions
|
||||
{
|
||||
public static class BotCredentialsExtensions
|
||||
{
|
||||
public static bool IsOwner(this IBotCredentials creds, IUser user)
|
||||
=> creds.OwnerIds.Contains(user.Id);
|
||||
}
|
||||
}
|
@@ -1,19 +1,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NadekoBot.Common;
|
||||
using NadekoBot.Modules.Music;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
using NadekoBot.Modules.Music.Resolvers;
|
||||
using NadekoBot.Modules.Music.Services;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace NadekoBot.Extensions
|
||||
namespace NadekoBot.Extensions;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddBotStringsServices(this IServiceCollection services, int totalShards)
|
||||
=> totalShards <= 1
|
||||
? services
|
||||
@@ -77,5 +74,4 @@ namespace NadekoBot.Extensions
|
||||
services.AddSingleton(ConnectionMultiplexer.Connect(conf));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
namespace Discord;
|
||||
// just a copy paste from discord.net in order to rename it, for compatibility iwth v3 which is gonna use custom lib
|
||||
|
||||
namespace Discord
|
||||
// Summary:
|
||||
// Defines the available permissions for a channel.
|
||||
[Flags]
|
||||
public enum GuildPerm : ulong
|
||||
{
|
||||
// just a copy paste from discord.net in order to rename it, for compatibility iwth v3 which is gonna use custom lib
|
||||
|
||||
|
||||
// Summary:
|
||||
// Defines the available permissions for a channel.
|
||||
[Flags]
|
||||
public enum GuildPerm : ulong
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Allows creation of instant invites.
|
||||
@@ -155,14 +151,14 @@ namespace Discord
|
||||
// This permission requires the owner account to use two-factor authentication when
|
||||
// used on a guild that has server-wide 2FA enabled.
|
||||
ManageEmojis = 1073741824
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Summary:
|
||||
// Defines the available permissions for a channel.
|
||||
[Flags]
|
||||
public enum ChannelPerm : ulong
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Defines the available permissions for a channel.
|
||||
[Flags]
|
||||
public enum ChannelPerm : ulong
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Allows creation of instant invites.
|
||||
@@ -251,5 +247,4 @@ namespace Discord
|
||||
// Summary:
|
||||
// Allows management and editing of webhooks.
|
||||
ManageWebhooks = 536870912
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
public static class Helpers
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
public static void ReadErrorAndExit(int exitCode)
|
||||
{
|
||||
if (!Console.IsInputRedirected)
|
||||
@@ -11,5 +9,4 @@ namespace NadekoBot.Common
|
||||
|
||||
Environment.Exit(exitCode);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Discord;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using NadekoBot.Common;
|
||||
using NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public interface IBotCredentials
|
||||
{
|
||||
public interface IBotCredentials
|
||||
{
|
||||
string Token { get; }
|
||||
string GoogleApiKey { get; }
|
||||
ICollection<ulong> OwnerIds { get; }
|
||||
@@ -26,11 +22,10 @@ namespace NadekoBot
|
||||
string TimezoneDbApiKey { get; }
|
||||
string CoinmarketcapApiKey { get; }
|
||||
string CoordinatorUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class RestartConfig
|
||||
{
|
||||
public class RestartConfig
|
||||
{
|
||||
public string Cmd { get; set; }
|
||||
public string Args { get; set; }
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public interface ICloneable<T> where T : new()
|
||||
{
|
||||
public interface ICloneable<T> where T : new()
|
||||
{
|
||||
public T Clone();
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public interface IEmbedBuilder
|
||||
{
|
||||
public interface IEmbedBuilder
|
||||
{
|
||||
IEmbedBuilder WithDescription(string desc);
|
||||
IEmbedBuilder WithTitle(string title);
|
||||
IEmbedBuilder AddField(string title, object value, bool isInline = false);
|
||||
@@ -14,12 +14,11 @@ namespace NadekoBot
|
||||
IEmbedBuilder WithUrl(string url);
|
||||
IEmbedBuilder WithImageUrl(string url);
|
||||
IEmbedBuilder WithThumbnailUrl(string url);
|
||||
}
|
||||
}
|
||||
|
||||
public enum EmbedColor
|
||||
{
|
||||
public enum EmbedColor
|
||||
{
|
||||
Ok,
|
||||
Pending,
|
||||
Error,
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public interface INadekoCommandOptions
|
||||
{
|
||||
public interface INadekoCommandOptions
|
||||
{
|
||||
void NormalizeOptions();
|
||||
}
|
||||
}
|
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
public interface IPlaceholderProvider
|
||||
{
|
||||
public interface IPlaceholderProvider
|
||||
{
|
||||
public IEnumerable<(string Name, Func<string> Func)> GetPlaceholders();
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using NadekoBot.Common.Yml;
|
||||
using NadekoBot.Common.Yml;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class ImageUrls
|
||||
{
|
||||
public class ImageUrls
|
||||
{
|
||||
[Comment("DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 3;
|
||||
|
||||
@@ -46,5 +45,4 @@ namespace NadekoBot.Common
|
||||
{
|
||||
public Uri Bg { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace NadekoBot.Common.JsonConverters
|
||||
namespace NadekoBot.Common.JsonConverters;
|
||||
|
||||
public class Rgba32Converter : JsonConverter<Rgba32>
|
||||
{
|
||||
public class Rgba32Converter : JsonConverter<Rgba32>
|
||||
{
|
||||
public override Rgba32 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return Rgba32.ParseHex(reader.GetString());
|
||||
@@ -17,10 +16,10 @@ namespace NadekoBot.Common.JsonConverters
|
||||
{
|
||||
writer.WriteStringValue(value.ToHex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CultureInfoConverter : JsonConverter<CultureInfo>
|
||||
{
|
||||
public class CultureInfoConverter : JsonConverter<CultureInfo>
|
||||
{
|
||||
public override CultureInfo Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return new CultureInfo(reader.GetString());
|
||||
@@ -30,5 +29,4 @@ namespace NadekoBot.Common.JsonConverters
|
||||
{
|
||||
writer.WriteStringValue(value.Name);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
// needs proper invalid input check (character array input out of range)
|
||||
// needs negative number support
|
||||
public readonly struct kwum : IEquatable<kwum>
|
||||
{
|
||||
// needs proper invalid input check (character array input out of range)
|
||||
// needs negative number support
|
||||
public readonly struct kwum : IEquatable<kwum>
|
||||
{
|
||||
private readonly int _value;
|
||||
private const string ValidCharacters = "23456789abcdefghijkmnpqrstuvwxyz";
|
||||
|
||||
@@ -94,5 +93,4 @@ namespace NadekoBot.Common
|
||||
{
|
||||
return _value.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
using CommandLine;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class LbOpts : INadekoCommandOptions
|
||||
{
|
||||
public class LbOpts : INadekoCommandOptions
|
||||
{
|
||||
[Option('c', "clean", Default = false, HelpText = "Only show users who are on the server.")]
|
||||
public bool Clean { get; set; }
|
||||
public void NormalizeOptions()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Net;
|
||||
using Serilog;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class LoginErrorHandler
|
||||
{
|
||||
public class LoginErrorHandler
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Handle(Exception ex)
|
||||
{
|
||||
@@ -53,5 +51,4 @@ namespace NadekoBot.Common
|
||||
|
||||
Log.Fatal(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
namespace NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by modules which block execution before anything is executed
|
||||
/// </summary>
|
||||
public interface IEarlyBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Implemented by modules which block execution before anything is executed
|
||||
/// </summary>
|
||||
public interface IEarlyBehavior
|
||||
{
|
||||
int Priority { get; }
|
||||
Task<bool> RunBehavior(IGuild guild, IUserMessage msg);
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
namespace NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
public interface IInputTransformer
|
||||
{
|
||||
public interface IInputTransformer
|
||||
{
|
||||
Task<string> TransformInput(IGuild guild, IMessageChannel channel, IUser user, string input);
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
namespace NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
public interface ILateBlocker
|
||||
{
|
||||
public interface ILateBlocker
|
||||
{
|
||||
public int Priority { get; }
|
||||
|
||||
Task<bool> TryBlockLate(ICommandContext context, string moduleName, CommandInfo command);
|
||||
}
|
||||
}
|
@@ -1,13 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
namespace NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
/// <summary>
|
||||
/// Last thing to be executed, won't stop further executions
|
||||
/// </summary>
|
||||
public interface ILateExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// Last thing to be executed, won't stop further executions
|
||||
/// </summary>
|
||||
public interface ILateExecutor
|
||||
{
|
||||
Task LateExecute(IGuild guild, IUserMessage msg);
|
||||
}
|
||||
}
|
@@ -2,10 +2,10 @@
|
||||
using Discord.WebSocket;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
namespace NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
public struct ModuleBehaviorResult
|
||||
{
|
||||
public struct ModuleBehaviorResult
|
||||
{
|
||||
public bool Blocked { get; set; }
|
||||
public string NewInput { get; set; }
|
||||
|
||||
@@ -20,15 +20,14 @@ namespace NadekoBot.Common.ModuleBehaviors
|
||||
Blocked = blocked,
|
||||
NewInput = null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public interface IModuleBehavior
|
||||
{
|
||||
public interface IModuleBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Negative priority means it will try to apply as early as possible
|
||||
/// Positive priority menas it will try to apply as late as possible
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
Task<ModuleBehaviorResult> ApplyBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg);
|
||||
}
|
||||
}
|
@@ -1,16 +1,15 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common.ModuleBehaviors
|
||||
namespace NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
/// <summary>
|
||||
/// All services which need to execute something after
|
||||
/// the bot is ready should implement this interface
|
||||
/// </summary>
|
||||
public interface IReadyExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// All services which need to execute something after
|
||||
/// the bot is ready should implement this interface
|
||||
/// </summary>
|
||||
public interface IReadyExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// Executed when bot is ready
|
||||
/// </summary>
|
||||
public Task OnReadyAsync();
|
||||
}
|
||||
}
|
@@ -6,10 +6,10 @@ using NadekoBot.Extensions;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules
|
||||
namespace NadekoBot.Modules;
|
||||
|
||||
public abstract class NadekoModule : ModuleBase
|
||||
{
|
||||
public abstract class NadekoModule : ModuleBase
|
||||
{
|
||||
protected CultureInfo _cultureInfo { get; set; }
|
||||
public IBotStrings Strings { get; set; }
|
||||
public CommandHandler CmdHandler { get; set; }
|
||||
@@ -132,26 +132,25 @@ namespace NadekoBot.Modules
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class NadekoModule<TService> : NadekoModule
|
||||
{
|
||||
public abstract class NadekoModule<TService> : NadekoModule
|
||||
{
|
||||
public TService _service { get; set; }
|
||||
|
||||
protected NadekoModule() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class NadekoSubmodule : NadekoModule
|
||||
{
|
||||
public abstract class NadekoSubmodule : NadekoModule
|
||||
{
|
||||
protected NadekoSubmodule() : base() { }
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class NadekoSubmodule<TService> : NadekoModule<TService>
|
||||
{
|
||||
public abstract class NadekoSubmodule<TService> : NadekoModule<TService>
|
||||
{
|
||||
protected NadekoSubmodule() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
namespace NadekoBot.Modules
|
||||
{
|
||||
public static class NadekoModuleExtensions
|
||||
{
|
||||
namespace NadekoBot.Modules;
|
||||
|
||||
public static class NadekoModuleExtensions
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class NadekoRandom : Random
|
||||
{
|
||||
public class NadekoRandom : Random
|
||||
{
|
||||
readonly RandomNumberGenerator _rng;
|
||||
|
||||
public NadekoRandom() : base()
|
||||
@@ -70,5 +69,4 @@ namespace NadekoBot.Common
|
||||
_rng.GetBytes(bytes);
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public sealed class NoPublicBotAttribute : PreconditionAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public sealed class NoPublicBotAttribute : PreconditionAttribute
|
||||
{
|
||||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||
{
|
||||
#if GLOBAL_NADEKO
|
||||
@@ -15,5 +14,4 @@ namespace NadekoBot.Common
|
||||
return Task.FromResult(PreconditionResult.FromSuccess());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
public class OldImageUrls
|
||||
{
|
||||
public class OldImageUrls
|
||||
{
|
||||
public int Version { get; set; } = 2;
|
||||
|
||||
public CoinData Coins { get; set; }
|
||||
@@ -45,5 +43,4 @@ namespace NadekoBot.Common
|
||||
{
|
||||
public Uri Bg { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using CommandLine;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public static class OptionsParser
|
||||
{
|
||||
public static class OptionsParser
|
||||
{
|
||||
public static T ParseFrom<T>(string[] args) where T : INadekoCommandOptions, new()
|
||||
=> ParseFrom(new T(), args).Item1;
|
||||
|
||||
@@ -20,5 +20,4 @@ namespace NadekoBot.Common
|
||||
return (options, res.Tag == ParserResultType.Parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class OsuMapData
|
||||
{
|
||||
public class OsuMapData
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Artist { get; set; }
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class OsuUserBests
|
||||
{
|
||||
public class OsuUserBests
|
||||
{
|
||||
[JsonProperty("beatmap_id")] public string BeatmapId { get; set; }
|
||||
|
||||
[JsonProperty("score_id")] public string ScoreId { get; set; }
|
||||
@@ -37,5 +37,4 @@ namespace NadekoBot.Common
|
||||
[JsonProperty("pp")] public double Pp { get; set; }
|
||||
|
||||
[JsonProperty("replay_available")] public string ReplayAvailable { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
public static class PlatformHelper
|
||||
{
|
||||
public static class PlatformHelper
|
||||
{
|
||||
private const int ProcessorCountRefreshIntervalMs = 30000;
|
||||
|
||||
private static volatile int _processorCount;
|
||||
@@ -21,5 +19,4 @@ namespace NadekoBot.Common
|
||||
return _processorCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
namespace NadekoBot.Common.Pokemon
|
||||
namespace NadekoBot.Common.Pokemon;
|
||||
|
||||
public class PokemonNameId
|
||||
{
|
||||
public class PokemonNameId
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Common.Pokemon
|
||||
namespace NadekoBot.Common.Pokemon;
|
||||
|
||||
public class SearchPokemon
|
||||
{
|
||||
public class SearchPokemon
|
||||
{
|
||||
public class GenderRatioClass
|
||||
{
|
||||
public float M { get; set; }
|
||||
@@ -36,5 +35,4 @@ namespace NadekoBot.Common.Pokemon
|
||||
public string Color { get; set; }
|
||||
public string[] Evos { get; set; }
|
||||
public string[] EggGroups { get; set; }
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
namespace NadekoBot.Common.Pokemon
|
||||
namespace NadekoBot.Common.Pokemon;
|
||||
|
||||
public class SearchPokemonAbility
|
||||
{
|
||||
public class SearchPokemonAbility
|
||||
{
|
||||
public string Desc { get; set; }
|
||||
public string ShortDesc { get; set; }
|
||||
public string Name { get; set; }
|
||||
public float Rating { get; set; }
|
||||
}
|
||||
}
|
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class EventPubSub : IPubSub
|
||||
{
|
||||
public class EventPubSub : IPubSub
|
||||
{
|
||||
private readonly Dictionary<string, Dictionary<Delegate, List<Func<object, ValueTask>>>> _actions
|
||||
= new Dictionary<string, Dictionary<Delegate, List<Func<object, ValueTask>>>>();
|
||||
private readonly object locker = new object();
|
||||
@@ -90,6 +87,4 @@ namespace NadekoBot.Common
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public interface IPubSub
|
||||
{
|
||||
public interface IPubSub
|
||||
{
|
||||
public Task Pub<TData>(in TypedKey<TData> key, TData data);
|
||||
public Task Sub<TData>(in TypedKey<TData> key, Func<TData, ValueTask> action);
|
||||
}
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public interface ISeria
|
||||
{
|
||||
public interface ISeria
|
||||
{
|
||||
byte[] Serialize<T>(T data);
|
||||
T Deserialize<T>(byte[] data);
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
using System.Text.Json;
|
||||
using NadekoBot.Common.JsonConverters;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class JsonSeria : ISeria
|
||||
{
|
||||
public class JsonSeria : ISeria
|
||||
{
|
||||
private JsonSerializerOptions serializerOptions = new JsonSerializerOptions()
|
||||
{
|
||||
Converters =
|
||||
@@ -24,5 +24,4 @@ namespace NadekoBot.Common
|
||||
|
||||
return JsonSerializer.Deserialize<T>(data, serializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Services;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Extensions;
|
||||
using Serilog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public sealed class RedisPubSub : IPubSub
|
||||
{
|
||||
public sealed class RedisPubSub : IPubSub
|
||||
{
|
||||
private readonly ConnectionMultiplexer _multi;
|
||||
private readonly ISeria _serializer;
|
||||
private readonly IBotCredentials _creds;
|
||||
@@ -42,5 +39,4 @@ namespace NadekoBot.Common
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public readonly struct TypedKey<TData>
|
||||
{
|
||||
public readonly struct TypedKey<TData>
|
||||
{
|
||||
public readonly string Key;
|
||||
|
||||
public TypedKey(in string key)
|
||||
@@ -25,5 +25,4 @@
|
||||
public override int GetHashCode() => Key?.GetHashCode() ?? 0;
|
||||
|
||||
public override string ToString() => Key;
|
||||
}
|
||||
}
|
@@ -3,10 +3,10 @@ using NadekoBot.Common.Yml;
|
||||
using NadekoBot.Common.Configs;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class YamlSeria : IConfigSeria
|
||||
{
|
||||
public class YamlSeria : IConfigSeria
|
||||
{
|
||||
private readonly ISerializer _serializer;
|
||||
private readonly IDeserializer _deserializer;
|
||||
|
||||
@@ -34,5 +34,4 @@ namespace NadekoBot.Common
|
||||
|
||||
public T Deserialize<T>(string data)
|
||||
=> _deserializer.Deserialize<T>(data);
|
||||
}
|
||||
}
|
@@ -3,18 +3,13 @@ using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
using NadekoBot.Modules.Music.Services;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Common.Replacements
|
||||
namespace NadekoBot.Common.Replacements;
|
||||
|
||||
public class ReplacementBuilder
|
||||
{
|
||||
public class ReplacementBuilder
|
||||
{
|
||||
private static readonly Regex rngRegex = new Regex("%rng(?:(?<from>(?:-)?\\d+)-(?<to>(?:-)?\\d+))?%", RegexOptions.Compiled);
|
||||
private ConcurrentDictionary<string, Func<string>> _reps = new ConcurrentDictionary<string, Func<string>>();
|
||||
private ConcurrentDictionary<Regex, Func<Match, string>> _regex = new ConcurrentDictionary<Regex, Func<Match, string>>();
|
||||
@@ -233,5 +228,4 @@ namespace NadekoBot.Common.Replacements
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NadekoBot.Common.Replacements
|
||||
namespace NadekoBot.Common.Replacements;
|
||||
|
||||
public class Replacer
|
||||
{
|
||||
public class Replacer
|
||||
{
|
||||
private readonly IEnumerable<(string Key, Func<string> Text)> _replacements;
|
||||
private readonly IEnumerable<(Regex Regex, Func<Match, string> Replacement)> _regex;
|
||||
|
||||
@@ -87,5 +85,4 @@ namespace NadekoBot.Common.Replacements
|
||||
|
||||
return newEmbedData;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +1,14 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class RequireObjectPropertiesContractResolver : DefaultContractResolver
|
||||
{
|
||||
public class RequireObjectPropertiesContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected override JsonObjectContract CreateObjectContract(Type objectType)
|
||||
{
|
||||
var contract = base.CreateObjectContract(objectType);
|
||||
contract.ItemRequired = Required.DisallowNull;
|
||||
return contract;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
public struct ShmartNumber : IEquatable<ShmartNumber>
|
||||
{
|
||||
public struct ShmartNumber : IEquatable<ShmartNumber>
|
||||
{
|
||||
public long Value { get; }
|
||||
public string Input { get; }
|
||||
|
||||
@@ -59,5 +57,4 @@ namespace NadekoBot.Common
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Discord;
|
||||
using Discord;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed record SmartEmbedText : SmartText
|
||||
{
|
||||
public sealed record SmartEmbedText : SmartText
|
||||
{
|
||||
public string PlainText { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
@@ -134,5 +131,4 @@ namespace NadekoBot
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed record SmartPlainText : SmartText
|
||||
{
|
||||
public sealed record SmartPlainText : SmartText
|
||||
{
|
||||
public string Text { get; init; }
|
||||
|
||||
public SmartPlainText(string text)
|
||||
@@ -19,5 +19,4 @@
|
||||
{
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public abstract record SmartText
|
||||
{
|
||||
public abstract record SmartText
|
||||
{
|
||||
public bool IsEmbed => this is SmartEmbedText;
|
||||
public bool IsPlainText => this is SmartPlainText;
|
||||
|
||||
@@ -49,5 +48,4 @@ namespace NadekoBot
|
||||
return new SmartPlainText(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public class SmartTextEmbedAuthor
|
||||
{
|
||||
public class SmartTextEmbedAuthor
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string IconUrl { get; set; }
|
||||
[JsonProperty("icon_url")]
|
||||
private string Icon_Url { set => IconUrl = value; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public class SmartTextEmbedField
|
||||
{
|
||||
public class SmartTextEmbedField
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool Inline { get; set; }
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot
|
||||
namespace NadekoBot;
|
||||
|
||||
public class SmartTextEmbedFooter
|
||||
{
|
||||
public class SmartTextEmbedFooter
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string IconUrl { get; set; }
|
||||
[JsonProperty("icon_url")]
|
||||
private string Icon_Url { set => IconUrl = value; }
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public sealed class ReactionEventWrapper : IDisposable
|
||||
{
|
||||
public sealed class ReactionEventWrapper : IDisposable
|
||||
{
|
||||
public IUserMessage Message { get; }
|
||||
public event Action<SocketReaction> OnReactionAdded = delegate { };
|
||||
public event Action<SocketReaction> OnReactionRemoved = delegate { };
|
||||
@@ -87,5 +86,4 @@ namespace NadekoBot.Common
|
||||
disposing = true;
|
||||
UnsubAll();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public enum AddRemove
|
||||
{
|
||||
public enum AddRemove
|
||||
{
|
||||
Add = int.MinValue,
|
||||
Rem = int.MinValue + 1,
|
||||
Rm = int.MinValue + 1,
|
||||
}
|
||||
}
|
@@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Modules.CustomReactions.Services;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class CommandTypeReader : NadekoTypeReader<CommandInfo>
|
||||
{
|
||||
public sealed class CommandTypeReader : NadekoTypeReader<CommandInfo>
|
||||
{
|
||||
private readonly CommandHandler _handler;
|
||||
private readonly CommandService _cmds;
|
||||
|
||||
@@ -33,10 +31,10 @@ namespace NadekoBot.Common.TypeReaders
|
||||
|
||||
return Task.FromResult(TypeReaderResult.FromSuccess(cmd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CommandOrCrTypeReader : NadekoTypeReader<CommandOrCrInfo>
|
||||
{
|
||||
public sealed class CommandOrCrTypeReader : NadekoTypeReader<CommandOrCrInfo>
|
||||
{
|
||||
private readonly CommandService _cmds;
|
||||
private readonly CustomReactionsService _crs;
|
||||
private readonly CommandHandler _commandHandler;
|
||||
@@ -67,10 +65,10 @@ namespace NadekoBot.Common.TypeReaders
|
||||
}
|
||||
return TypeReaderResult.FromError(CommandError.ParseFailed, "No such command or cr found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandOrCrInfo
|
||||
{
|
||||
public class CommandOrCrInfo
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Normal,
|
||||
@@ -86,5 +84,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
this.Name = input;
|
||||
this.CmdType = type;
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,10 +2,10 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
|
||||
{
|
||||
public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
|
||||
{
|
||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input)
|
||||
{
|
||||
if (!Emote.TryParse(input, out var emote))
|
||||
@@ -13,5 +13,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
|
||||
return Task.FromResult(TypeReaderResult.FromSuccess(emote));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class GuildDateTimeTypeReader : NadekoTypeReader<GuildDateTime>
|
||||
{
|
||||
public sealed class GuildDateTimeTypeReader : NadekoTypeReader<GuildDateTime>
|
||||
{
|
||||
private readonly GuildTimezoneService _gts;
|
||||
|
||||
public GuildDateTimeTypeReader(GuildTimezoneService gts)
|
||||
@@ -32,10 +31,10 @@ namespace NadekoBot.Common.TypeReaders
|
||||
|
||||
return new(tz, dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GuildDateTime
|
||||
{
|
||||
public class GuildDateTime
|
||||
{
|
||||
public TimeZoneInfo Timezone { get; }
|
||||
public DateTime CurrentGuildTime { get; }
|
||||
public DateTime InputTime { get; }
|
||||
@@ -49,5 +48,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
InputTime = inputTime;
|
||||
InputTimeUtc = TimeZoneInfo.ConvertTime(inputTime, Timezone, TimeZoneInfo.Utc);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,12 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class GuildTypeReader : NadekoTypeReader<IGuild>
|
||||
{
|
||||
public sealed class GuildTypeReader : NadekoTypeReader<IGuild>
|
||||
{
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public GuildTypeReader(DiscordSocketClient client)
|
||||
@@ -27,5 +26,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
|
||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No guild by that name or Id found"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class KwumTypeReader : NadekoTypeReader<kwum>
|
||||
{
|
||||
public sealed class KwumTypeReader : NadekoTypeReader<kwum>
|
||||
{
|
||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
|
||||
{
|
||||
if (kwum.TryParse(input, out var val))
|
||||
@@ -12,13 +12,12 @@ namespace NadekoBot.Common.TypeReaders
|
||||
|
||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Input is not a valid kwum"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SmartTextTypeReader : NadekoTypeReader<SmartText>
|
||||
{
|
||||
public sealed class SmartTextTypeReader : NadekoTypeReader<SmartText>
|
||||
{
|
||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input)
|
||||
{
|
||||
return Task.FromResult(TypeReaderResult.FromSuccess(SmartText.CreateFrom(input)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
namespace NadekoBot.Common.TypeReaders.Models
|
||||
namespace NadekoBot.Common.TypeReaders.Models;
|
||||
|
||||
public class PermissionAction
|
||||
{
|
||||
public class PermissionAction
|
||||
{
|
||||
public static PermissionAction Enable => new PermissionAction(true);
|
||||
public static PermissionAction Disable => new PermissionAction(false);
|
||||
|
||||
@@ -23,5 +23,4 @@
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Value.GetHashCode();
|
||||
}
|
||||
}
|
@@ -1,16 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders.Models
|
||||
namespace NadekoBot.Common.TypeReaders.Models;
|
||||
|
||||
public class StoopidTime
|
||||
{
|
||||
public class StoopidTime
|
||||
{
|
||||
public string Input { get; set; }
|
||||
public TimeSpan Time { get; set; }
|
||||
|
||||
private static readonly Regex _regex = new Regex(
|
||||
@"^(?:(?<months>\d)mo)?(?:(?<weeks>\d{1,2})w)?(?:(?<days>\d{1,2})d)?(?:(?<hours>\d{1,4})h)?(?:(?<minutes>\d{1,5})m)?(?:(?<seconds>\d{1,6})s)?$",
|
||||
@"^(?:(?<months>\d)mo)?(?:(?<weeks>\d{1,2})w)?(?:(?<days>\d{1,2})d)?(?:(?<hours>\d{1,4})h)?(?:(?<minutes>\d{1,5})m)?(?:(?<seconds>\d{1,6})s)?$",
|
||||
RegexOptions.Compiled | RegexOptions.Multiline);
|
||||
|
||||
private StoopidTime() { }
|
||||
@@ -61,5 +59,4 @@ namespace NadekoBot.Common.TypeReaders.Models
|
||||
Time = ts,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Extensions;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo>
|
||||
{
|
||||
public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo>
|
||||
{
|
||||
private readonly CommandService _cmds;
|
||||
|
||||
public ModuleTypeReader(CommandService cmds)
|
||||
@@ -23,10 +22,10 @@ namespace NadekoBot.Common.TypeReaders
|
||||
|
||||
return Task.FromResult(TypeReaderResult.FromSuccess(module));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ModuleOrCrTypeReader : NadekoTypeReader<ModuleOrCrInfo>
|
||||
{
|
||||
public sealed class ModuleOrCrTypeReader : NadekoTypeReader<ModuleOrCrInfo>
|
||||
{
|
||||
private readonly CommandService _cmds;
|
||||
|
||||
public ModuleOrCrTypeReader(CommandService cmds)
|
||||
@@ -46,10 +45,9 @@ namespace NadekoBot.Common.TypeReaders
|
||||
Name = input,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ModuleOrCrInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ModuleOrCrInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
@@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public abstract class NadekoTypeReader<T> : TypeReader
|
||||
{
|
||||
public abstract class NadekoTypeReader<T> : TypeReader
|
||||
{
|
||||
public abstract Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input);
|
||||
|
||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input, IServiceProvider services)
|
||||
=> ReadAsync(ctx, input);
|
||||
}
|
||||
}
|
@@ -2,13 +2,13 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Common.TypeReaders.Models;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
/// <summary>
|
||||
/// Used instead of bool for more flexible keywords for true/false only in the permission module
|
||||
/// </summary>
|
||||
public sealed class PermissionActionTypeReader : NadekoTypeReader<PermissionAction>
|
||||
{
|
||||
/// <summary>
|
||||
/// Used instead of bool for more flexible keywords for true/false only in the permission module
|
||||
/// </summary>
|
||||
public sealed class PermissionActionTypeReader : NadekoTypeReader<PermissionAction>
|
||||
{
|
||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
|
||||
{
|
||||
input = input.ToUpperInvariant();
|
||||
@@ -36,5 +36,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Did not receive a valid boolean value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using SixLabors.ImageSharp;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class Rgba32TypeReader : NadekoTypeReader<Color>
|
||||
{
|
||||
public sealed class Rgba32TypeReader : NadekoTypeReader<Color>
|
||||
{
|
||||
public override async Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
|
||||
{
|
||||
await Task.Yield();
|
||||
@@ -21,5 +20,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
return TypeReaderResult.FromError(CommandError.ParseFailed, "Parameter is not a valid color hex.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +1,14 @@
|
||||
using Discord.Commands;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Modules.Gambling.Services;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber>
|
||||
{
|
||||
public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber>
|
||||
{
|
||||
private readonly DbService _db;
|
||||
private readonly GamblingConfigService _gambling;
|
||||
|
||||
@@ -103,5 +102,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Common.TypeReaders.Models;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Common.TypeReaders
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class StoopidTimeTypeReader : NadekoTypeReader<StoopidTime>
|
||||
{
|
||||
public sealed class StoopidTimeTypeReader : NadekoTypeReader<StoopidTime>
|
||||
{
|
||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
@@ -21,5 +20,4 @@ namespace NadekoBot.Common.TypeReaders
|
||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.Exception, ex.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
public class CommentAttribute : Attribute
|
||||
{
|
||||
public class CommentAttribute : Attribute
|
||||
{
|
||||
public string Comment { get; }
|
||||
|
||||
public CommentAttribute(string comment)
|
||||
{
|
||||
Comment = comment;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.TypeInspectors;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class CommentGatheringTypeInspector : TypeInspectorSkeleton
|
||||
{
|
||||
public class CommentGatheringTypeInspector : TypeInspectorSkeleton
|
||||
{
|
||||
private readonly ITypeInspector innerTypeDescriptor;
|
||||
|
||||
public CommentGatheringTypeInspector(ITypeInspector innerTypeDescriptor)
|
||||
@@ -69,5 +66,4 @@ namespace NadekoBot.Common.Yml
|
||||
: baseDescriptor.Read(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public sealed class CommentsObjectDescriptor : IObjectDescriptor
|
||||
{
|
||||
public sealed class CommentsObjectDescriptor : IObjectDescriptor
|
||||
{
|
||||
private readonly IObjectDescriptor innerDescriptor;
|
||||
|
||||
public CommentsObjectDescriptor(IObjectDescriptor innerDescriptor, string comment)
|
||||
@@ -20,5 +19,4 @@ namespace NadekoBot.Common.Yml
|
||||
public Type Type { get { return innerDescriptor.Type; } }
|
||||
public Type StaticType { get { return innerDescriptor.StaticType; } }
|
||||
public ScalarStyle ScalarStyle { get { return innerDescriptor.ScalarStyle; } }
|
||||
}
|
||||
}
|
@@ -3,10 +3,10 @@ using YamlDotNet.Core.Events;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.ObjectGraphVisitors;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor
|
||||
{
|
||||
public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor
|
||||
{
|
||||
public CommentsObjectGraphVisitor(IObjectGraphVisitor<IEmitter> nextVisitor)
|
||||
: base(nextVisitor)
|
||||
{
|
||||
@@ -22,5 +22,4 @@ namespace NadekoBot.Common.Yml
|
||||
|
||||
return base.EnterMapping(key, value, context);
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,10 +2,10 @@
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.EventEmitters;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter
|
||||
{
|
||||
public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter
|
||||
{
|
||||
public MultilineScalarFlowStyleEmitter(IEventEmitter nextEmitter)
|
||||
: base(nextEmitter) { }
|
||||
|
||||
@@ -28,5 +28,4 @@ namespace NadekoBot.Common.Yml
|
||||
|
||||
nextEmitter.Emit(eventInfo, emitter);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Core.Events;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class Rgba32Converter : IYamlTypeConverter
|
||||
{
|
||||
public class Rgba32Converter : IYamlTypeConverter
|
||||
{
|
||||
public bool Accepts(Type type)
|
||||
{
|
||||
return type == typeof(Rgba32);
|
||||
@@ -27,10 +26,10 @@ namespace NadekoBot.Common.Yml
|
||||
var val = (uint) (color.B << 0 | color.G << 8 | color.R << 16);
|
||||
emitter.Emit(new Scalar(val.ToString("X6").ToLower()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CultureInfoConverter : IYamlTypeConverter
|
||||
{
|
||||
public class CultureInfoConverter : IYamlTypeConverter
|
||||
{
|
||||
public bool Accepts(Type type)
|
||||
{
|
||||
return type == typeof(CultureInfo);
|
||||
@@ -48,5 +47,4 @@ namespace NadekoBot.Common.Yml
|
||||
var ci = (CultureInfo)value;
|
||||
emitter.Emit(new Scalar(ci.Name));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Core.Events;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class UriConverter : IYamlTypeConverter
|
||||
{
|
||||
public class UriConverter : IYamlTypeConverter
|
||||
{
|
||||
public bool Accepts(Type type)
|
||||
{
|
||||
return type == typeof(Uri);
|
||||
@@ -24,5 +23,4 @@ namespace NadekoBot.Common.Yml
|
||||
var uri = (Uri)value;
|
||||
emitter.Emit(new Scalar(uri.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class Yaml
|
||||
{
|
||||
public class Yaml
|
||||
{
|
||||
public static ISerializer Serializer => new SerializerBuilder()
|
||||
.WithTypeInspector(inner => new CommentGatheringTypeInspector(inner))
|
||||
.WithEmissionPhaseObjectGraphVisitor(args => new CommentsObjectGraphVisitor(args.InnerVisitor))
|
||||
@@ -22,5 +22,4 @@ namespace NadekoBot.Common.Yml
|
||||
.WithTypeConverter(new UriConverter())
|
||||
.IgnoreUnmatchedProperties()
|
||||
.Build();
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
namespace NadekoBot.Common.Yml
|
||||
namespace NadekoBot.Common.Yml;
|
||||
|
||||
public class YamlHelper
|
||||
{
|
||||
public class YamlHelper
|
||||
{
|
||||
// https://github.com/aaubry/YamlDotNet/blob/0f4cc205e8b2dd8ef6589d96de32bf608a687c6f/YamlDotNet/Core/Scanner.cs#L1687
|
||||
/// <summary>
|
||||
/// This is modified code from yamldotnet's repo which handles parsing unicode code points
|
||||
@@ -54,5 +54,4 @@
|
||||
}
|
||||
return c - 'a' + 10;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,10 @@
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Db
|
||||
namespace NadekoBot.Db;
|
||||
|
||||
public static class ClubExtensions
|
||||
{
|
||||
public static class ClubExtensions
|
||||
{
|
||||
private static IQueryable<ClubInfo> Include(this DbSet<ClubInfo> clubs)
|
||||
=> clubs.Include(x => x.Owner)
|
||||
.Include(x => x.Applicants)
|
||||
@@ -44,5 +42,4 @@ namespace NadekoBot.Db
|
||||
.Take(9)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Db
|
||||
namespace NadekoBot.Db;
|
||||
|
||||
public static class CurrencyTransactionExtensions
|
||||
{
|
||||
public static class CurrencyTransactionExtensions
|
||||
{
|
||||
public static List<CurrencyTransaction> GetPageFor(this DbSet<CurrencyTransaction> set, ulong userId, int page)
|
||||
{
|
||||
return set.AsQueryable()
|
||||
@@ -17,5 +15,4 @@ namespace NadekoBot.Db
|
||||
.Take(15)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LinqToDB;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Db
|
||||
namespace NadekoBot.Db;
|
||||
|
||||
public static class CustomReactionsExtensions
|
||||
{
|
||||
public static class CustomReactionsExtensions
|
||||
{
|
||||
public static int ClearFromGuild(this DbSet<CustomReaction> crs, ulong guildId)
|
||||
{
|
||||
return crs.Delete(x => x.GuildId == guildId);
|
||||
@@ -26,5 +24,4 @@ namespace NadekoBot.Db
|
||||
{
|
||||
return crs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user