Base for 4.3 work. Split Nadeko.Common into a separate project

This commit is contained in:
Kwoth
2022-07-11 00:06:19 +02:00
parent 1396d9d55a
commit f41b1fb93c
113 changed files with 271 additions and 255 deletions

View File

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

View File

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

View File

@@ -5,6 +5,7 @@ using NadekoBot.Db;
using NadekoBot.Services.Database.Models;
using System.Net;
using System.Threading.Channels;
using Nadeko.Common;
namespace NadekoBot.Modules.Administration.Services;

View File

@@ -4,6 +4,7 @@ using Microsoft.Extensions.Caching.Memory;
using NadekoBot.Common.ModuleBehaviors;
using System.Net;
using System.Threading.Channels;
using Nadeko.Common;
namespace NadekoBot.Modules.Administration.Services;

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,6 @@
#nullable disable
using Nadeko.Common;
namespace NadekoBot.Modules.Administration.Services;
public class PruneService : INService

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,7 @@
#nullable disable
using Nadeko.Common;
namespace NadekoBot.Modules.NadekoExpressions;
[Name("Expressions")]

View File

@@ -7,6 +7,7 @@ using NadekoBot.Modules.Permissions.Common;
using NadekoBot.Modules.Permissions.Services;
using NadekoBot.Services.Database.Models;
using System.Runtime.CompilerServices;
using Nadeko.Common;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Bank;
using Nadeko.Common;
using NadekoBot.Modules.Gambling.Bank;
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services;

View File

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

View File

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

View File

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

View File

@@ -13,6 +13,7 @@ using NadekoBot.Services.Database.Models;
using System.Collections.Immutable;
using System.Globalization;
using System.Text;
using Nadeko.Common;
namespace NadekoBot.Modules.Gambling;

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,6 +8,7 @@ using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System.Text;
using Nadeko.Common;
using Color = SixLabors.ImageSharp.Color;
using Image = SixLabors.ImageSharp.Image;

View File

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

View File

@@ -1,4 +1,6 @@
#nullable disable
using Nadeko.Common;
namespace NadekoBot.Modules.Gambling.Common;
public class Deck

View File

@@ -1,5 +1,6 @@
#nullable disable
using Microsoft.Extensions.Caching.Memory;
using Nadeko.Common;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Modules.Games.Common;
using NadekoBot.Modules.Games.Common.Acrophobia;

View File

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

View File

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

View File

@@ -1,5 +1,4 @@
#nullable disable
using NadekoBot.Common.Collections;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db;
using NadekoBot.Modules.Games.Common;

View File

@@ -0,0 +1,33 @@
namespace NadekoBot.Modules.Games.Common.Trivia;
public sealed class DefaultQuestionPool : IQuestionPool
{
private readonly ILocalDataCache _cache;
private readonly NadekoRandom _rng;
public DefaultQuestionPool(ILocalDataCache cache)
{
_cache = cache;
_rng = new NadekoRandom();
}
public async Task<TriviaQuestion?> GetRandomQuestionAsync(ISet<TriviaQuestion> exclude)
{
TriviaQuestion randomQuestion;
var pool = await _cache.GetTriviaQuestionsAsync();
if(pool is null)
return default;
while (exclude.Contains(randomQuestion = new(pool[_rng.Next(0, pool.Length)])))
{
// if too many questions are excluded, clear the exclusion list and start over
if (exclude.Count > pool.Length / 10 * 9)
{
exclude.Clear();
break;
}
}
return randomQuestion;
}
}

View File

@@ -0,0 +1,6 @@
namespace NadekoBot.Modules.Games.Common.Trivia;
public interface IQuestionPool
{
Task<TriviaQuestion?> GetRandomQuestionAsync(ISet<TriviaQuestion> exclude);
}

View File

@@ -0,0 +1,32 @@
namespace NadekoBot.Modules.Games.Common.Trivia;
public sealed class PokemonQuestionPool : IQuestionPool
{
public int QuestionsCount => 721; // xd
private readonly NadekoRandom _rng;
private readonly ILocalDataCache _cache;
public PokemonQuestionPool(ILocalDataCache cache)
{
_cache = cache;
_rng = new NadekoRandom();
}
public async Task<TriviaQuestion?> GetRandomQuestionAsync(ISet<TriviaQuestion> exclude)
{
var pokes = await _cache.GetPokemonMapAsync();
if (pokes is null or { Count: 0 })
return default;
var num = _rng.Next(1, QuestionsCount + 1);
return new(new()
{
Question = "Who's That Pokémon?",
Answer = pokes[num].ToTitleCase(),
Category = "Pokemon",
ImageUrl = $@"https://nadeko.bot/images/pokemon/shadows/{num}.png",
AnswerImageUrl = $@"https://nadeko.bot/images/pokemon/real/{num}.png"
});
}
}

View File

