More cleanup, namespace fixes, convenience methods for IKernel

This commit is contained in:
Kwoth
2023-04-07 00:41:31 +02:00
parent 2c63b1cce7
commit 4bc3147697
131 changed files with 217 additions and 338 deletions

View File

@@ -1,6 +1,4 @@
#nullable disable #nullable disable
using NadekoBot.Common;
namespace NadekoBot; namespace NadekoBot;
public interface IBotCredentials public interface IBotCredentials

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using System.Globalization; using System.Globalization;
using NadekoBot.Services;
namespace NadekoBot.Common; namespace NadekoBot.Common;

View File

@@ -1,6 +1,4 @@
#nullable disable #nullable disable
using NadekoBot.Services;
namespace NadekoBot.Common.TypeReaders; namespace NadekoBot.Common.TypeReaders;
public sealed class CommandTypeReader : NadekoTypeReader<CommandInfo> public sealed class CommandTypeReader : NadekoTypeReader<CommandInfo>

View File

@@ -1,6 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
namespace NadekoBot.Common.TypeReaders; namespace NadekoBot.Common.TypeReaders;
public sealed class KwumTypeReader : NadekoTypeReader<kwum> public sealed class KwumTypeReader : NadekoTypeReader<kwum>

View File

@@ -1,5 +1,4 @@
using SixLabors.Fonts; using SixLabors.ImageSharp;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;

View File

@@ -1,6 +1,4 @@
using NadekoBot; using OneOf;
using NadekoBot.Services;
using OneOf;
using OneOf.Types; using OneOf.Types;
namespace Nadeko.Bot.Common; namespace Nadeko.Bot.Common;

View File

@@ -1,6 +1,4 @@
using NadekoBot.Services; namespace NadekoBot;
namespace NadekoBot;
public class NadekoInteractionService : INadekoInteractionService, INService public class NadekoInteractionService : INadekoInteractionService, INService
{ {

View File

@@ -0,0 +1,6 @@
namespace NadekoBot.Common.ModuleBehaviors;
public interface IBehavior
{
public virtual string Name => this.GetType().Name;
}

View File

@@ -3,7 +3,7 @@ namespace NadekoBot.Common.ModuleBehaviors;
/// <summary> /// <summary>
/// Executed if no command was found for this message /// Executed if no command was found for this message
/// </summary> /// </summary>
public interface IExecNoCommand public interface IExecNoCommand : IBehavior
{ {
/// <summary> /// <summary>
/// Executed at the end of the lifecycle if no command was found /// Executed at the end of the lifecycle if no command was found

View File

@@ -3,7 +3,7 @@ namespace NadekoBot.Common.ModuleBehaviors;
/// <summary> /// <summary>
/// Implemented by modules to handle non-bot messages received /// Implemented by modules to handle non-bot messages received
/// </summary> /// </summary>
public interface IExecOnMessage public interface IExecOnMessage : IBehavior
{ {
int Priority { get; } int Priority { get; }

View File

@@ -5,7 +5,7 @@ namespace NadekoBot.Common.ModuleBehaviors;
/// ***There is no support for this method in NadekoBot services.*** /// ***There is no support for this method in NadekoBot services.***
/// It is only meant to be used in medusa system /// It is only meant to be used in medusa system
/// </summary> /// </summary>
public interface IExecPostCommand public interface IExecPostCommand : IBehavior
{ {
/// <summary> /// <summary>
/// Executed after a command was successfully executed /// Executed after a command was successfully executed

View File

@@ -4,7 +4,7 @@ namespace NadekoBot.Common.ModuleBehaviors;
/// This interface's method is executed after a command was found but before it was executed. /// This interface's method is executed after a command was found but before it was executed.
/// Able to block further processing of a command /// Able to block further processing of a command
/// </summary> /// </summary>
public interface IExecPreCommand public interface IExecPreCommand : IBehavior
{ {
public int Priority { get; } public int Priority { get; }

View File

@@ -3,7 +3,7 @@ namespace NadekoBot.Common.ModuleBehaviors;
/// <summary> /// <summary>
/// Implemented by services which may transform input before a command is searched for /// Implemented by services which may transform input before a command is searched for
/// </summary> /// </summary>
public interface IInputTransformer public interface IInputTransformer : IBehavior
{ {
/// <summary> /// <summary>
/// Ran after a non-bot message was received /// Ran after a non-bot message was received

View File

@@ -4,7 +4,7 @@ namespace NadekoBot.Common.ModuleBehaviors;
/// All services which need to execute something after /// All services which need to execute something after
/// the bot is ready should implement this interface /// the bot is ready should implement this interface
/// </summary> /// </summary>
public interface IReadyExecutor public interface IReadyExecutor : IBehavior
{ {
/// <summary> /// <summary>
/// Executed when bot is ready /// Executed when bot is ready

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NonBlocking;
namespace NadekoBot.Common; namespace NadekoBot.Common;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Nadeko.Common;
namespace NadekoBot.Common; namespace NadekoBot.Common;

View File

@@ -1,6 +1,5 @@
using LinqToDB; using LinqToDB;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Services.Currency; namespace NadekoBot.Services.Currency;

View File

@@ -1,7 +1,4 @@
using NadekoBot.Modules.Administration; namespace NadekoBot.Services;
using NonBlocking;
namespace NadekoBot.Services;
public interface ICommandHandler public interface ICommandHandler
{ {

View File

@@ -1,12 +1,11 @@
#nullable disable #nullable disable
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using Ninject;
namespace NadekoBot.Services; namespace NadekoBot.Services;
// should be renamed to handler as it's not only executing // should be renamed to handler as it's not only executing
public sealed class BehaviorHandler : IBehaviorHandler, INService public sealed class BehaviorHandler : IBehaviorHandler
{ {
private readonly IServiceProvider _services; private readonly IServiceProvider _services;
@@ -152,10 +151,8 @@ public sealed class BehaviorHandler : IBehaviorHandler, INService
return false; return false;
} }
private string GetExecName(object exec) private string GetExecName(IBehavior exec)
=> exec is BehaviorAdapter ba => exec.Name;
? ba.ToString()
: exec.GetType().Name;
public async Task<bool> RunPreCommandAsync(ICommandContext ctx, CommandInfo cmd) public async Task<bool> RunPreCommandAsync(ICommandContext ctx, CommandInfo cmd)
{ {

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;

View File

@@ -2,7 +2,6 @@
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
using Nadeko.Common;
namespace NadekoBot.Services; namespace NadekoBot.Services;

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 NadekoBot.Common;
namespace NadekoBot.Services; namespace NadekoBot.Services;

View File

@@ -4,8 +4,6 @@ using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Nadeko.Medusa; using Nadeko.Medusa;
using NadekoBot.Common;
using Serilog;
namespace NadekoBot.Extensions; namespace NadekoBot.Extensions;

View File

@@ -1,7 +1,3 @@
using NadekoBot.Common;
using NadekoBot.Services;
using Serilog;
namespace NadekoBot.Extensions; namespace NadekoBot.Extensions;
public static class MessageChannelExtensions public static class MessageChannelExtensions

View File

@@ -1,8 +1,4 @@
using Nadeko.Common; namespace NadekoBot.Extensions;
using NadekoBot.Common;
using NadekoBot.Services;
namespace NadekoBot.Extensions;
public static class SocketMessageComponentExtensions public static class SocketMessageComponentExtensions
{ {

View File

@@ -1,5 +1,4 @@
using NadekoBot.Db.Models; using NadekoBot.Db.Models;
using NadekoBot.Services;
namespace NadekoBot.Extensions; namespace NadekoBot.Extensions;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db; namespace NadekoBot.Db;

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations namespace NadekoBot.Migrations
{ {

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations namespace NadekoBot.Migrations
{ {

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations namespace NadekoBot.Migrations
{ {

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations namespace NadekoBot.Migrations
{ {

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations namespace NadekoBot.Migrations
{ {

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,7 +1,6 @@
#nullable disable #nullable disable
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics; using System.Diagnostics;
using Nadeko.Common;
namespace NadekoBot.Services.Database.Models; namespace NadekoBot.Services.Database.Models;

View File

@@ -1,6 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
namespace NadekoBot.Services.Database.Models; namespace NadekoBot.Services.Database.Models;
public class Poll : DbEntity public class Poll : DbEntity

View File

@@ -1,6 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
namespace NadekoBot.Services.Database.Models; namespace NadekoBot.Services.Database.Models;
public enum ShopEntryType public enum ShopEntryType

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using NadekoBot.Db.Models; using NadekoBot.Db.Models;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;

View File

@@ -1,8 +1,7 @@
// Code temporarily yeeted from // Code temporarily yeeted from
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs // https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
// because of NRT issue // because of NRT issue
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
namespace Cloneable namespace Cloneable

View File

@@ -1,7 +1,7 @@
// Code temporarily yeeted from // Code temporarily yeeted from
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs // https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
// because of NRT issue // because of NRT issue
using System.Collections.Generic;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;

View File

@@ -1,10 +1,6 @@
#nullable enable #nullable enable
using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -43,7 +39,6 @@ namespace NadekoBot.Generators
public void Initialize(GeneratorInitializationContext context) public void Initialize(GeneratorInitializationContext context)
{ {
} }
public void Execute(GeneratorExecutionContext context) public void Execute(GeneratorExecutionContext context)
@@ -55,6 +50,7 @@ namespace NadekoBot.Generators
using (var stringWriter = new StringWriter()) using (var stringWriter = new StringWriter())
using (var sw = new IndentedTextWriter(stringWriter)) using (var sw = new IndentedTextWriter(stringWriter))
{ {
sw.WriteLine("#pragma warning disable CS8981");
sw.WriteLine("namespace NadekoBot;"); sw.WriteLine("namespace NadekoBot;");
sw.WriteLine(); sw.WriteLine();

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Administration.Services;
namespace NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Administration;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;

View File

@@ -1,8 +1,5 @@
#nullable disable #nullable disable
using Nadeko.Common;
using Nadeko.Bot.Db;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Administration.Services;
namespace NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Administration;

View File

@@ -1,8 +1,5 @@
#nullable disable #nullable disable
using NadekoBot.Modules.Administration.Services;
using NadekoBot.Services.Database.Models;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using System.Net;
using Color = SixLabors.ImageSharp.Color; using Color = SixLabors.ImageSharp.Color;
namespace NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Administration;

View File

@@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Collections.Immutable; using System.Collections.Immutable;
using Nadeko.Common;
namespace NadekoBot.Modules.Administration.Services; namespace NadekoBot.Modules.Administration.Services;

View File

@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Nadeko.Common;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Administration.Services;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Modules.NadekoExpressions; namespace NadekoBot.Modules.NadekoExpressions;

View File

@@ -1,7 +1,6 @@
#nullable disable #nullable disable
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using NadekoBot.Extensions;
namespace NadekoBot.Modules.NadekoExpressions; namespace NadekoBot.Modules.NadekoExpressions;

View File

@@ -7,7 +7,6 @@ using NadekoBot.Services.Database.Models;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using Nadeko.Bot.Common; using Nadeko.Bot.Common;
using Nadeko.Common;
using NadekoBot.Services; using NadekoBot.Services;
using Serilog; using Serilog;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions; using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
using NadekoBot.Modules.Games.Common; using NadekoBot.Modules.Games.Common;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.AnimalRacing; using NadekoBot.Modules.Gambling.Common.AnimalRacing;

View File

@@ -1,6 +1,5 @@
using LinqToDB; using LinqToDB;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using NadekoBot.Db.Models;
namespace NadekoBot.Modules.Gambling.Bank; namespace NadekoBot.Modules.Gambling.Bank;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.Blackjack; using NadekoBot.Modules.Gambling.Common.Blackjack;

View File

@@ -1,7 +1,6 @@
#nullable disable #nullable disable
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using Nadeko.Common;
namespace NadekoBot.Modules.Gambling.Common.Events; namespace NadekoBot.Modules.Gambling.Common.Events;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;

View File

@@ -1,8 +1,6 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Common.Configs; using NadekoBot.Common.Configs;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Services;
namespace NadekoBot.Modules.Gambling.Services; namespace NadekoBot.Modules.Gambling.Services;

View File

@@ -14,8 +14,6 @@ public class GamblingService : INService, IReadyExecutor
public ConcurrentDictionary<(ulong, ulong), RollDuelGame> Duels { get; } = new(); public ConcurrentDictionary<(ulong, ulong), RollDuelGame> Duels { get; } = new();
public ConcurrentDictionary<ulong, Connect4Game> Connect4Games { get; } = new(); public ConcurrentDictionary<ulong, Connect4Game> Connect4Games { get; } = new();
private readonly DbService _db; private readonly DbService _db;
private readonly ICurrencyService _cs;
private readonly IBot _bot;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
private readonly IBotCache _cache; private readonly IBotCache _cache;
private readonly GamblingConfigService _gss; private readonly GamblingConfigService _gss;
@@ -24,13 +22,11 @@ public class GamblingService : INService, IReadyExecutor
public GamblingService( public GamblingService(
DbService db, DbService db,
ICurrencyService cs,
DiscordSocketClient client, DiscordSocketClient client,
IBotCache cache, IBotCache cache,
GamblingConfigService gss) GamblingConfigService gss)
{ {
_db = db; _db = db;
_cs = cs;
_client = client; _client = client;
_cache = cache; _cache = cache;
_gss = gss; _gss = gss;
@@ -57,7 +53,7 @@ public class GamblingService : INService, IReadyExecutor
var days = TimeSpan.FromDays(lifetime); var days = TimeSpan.FromDays(lifetime);
await using var uow = _db.GetDbContext(); await using var uow = _db.GetDbContext();
await uow.CurrencyTransactions await uow.CurrencyTransactions
.DeleteAsync(ct => ct.DateAdded == null || now - ct.DateAdded < days); .DeleteAsync(ct => ct.DateAdded == null || now - ct.DateAdded < days);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -67,7 +63,7 @@ public class GamblingService : INService, IReadyExecutor
} }
} }
} }
private async Task CurrencyDecayLoopAsync() private async Task CurrencyDecayLoopAsync()
{ {
if (_client.ShardId != 0) if (_client.ShardId != 0)
@@ -84,7 +80,7 @@ public class GamblingService : INService, IReadyExecutor
continue; continue;
var now = DateTime.UtcNow; var now = DateTime.UtcNow;
await using var uow = _db.GetDbContext(); await using var uow = _db.GetDbContext();
var result = await _cache.GetAsync(_curDecayKey); var result = await _cache.GetAsync(_curDecayKey);
@@ -109,14 +105,14 @@ public class GamblingService : INService, IReadyExecutor
var decay = (double)config.Decay.Percent; var decay = (double)config.Decay.Percent;
await uow.DiscordUser await uow.DiscordUser
.Where(x => x.CurrencyAmount > config.Decay.MinThreshold && x.UserId != _client.CurrentUser.Id) .Where(x => x.CurrencyAmount > config.Decay.MinThreshold && x.UserId != _client.CurrentUser.Id)
.UpdateAsync(old => new() .UpdateAsync(old => new()
{ {
CurrencyAmount = CurrencyAmount =
maxDecay > Sql.Round((old.CurrencyAmount * decay) - 0.5) maxDecay > Sql.Round((old.CurrencyAmount * decay) - 0.5)
? (long)(old.CurrencyAmount - Sql.Round((old.CurrencyAmount * decay) - 0.5)) ? (long)(old.CurrencyAmount - Sql.Round((old.CurrencyAmount * decay) - 0.5))
: old.CurrencyAmount - maxDecay : old.CurrencyAmount - maxDecay
}); });
await uow.SaveChangesAsync(); await uow.SaveChangesAsync();
@@ -145,7 +141,7 @@ public class GamblingService : INService, IReadyExecutor
var waifus = uow.WaifuInfo.GetTotalValue(); var waifus = uow.WaifuInfo.GetTotalValue();
var bot = await uow.DiscordUser.GetUserCurrencyAsync(_client.CurrentUser.Id); var bot = await uow.DiscordUser.GetUserCurrencyAsync(_client.CurrentUser.Id);
decimal bank = await uow.GetTable<BankUser>() decimal bank = await uow.GetTable<BankUser>()
.SumAsyncLinqToDB(x => x.Balance); .SumAsyncLinqToDB(x => x.Balance);
var result = new EconomyResult var result = new EconomyResult
{ {
@@ -165,10 +161,11 @@ public class GamblingService : INService, IReadyExecutor
} }
private static readonly SemaphoreSlim _timelyLock = new (1, 1); private static readonly SemaphoreSlim _timelyLock = new(1, 1);
private static TypedKey<Dictionary<ulong, long>> _timelyKey private static TypedKey<Dictionary<ulong, long>> _timelyKey
= new("timely:claims"); = new("timely:claims");
public async Task<TimeSpan?> ClaimTimelyAsync(ulong userId, int period) public async Task<TimeSpan?> ClaimTimelyAsync(ulong userId, int period)
{ {
if (period == 0) if (period == 0)
@@ -196,7 +193,7 @@ public class GamblingService : INService, IReadyExecutor
// update the cache // update the cache
dict[userId] = nowB; dict[userId] = nowB;
await _cache.AddAsync(_timelyKey, dict); await _cache.AddAsync(_timelyKey, dict);
return null; return null;
} }
else else

View File

@@ -1,10 +1,7 @@
#nullable disable #nullable disable
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;
using System.Globalization;
using System.Numerics; using System.Numerics;
using Discord;
using Nadeko.Bot.Common; using Nadeko.Bot.Common;
using NadekoBot.Common;
namespace NadekoBot.Modules.Gambling.Common; namespace NadekoBot.Modules.Gambling.Common;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Services.Database; using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;

View File

@@ -7,7 +7,6 @@ using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using System.Text;
using Nadeko.Econ.Gambling; using Nadeko.Econ.Gambling;
using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders;
using Color = SixLabors.ImageSharp.Color; using Color = SixLabors.ImageSharp.Color;

View File

@@ -2,9 +2,6 @@
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Discord.WebSocket;
using NadekoBot.Services;
using Serilog;
namespace NadekoBot.Modules.Gambling.Services; namespace NadekoBot.Modules.Gambling.Services;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.Waifu; using NadekoBot.Modules.Gambling.Common.Waifu;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;

View File

@@ -1,11 +1,9 @@
#nullable disable #nullable disable
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Nadeko.Common;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Modules.Games.Common; using NadekoBot.Modules.Games.Common;
using NadekoBot.Modules.Games.Common.Acrophobia; using NadekoBot.Modules.Games.Common.Acrophobia;
using NadekoBot.Modules.Games.Common.Nunchi; using NadekoBot.Modules.Games.Common.Nunchi;
using NadekoBot.Modules.Games.Common.Trivia;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NadekoBot.Modules.Games.Services; namespace NadekoBot.Modules.Games.Services;

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using Nadeko.Common;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using Image = SixLabors.ImageSharp.Image; using Image = SixLabors.ImageSharp.Image;

View File

@@ -1,4 +1,3 @@
using Nadeko.Common;
using NadekoBot.Modules.Games.Hangman; using NadekoBot.Modules.Games.Hangman;
namespace NadekoBot.Modules.Games; namespace NadekoBot.Modules.Games;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using CommandLine; using CommandLine;
using NadekoBot.Common;
namespace NadekoBot.Modules.Help.Common; namespace NadekoBot.Modules.Help.Common;

View File

@@ -1,7 +1,6 @@
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Nadeko.Common;
namespace NadekoBot.Modules.Music.Services; namespace NadekoBot.Modules.Music.Services;

View File

@@ -4,7 +4,6 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Nadeko.Common;
namespace NadekoBot.Modules.Music; namespace NadekoBot.Modules.Music;

View File

@@ -1,7 +1,6 @@
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
using Nadeko.Common;
namespace NadekoBot.Modules.Music.Resolvers; namespace NadekoBot.Modules.Music.Resolvers;

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