@@ -234,9 +234,9 @@ public class TriviaGame
if (!guess)
return;
triviaCancelSource.Cancel();
if (_options.WinRequirement != 0 && Users[guildUser] == _options.WinRequirement)
{
ShouldStopGame = true;

View File

@@ -7,6 +7,7 @@ using NadekoBot.Modules.Permissions.Services;
using Newtonsoft.Json;
using System.Text;
using System.Text.Json;
using Nadeko.Common;
using JsonSerializer = System.Text.Json.JsonSerializer;
namespace NadekoBot.Modules.Help;

View File

@@ -1,5 +1,6 @@
#nullable disable
using CommandLine;
using Nadeko.Common;
using Nadeko.Medusa;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Modules.Administration.Services;

View File

@@ -1,4 +1,5 @@
using Nadeko.Medusa;
using Nadeko.Common;
using Nadeko.Medusa;
namespace NadekoBot.Modules;

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using Nadeko.Common;
namespace NadekoBot.Modules.Music.Resolvers;

View File

@@ -1,4 +1,5 @@
#nullable disable
using Nadeko.Common;
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json.Linq;

View File

@@ -1,5 +1,6 @@
#nullable disable
using Microsoft.Extensions.Caching.Memory;
using Nadeko.Common;
namespace NadekoBot.Modules.Nsfw.Common;

View File

@@ -1,5 +1,6 @@
#nullable disable warnings
using LinqToDB;
using Nadeko.Common;
using NadekoBot.Modules.Nsfw.Common;
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json.Linq;

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Nsfw;
#nullable disable warnings
namespace NadekoBot.Modules.Nsfw;
public record UrlReply
{

View File

@@ -1,5 +1,6 @@
#nullable disable
using System.Net.Http.Json;
using Nadeko.Common;
namespace NadekoBot.Modules.Nsfw.Common;

View File

@@ -1,5 +1,6 @@
#nullable disable
using System.Net.Http.Json;
using Nadeko.Common;
namespace NadekoBot.Modules.Nsfw.Common;

View File

@@ -1,5 +1,6 @@
#nullable disable
using System.Net.Http.Json;
using Nadeko.Common;
namespace NadekoBot.Modules.Nsfw.Common;

View File

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

View File

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

View File

@@ -1,7 +1,4 @@
#nullable disable
using NadekoBot.Common.Collections;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Modules.Permissions.Common;
public class PermissionsCollection<T> : IndexedCollection<T>

View File

@@ -1,6 +1,7 @@
#nullable disable
using AngleSharp;
using AngleSharp.Html.Dom;
using Nadeko.Common;
using NadekoBot.Modules.Searches.Services;
namespace NadekoBot.Modules.Searches;

View File

@@ -4,6 +4,7 @@ using Google.Protobuf.WellKnownTypes;
using System.Globalization;
using System.Net.Http.Json;
using System.Text.Json;
using Nadeko.Common;
namespace NadekoBot.Modules.Searches;

View File

@@ -4,6 +4,7 @@ using CodeHollow.FeedReader.Feeds;
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Db;
using NadekoBot.Services.Database.Models;

View File

@@ -1,4 +1,5 @@
#nullable disable
using Nadeko.Common;
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json;

View File

@@ -2,6 +2,7 @@
using StackExchange.Redis;
using System.Net.Http.Json;
using System.Text.Json.Serialization;
using Nadeko.Common;
namespace NadekoBot.Modules.Searches;

View File

@@ -11,6 +11,7 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using Nadeko.Common;
using Color = SixLabors.ImageSharp.Color;
namespace NadekoBot.Modules.Searches;

View File

@@ -1,5 +1,6 @@
#nullable disable
using Html2Markdown;
using Nadeko.Common;
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

View File

@@ -2,6 +2,7 @@
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db;
using NadekoBot.Db.Models;

View File

@@ -1,4 +1,5 @@
using NadekoBot.Db.Models;
using Nadeko.Common;
using NadekoBot.Db.Models;
using NadekoBot.Modules.Searches.Common.StreamNotifications.Providers;
namespace NadekoBot.Modules.Searches.Common.StreamNotifications;

View File

@@ -1,5 +1,6 @@
using NadekoBot.Db.Models;
using System.Text.RegularExpressions;
using Nadeko.Common;
using TwitchLib.Api;
using JsonSerializer = System.Text.Json.JsonSerializer;

View File

@@ -1,6 +1,7 @@
#nullable disable
using NadekoBot.Modules.Utility.Patronage;
using System.Text;
using Nadeko.Common;
namespace NadekoBot.Modules.Utility;

View File

@@ -1,4 +1,5 @@
#nullable disable warnings
using Nadeko.Common;
using NadekoBot.Common.Yml;
using NadekoBot.Db;
using NadekoBot.Services.Database.Models;

View File

@@ -4,6 +4,7 @@ using LinqToDB.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Services.Database.Models;
using System.Text.RegularExpressions;
using Nadeko.Common;
namespace NadekoBot.Modules.Utility.Services;

View File

@@ -1,6 +1,7 @@
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Services.Database.Models;

View File

@@ -6,6 +6,7 @@ using NadekoBot.Modules.Utility.Common.Exceptions;
using NadekoBot.Services.Database.Models;
using System.Diagnostics;
using System.Net;
using Nadeko.Common;
namespace NadekoBot.Modules.Utility.Services;

View File

@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Nadeko.Common;
using SystemTextJsonSamples;
namespace NadekoBot.Modules.Utility;

View File

@@ -2,6 +2,7 @@
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Nadeko.Common;
using NadekoBot.Db;
using NadekoBot.Db.Models;

View File

@@ -3,6 +3,7 @@ using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Xp.Services;
using NadekoBot.Services.Database.Models;
using System.Diagnostics;
using Nadeko.Common;
namespace NadekoBot.Modules.Xp;

View File

@@ -14,6 +14,7 @@ using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System.Threading.Channels;
using Nadeko.Common;
using Color = SixLabors.ImageSharp.Color;
using Image = SixLabors.ImageSharp.Image;