From 6d2c9970a7ee0165aecdd465b2c7f1be757067cb Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 1 Sep 2016 03:12:08 +0200 Subject: [PATCH] Fix to v+t, finished typing articles? --- .../20160901010812_second.Designer.cs | 432 ++++++++++++++++++ .../Migrations/20160901010812_second.cs | 32 ++ .../NadekoSqliteContextModelSnapshot.cs | 14 + .../Administration/Commands/LogCommand.cs | 4 +- .../Commands/VoicePlusTextCommands.cs | 1 + .../Modules/Gambling/Commands/AnimalRacing.cs | 2 +- .../Gambling/Commands/DiceRollCommand.cs | 6 +- .../Modules/Gambling/Commands/DrawCommand.cs | 4 +- .../Games/Commands/PlantAndPickCommands.cs | 2 +- .../Games/Commands/SpeedTypingCommands.cs | 334 +++++++------- .../Commands/Trivia/TriviaQuestionPool.cs | 2 +- .../Modules/Music/Classes/MusicControls.cs | 12 +- src/NadekoBot/Modules/Music/Classes/Song.cs | 14 +- .../Modules/Music/Classes/SoundCloud.cs | 2 +- src/NadekoBot/Modules/NSFW/NSFW.cs | 2 +- .../Searches/Commands/ConverterCommands.cs | 2 +- .../Modules/Searches/Commands/LoLCommands.cs | 2 +- src/NadekoBot/Modules/Trello/Trello.cs | 2 +- .../Resources/CommandStrings.Designer.cs | 2 +- .../Resources/ResponseStrings.Designer.cs | 2 +- .../Services/Database/Models/ClashWar.cs | 2 +- .../Services/Database/Models/TypingArticle.cs | 14 + .../Services/Database/NadekoContext.cs | 1 + .../Repositories/ITypingArticlesRepository.cs | 14 + .../Impl/TypingArticlesRepository.cs | 25 + src/NadekoBot/Services/Database/UnitOfWork.cs | 3 + .../_Classes/ServerSpecificConfig.cs | 4 +- .../_Models/DataModels/AnnouncementModel.cs | 20 - .../_Models/DataModels/CommandModel.cs | 11 - .../_Models/DataModels/CurrencyStateModel.cs | 7 - .../DataModels/CurrencyTransactionModel.cs | 7 - src/NadekoBot/_Models/DataModels/Donator.cs | 7 - .../_Models/DataModels/IDataModel.cs | 14 - src/NadekoBot/_Models/DataModels/Incident.cs | 10 - .../_Models/DataModels/MusicPlaylist.cs | 9 - .../_Models/DataModels/PlaylistSongInfo.cs | 8 - src/NadekoBot/_Models/DataModels/PokeTypes.cs | 14 - .../_Models/DataModels/RequestModel.cs | 10 - src/NadekoBot/_Models/DataModels/SongInfo.cs | 14 - .../_Models/DataModels/StatsModel.cs | 10 - .../_Models/DataModels/TestDataModel.cs | 8 - .../_Models/DataModels/TypingArticleModel.cs | 5 - .../_Models/DataModels/UserQuoteModel.cs | 7 - .../_Models/JSONModels/AnimeResult.cs | 20 - .../_Models/JSONModels/Configuration.cs | 246 ---------- .../_Models/JSONModels/LocalizedStrings.cs | 50 -- src/NadekoBot/_Models/JSONModels/MagicItem.cs | 16 - .../_Models/JSONModels/PokemonType.cs | 33 -- .../_Models/JSONModels/_JSONModels.cs | 155 ------- .../CustomReactions/CustomReactions.cs | 2 +- src/NadekoBot/_Modules/DiscordCommand.cs | 2 +- .../Permissions/Classes/PermissionChecker.cs | 2 +- .../Permissions/Classes/PermissionHelper.cs | 12 +- .../Permissions/Classes/PermissionsHandler.cs | 20 +- .../Commands/FilterInvitesCommand.cs | 4 +- .../Commands/FilterWordsCommand.cs | 4 +- .../_Modules/Permissions/PermissionsModule.cs | 2 +- 57 files changed, 757 insertions(+), 908 deletions(-) create mode 100644 src/NadekoBot/Migrations/20160901010812_second.Designer.cs create mode 100644 src/NadekoBot/Migrations/20160901010812_second.cs create mode 100644 src/NadekoBot/Services/Database/Models/TypingArticle.cs create mode 100644 src/NadekoBot/Services/Database/Repositories/ITypingArticlesRepository.cs create mode 100644 src/NadekoBot/Services/Database/Repositories/Impl/TypingArticlesRepository.cs delete mode 100644 src/NadekoBot/_Models/DataModels/AnnouncementModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/CommandModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/CurrencyStateModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/CurrencyTransactionModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/Donator.cs delete mode 100644 src/NadekoBot/_Models/DataModels/IDataModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/Incident.cs delete mode 100644 src/NadekoBot/_Models/DataModels/MusicPlaylist.cs delete mode 100644 src/NadekoBot/_Models/DataModels/PlaylistSongInfo.cs delete mode 100644 src/NadekoBot/_Models/DataModels/PokeTypes.cs delete mode 100644 src/NadekoBot/_Models/DataModels/RequestModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/SongInfo.cs delete mode 100644 src/NadekoBot/_Models/DataModels/StatsModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/TestDataModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/TypingArticleModel.cs delete mode 100644 src/NadekoBot/_Models/DataModels/UserQuoteModel.cs delete mode 100644 src/NadekoBot/_Models/JSONModels/AnimeResult.cs delete mode 100644 src/NadekoBot/_Models/JSONModels/Configuration.cs delete mode 100644 src/NadekoBot/_Models/JSONModels/LocalizedStrings.cs delete mode 100644 src/NadekoBot/_Models/JSONModels/MagicItem.cs delete mode 100644 src/NadekoBot/_Models/JSONModels/PokemonType.cs delete mode 100644 src/NadekoBot/_Models/JSONModels/_JSONModels.cs diff --git a/src/NadekoBot/Migrations/20160901010812_second.Designer.cs b/src/NadekoBot/Migrations/20160901010812_second.Designer.cs new file mode 100644 index 00000000..939154cf --- /dev/null +++ b/src/NadekoBot/Migrations/20160901010812_second.Designer.cs @@ -0,0 +1,432 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using NadekoBot.Services.Database.Impl; + +namespace NadekoBot.Migrations +{ + [DbContext(typeof(NadekoSqliteContext))] + [Migration("20160901010812_second")] + partial class second + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.0-rtm-21431"); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ItemId"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("BlacklistItem"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BufferSize"); + + b.Property("CurrencyName"); + + b.Property("CurrencyPluralName"); + + b.Property("CurrencySign"); + + b.Property("DontJoinServers"); + + b.Property("ForwardMessages"); + + b.Property("ForwardToAllOwners"); + + b.Property("RemindMessageFormat"); + + b.Property("RotatingStatuses"); + + b.HasKey("Id"); + + b.ToTable("BotConfig"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BaseDestroyed"); + + b.Property("CallUser"); + + b.Property("ClashWarId"); + + b.Property("Stars"); + + b.Property("TimeAdded"); + + b.HasKey("Id"); + + b.HasIndex("ClashWarId"); + + b.ToTable("ClashCallers"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashWar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("EnemyClan"); + + b.Property("GuildId"); + + b.Property("Size"); + + b.Property("StartedAt"); + + b.Property("WarState"); + + b.HasKey("Id"); + + b.ToTable("ClashOfClans"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Currency"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("Name"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Donators"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("EightBallResponse"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.Property("GuildId"); + + b.Property("LastStatus"); + + b.Property("Type"); + + b.Property("Username"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FollowedStream"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AutoAssignRoleId"); + + b.Property("AutoDeleteByeMessages"); + + b.Property("AutoDeleteGreetMessages"); + + b.Property("AutoDeleteGreetMessagesTimer"); + + b.Property("AutoDeleteSelfAssignedRoleMessages"); + + b.Property("ByeMessageChannelId"); + + b.Property("ChannelByeMessageText"); + + b.Property("ChannelGreetMessageText"); + + b.Property("DefaultMusicVolume"); + + b.Property("DeleteMessageOnCommand"); + + b.Property("DmGreetMessageText"); + + b.Property("ExclusiveSelfAssignedRoles"); + + b.Property("GreetMessageChannelId"); + + b.Property("GuildId"); + + b.Property("SendChannelByeMessage"); + + b.Property("SendChannelGreetMessage"); + + b.Property("SendDmGreetMessage"); + + b.Property("VoicePlusTextEnabled"); + + b.HasKey("Id"); + + b.HasIndex("GuildId") + .IsUnique(); + + b.ToTable("GuildConfigs"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ModuleName"); + + b.Property("Prefix"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("ModulePrefix"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("PlayingStatus"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuthorId"); + + b.Property("AuthorName") + .IsRequired(); + + b.Property("GuildId"); + + b.Property("Keyword") + .IsRequired(); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Icon"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("RaceAnimal"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Reminder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("IsPrivate"); + + b.Property("Message"); + + b.Property("ServerId"); + + b.Property("UserId"); + + b.Property("When"); + + b.HasKey("Id"); + + b.ToTable("Reminders"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Repeater", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildId"); + + b.Property("Interval"); + + b.Property("Message"); + + b.HasKey("Id"); + + b.HasIndex("ChannelId") + .IsUnique(); + + b.ToTable("Repeaters"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SelfAssignedRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildId"); + + b.Property("RoleId"); + + b.HasKey("Id"); + + b.HasIndex("GuildId", "RoleId") + .IsUnique(); + + b.ToTable("SelfAssignableRoles"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.TypingArticle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Author"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.ToTable("TypingArticles"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("Blacklist") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.HasOne("NadekoBot.Services.Database.Models.ClashWar", "ClashWar") + .WithMany("Bases") + .HasForeignKey("ClashWarId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("EightBallResponses") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FollowedStreams") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("ModulePrefixes") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RotatingStatusMessages") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RaceAnimals") + .HasForeignKey("BotConfigId"); + }); + } + } +} diff --git a/src/NadekoBot/Migrations/20160901010812_second.cs b/src/NadekoBot/Migrations/20160901010812_second.cs new file mode 100644 index 00000000..b3eee6b4 --- /dev/null +++ b/src/NadekoBot/Migrations/20160901010812_second.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace NadekoBot.Migrations +{ + public partial class second : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "TypingArticles", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Autoincrement", true), + Author = table.Column(nullable: true), + Text = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TypingArticles", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TypingArticles"); + } + } +} diff --git a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs index af288187..14198069 100644 --- a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs +++ b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs @@ -363,6 +363,20 @@ namespace NadekoBot.Migrations b.ToTable("SelfAssignableRoles"); }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.TypingArticle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Author"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.ToTable("TypingArticles"); + }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => { b.HasOne("NadekoBot.Services.Database.Models.BotConfig") diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 012a580a..8b205fdf 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -13,7 +13,7 @@ ////todo Add flags for every event //namespace NadekoBot.Modules.Administration //{ -// internal class LogCommand : DiscordCommand +// public class LogCommand : DiscordCommand // { // private string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】"; @@ -373,7 +373,7 @@ // catch { } // } -// internal override void Init(CommandGroupBuilder cgb) +// public override void Init(CommandGroupBuilder cgb) // { // cgb.CreateCommand(Module.Prefix + "spmom") diff --git a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs index a3166161..bafa59b3 100644 --- a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs @@ -23,6 +23,7 @@ namespace NadekoBot.Modules.Administration public VoicePlusTextCommands() { NadekoBot.Client.UserUpdated += UserUpdatedEventHandler; + voicePlusTextCache = new ConcurrentDictionary(); } private Task UserUpdatedEventHandler(IGuildUser before, IGuildUser after) diff --git a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs index 7aece0bc..2731627f 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs @@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Gambling private ConcurrentQueue animals { get; } - public bool Fail { get; internal set; } + public bool Fail { get; set; } public List participants = new List(); private ulong serverId; diff --git a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs index c3e9d9ed..e2654649 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs @@ -17,14 +17,14 @@ namespace NadekoBot.Modules.Gambling [LocalizedCommand, LocalizedDescription, LocalizedSummary] [RequireContext(ContextType.Guild)] public Task Roll(IUserMessage umsg, [Remainder] string arg = null) => - InternalRoll(umsg, arg, true); + publicRoll(umsg, arg, true); [LocalizedCommand, LocalizedDescription, LocalizedSummary] [RequireContext(ContextType.Guild)] public Task Rolluo(IUserMessage umsg, [Remainder] string arg = null) => - InternalRoll(umsg, arg, false); + publicRoll(umsg, arg, false); //todo drawing - private async Task InternalRoll(IUserMessage umsg, string arg, bool ordered) + private async Task publicRoll(IUserMessage umsg, string arg, bool ordered) { var channel = (ITextChannel)umsg.Channel; var r = new Random(); diff --git a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs index 099649f6..17c5033b 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs @@ -11,11 +11,11 @@ ////todo drawing //namespace NadekoBot.Modules.Gambling //{ -// internal class DrawCommand : DiscordCommand +// public class DrawCommand : DiscordCommand // { // public DrawCommand(DiscordModule module) : base(module) { } -// internal override void Init(CommandGroupBuilder cgb) +// public override void Init(CommandGroupBuilder cgb) // { // cgb.CreateCommand(Module.Prefix + "draw") // .Description($"Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | `{Prefix}draw [x]`") diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index 3700813e..f7dcd48a 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -63,7 +63,7 @@ // private SemaphoreSlim locker = new SemaphoreSlim(1,1); -// internal override void Init(CommandGroupBuilder cgb) +// public override void Init(CommandGroupBuilder cgb) // { // cgb.CreateCommand(Module.Prefix + "pick") // .Description($"Picks a flower planted in this channel. | `{Prefix}pick`") diff --git a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs index 875f235c..efabc444 100644 --- a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs @@ -1,196 +1,190 @@ -//using Discord; -//using Discord.Commands; -//using NadekoBot.Classes; -//using NadekoBot.DataModels; -//using NadekoBot.Extensions; -//using System; -//using System.Collections.Concurrent; -//using System.Collections.Generic; -//using System.Diagnostics; -//using System.Linq; -//using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using Discord.WebSocket; +using NadekoBot.Attributes; +using NadekoBot.Extensions; +using NadekoBot.Services; +using NadekoBot.Services.Database; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; -////todo DB -////todo Rewrite? -//namespace NadekoBot.Modules.Games -//{ -// public static class SentencesProvider -// { -// internal static string GetRandomSentence() -// { -// var data = DbHandler.Instance.GetAllRows(); -// try -// { -// return data.ToList()[new Random().Next(0, data.Count())].Text; -// } -// catch -// { -// return "Failed retrieving data from parse. Owner didn't add any articles to type using `typeadd`."; -// } -// } -// } +namespace NadekoBot.Modules.Games +{ + public class TypingGame + { + public const float WORD_VALUE = 4.5f; + private readonly ITextChannel channel; + public string CurrentSentence; + public bool IsActive; + private readonly Stopwatch sw; + private readonly List finishedUserIds; -// public class TypingGame -// { -// public const float WORD_VALUE = 4.5f; -// private readonly Channel channel; -// public string CurrentSentence; -// public bool IsActive; -// private readonly Stopwatch sw; -// private readonly List finishedUserIds; + public TypingGame(ITextChannel channel) + { + this.channel = channel; + IsActive = false; + sw = new Stopwatch(); + finishedUserIds = new List(); + } -// public TypingGame(Channel channel) -// { -// this.channel = channel; -// IsActive = false; -// sw = new Stopwatch(); -// finishedUserIds = new List(); -// } + public ITextChannel Channel { get; set; } -// public Channel Channell { get; internal set; } + public async Task Stop() + { + if (!IsActive) return false; + NadekoBot.Client.MessageReceived -= AnswerReceived; + finishedUserIds.Clear(); + IsActive = false; + sw.Stop(); + sw.Reset(); + await channel.SendMessageAsync("Typing contest stopped").ConfigureAwait(false); + return true; + } -// internal async Task Stop() -// { -// if (!IsActive) return false; -// NadekoBot.Client.MessageReceived -= AnswerReceived; -// finishedUserIds.Clear(); -// IsActive = false; -// sw.Stop(); -// sw.Reset(); -// await channel.Send("Typing contest stopped").ConfigureAwait(false); -// return true; -// } - -// internal async Task Start() -// { -// while (true) -// { -// if (IsActive) return; // can't start running game -// IsActive = true; -// CurrentSentence = SentencesProvider.GetRandomSentence(); -// var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f); -// await channel.SendMessageAsync($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false); + public async Task Start() + { + while (true) + { + if (IsActive) return; // can't start running game + IsActive = true; + CurrentSentence = GetRandomSentence(); + var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f); + await channel.SendMessageAsync($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false); -// var msg = await channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false); -// await Task.Delay(1000).ConfigureAwait(false); -// await msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false); -// await Task.Delay(1000).ConfigureAwait(false); -// await msg.Edit("Starting new typing contest in **1**...").ConfigureAwait(false); -// await Task.Delay(1000).ConfigureAwait(false); -// await msg.Edit($":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:").ConfigureAwait(false); -// sw.Start(); -// HandleAnswers(); + var msg = await channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + await msg.ModifyAsync(m => m.Content = "Starting new typing contest in **2**...").ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + await msg.ModifyAsync(m => m.Content = "Starting new typing contest in **1**...").ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + await msg.ModifyAsync(m => m.Content = $":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:").ConfigureAwait(false); + sw.Start(); + HandleAnswers(); -// while (i > 0) -// { -// await Task.Delay(1000).ConfigureAwait(false); -// i--; -// if (!IsActive) -// return; -// } + while (i > 0) + { + await Task.Delay(1000).ConfigureAwait(false); + i--; + if (!IsActive) + return; + } -// await Stop().ConfigureAwait(false); -// } -// } + await Stop().ConfigureAwait(false); + } + } -// private void HandleAnswers() -// { -// NadekoBot.Client.MessageReceived += AnswerReceived; -// } + public string GetRandomSentence() + { + using (var uow = DbHandler.UnitOfWork()) + { + return uow.TypingArticles.GetRandom()?.Text ?? "No typing articles found. Use `>typeadd` command to add a new article for typing."; + } -// private async void AnswerReceived(object sender, MessageEventArgs e) -// { -// try -// { -// if (e.Channel == null || e.Channel.Id != channel.Id || umsg.Author.Id == NadekoBot.Client.CurrentUser.Id) return; + } -// var guess = e.Message.RawText; + private void HandleAnswers() + { + NadekoBot.Client.MessageReceived += AnswerReceived; + } -// var distance = CurrentSentence.LevenshteinDistance(guess); -// var decision = Judge(distance, guess.Length); -// if (decision && !finishedUserIds.Contains(umsg.Author.Id)) -// { -// finishedUserIds.Add(umsg.Author.Id); -// await channel.Send($"{umsg.Author.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false); -// if (finishedUserIds.Count % 2 == 0) -// { -// await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false); -// } -// } -// } -// catch { } -// } + private async Task AnswerReceived(IMessage imsg) + { + var msg = imsg as IUserMessage; + if (msg == null) + return; + try + { + if (channel== null || channel.Id != channel.Id || msg.Author.Id == NadekoBot.Client.GetCurrentUser().Id) return; -// private bool Judge(int errors, int textLength) => errors <= textLength / 25; + var guess = msg.Content; -// } + var distance = CurrentSentence.LevenshteinDistance(guess); + var decision = Judge(distance, guess.Length); + if (decision && !finishedUserIds.Contains(msg.Author.Id)) + { + finishedUserIds.Add(msg.Author.Id); + await channel.SendMessageAsync($"{msg.Author.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false); + if (finishedUserIds.Count % 2 == 0) + { + await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false); + } + } + } + catch { } + } -// internal class SpeedTyping : DiscordCommand -// { + private bool Judge(int errors, int textLength) => errors <= textLength / 25; -// public static ConcurrentDictionary RunningContests; + } -// public SpeedTyping(DiscordModule module) : base(module) -// { -// RunningContests = new ConcurrentDictionary(); -// } + [Group] + public class SpeedTypingCommands + { -// public Func DoFunc() => -// async e => -// { -// var game = RunningContests.GetOrAdd(umsg.Author.Server.Id, id => new TypingGame(e.Channel)); + public static ConcurrentDictionary RunningContests; -// if (game.IsActive) -// { -// await channel.SendMessageAsync( -// $"Contest already running in " + -// $"{game.Channell.Mention} channel.") -// .ConfigureAwait(false); -// } -// else -// { -// await game.Start().ConfigureAwait(false); -// } -// }; + public SpeedTypingCommands() + { + RunningContests = new ConcurrentDictionary(); + } -// private Func QuitFunc() => -// async e => -// { -// TypingGame game; -// if (RunningContests.TryRemove(umsg.Author.Server.Id, out game)) -// { -// await game.Stop().ConfigureAwait(false); -// return; -// } -// await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false); -// }; + [LocalizedCommand, LocalizedDescription, LocalizedSummary] + [RequireContext(ContextType.Guild)] + public async Task TypeStart(IUserMessage msg) + { + var channel = (ITextChannel)msg.Channel; -// internal override void Init(CommandGroupBuilder cgb) -// { -// cgb.CreateCommand(Module.Prefix + "typestart") -// .Description($"Starts a typing contest. | `{Prefix}typestart`") -// .Do(DoFunc()); + var game = RunningContests.GetOrAdd(channel.Guild.Id, id => new TypingGame(channel)); -// cgb.CreateCommand(Module.Prefix + "typestop") -// .Description($"Stops a typing contest on the current channel. | `{Prefix}typestop`") -// .Do(QuitFunc()); + if (game.IsActive) + { + await channel.SendMessageAsync( + $"Contest already running in " + + $"{game.Channel.Mention} channel.") + .ConfigureAwait(false); + } + else + { + await game.Start().ConfigureAwait(false); + } + } -// cgb.CreateCommand(Module.Prefix + "typeadd") -// .Description($"Adds a new article to the typing contest. Owner only. | `{Prefix}typeadd wordswords`") -// .Parameter("text", ParameterType.Unparsed) -// .Do(async e => -// { -// if (!NadekoBot.IsOwner(umsg.Author.Id) || string.IsNullOrWhiteSpace(text)) return; + [LocalizedCommand, LocalizedDescription, LocalizedSummary] + [RequireContext(ContextType.Guild)] + public async Task TypeStop(IUserMessage imsg) + { + var channel = (ITextChannel)imsg.Channel; + TypingGame game; + if (RunningContests.TryRemove(channel.Guild.Id, out game)) + { + await game.Stop().ConfigureAwait(false); + return; + } + await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false); + } -// DbHandler.Instance.Connection.Insert(new TypingArticle -// { -// Text = text, -// DateAdded = DateTime.Now -// }); + ////todo owner only + //[LocalizedCommand, LocalizedDescription, LocalizedSummary] + //[RequireContext(ContextType.Guild)] + //public async Task Typeadd(IUserMessage imsg, [Remainder] string text) + //{ + // var channel = (ITextChannel)imsg.Channel; -// await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); -// }); -// } -// } -//} + // using (var uow = DbHandler.UnitOfWork()) + // { + // uow.TypingArticles.Add(new Services.Database.Models.TypingArticle + // { + // Author = imsg.Author.Username, + // Text = text + // }); + // } + + // await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); + //} + } +} diff --git a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs index bb684141..56d65ca9 100644 --- a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs +++ b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs @@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Games.Trivia return list[rand]; } - internal void Reload() + public void Reload() { var arr = JArray.Parse(File.ReadAllText("data/triviaquestions.json")); diff --git a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs index 03aaccef..233bca09 100644 --- a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -234,7 +234,7 @@ namespace NadekoBot.Modules.Music.Classes }); } - internal void ClearQueue() + public void ClearQueue() { actionQueue.Enqueue(() => { @@ -256,7 +256,7 @@ namespace NadekoBot.Modules.Music.Classes }); } - internal Task MoveToVoiceChannel(IVoiceChannel voiceChannel) + public Task MoveToVoiceChannel(IVoiceChannel voiceChannel) { if (audioClient?.ConnectionState != ConnectionState.Connected) throw new InvalidOperationException("Can't move while bot is not connected to voice channel."); @@ -264,13 +264,13 @@ namespace NadekoBot.Modules.Music.Classes return PlaybackVoiceChannel.ConnectAsync(); } - internal bool ToggleRepeatSong() => this.RepeatSong = !this.RepeatSong; + public bool ToggleRepeatSong() => this.RepeatSong = !this.RepeatSong; - internal bool ToggleRepeatPlaylist() => this.RepeatPlaylist = !this.RepeatPlaylist; + public bool ToggleRepeatPlaylist() => this.RepeatPlaylist = !this.RepeatPlaylist; - internal bool ToggleAutoplay() => this.Autoplay = !this.Autoplay; + public bool ToggleAutoplay() => this.Autoplay = !this.Autoplay; - internal void ThrowIfQueueFull() + public void ThrowIfQueueFull() { if (MaxQueueSize == 0) return; diff --git a/src/NadekoBot/Modules/Music/Classes/Song.cs b/src/NadekoBot/Modules/Music/Classes/Song.cs index 9ec3c1db..00757f92 100644 --- a/src/NadekoBot/Modules/Music/Classes/Song.cs +++ b/src/NadekoBot/Modules/Music/Classes/Song.cs @@ -16,18 +16,18 @@ namespace NadekoBot.Modules.Music.Classes { public class SongInfo { - public string Provider { get; internal set; } - public MusicType ProviderType { get; internal set; } + public string Provider { get; set; } + public MusicType ProviderType { get; set; } /// /// Will be set only if the providertype is normal /// - public string Query { get; internal set; } - public string Title { get; internal set; } - public string Uri { get; internal set; } + public string Query { get; set; } + public string Title { get; set; } + public string Uri { get; set; } } public class Song { - public StreamState State { get; internal set; } + public StreamState State { get; set; } public string PrettyName => $"**【 {SongInfo.Title.TrimTo(55)} 】**`{(SongInfo.Provider ?? "-")}` `by {QueuerName}`"; public SongInfo SongInfo { get; } @@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Music.Classes return this; } - internal async Task Play(IAudioClient voiceClient, CancellationToken cancelToken) + public async Task Play(IAudioClient voiceClient, CancellationToken cancelToken) { var filename = Path.Combine(Music.MusicDataPath, DateTime.Now.UnixTimestamp().ToString()); diff --git a/src/NadekoBot/Modules/Music/Classes/SoundCloud.cs b/src/NadekoBot/Modules/Music/Classes/SoundCloud.cs index c788ed74..c653d5a2 100644 --- a/src/NadekoBot/Modules/Music/Classes/SoundCloud.cs +++ b/src/NadekoBot/Modules/Music/Classes/SoundCloud.cs @@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Music.Classes public bool IsSoundCloudLink(string url) => System.Text.RegularExpressions.Regex.IsMatch(url, "(.*)(soundcloud.com|snd.sc)(.*)"); - internal async Task GetVideoByQueryAsync(string query) + public async Task GetVideoByQueryAsync(string query) { if (string.IsNullOrWhiteSpace(query)) throw new ArgumentNullException(nameof(query)); diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index 407f2116..a8699ca4 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -204,7 +204,7 @@ namespace NadekoBot.Modules.NSFW } - internal static async Task GetE621ImageLink(string tags) + public static async Task GetE621ImageLink(string tags) { try { diff --git a/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs b/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs index 52a6d157..63ed2205 100644 --- a/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs @@ -30,7 +30,7 @@ // } -// internal override void Init(CommandGroupBuilder cgb) +// public override void Init(CommandGroupBuilder cgb) // { // cgb.CreateCommand(Module.Prefix + "convert") // .Description($"Convert quantities from>to. | `{Prefix}convert m>km 1000`") diff --git a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs index 8e52985a..2aa4cdc3 100644 --- a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs @@ -113,7 +113,7 @@ namespace NadekoBot.Modules.Searches // public float StatScore { get; set; } // } -// internal override void Init(CommandGroupBuilder cgb) +// public override void Init(CommandGroupBuilder cgb) // { // cgb.CreateCommand(Module.Prefix + "lolchamp") // .Description($"Shows League Of Legends champion statistics. If there are spaces/apostrophes or in the name - omit them. Optional second parameter is a role. |`{Prefix}lolchamp Riven` or `{Prefix}lolchamp Annie sup`") diff --git a/src/NadekoBot/Modules/Trello/Trello.cs b/src/NadekoBot/Modules/Trello/Trello.cs index 18e1a4d5..fbda6fab 100644 --- a/src/NadekoBot/Modules/Trello/Trello.cs +++ b/src/NadekoBot/Modules/Trello/Trello.cs @@ -11,7 +11,7 @@ ////todo rewrite //namespace NadekoBot.Modules.Trello //{ -// internal class Trello : DiscordModule +// public class Trello : DiscordModule // { // private readonly Timer t = new Timer { Interval = 2000 }; // public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Trello; diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 380f6767..d8310229 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -28,7 +28,7 @@ namespace NadekoBot.Resources { private static global::System.Globalization.CultureInfo resourceCulture; - internal CommandStrings() { + public CommandStrings() { } /// diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index 72395491..38b66963 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -28,7 +28,7 @@ namespace NadekoBot.Resources { private static global::System.Globalization.CultureInfo resourceCulture; - internal ResponseStrings() { + public ResponseStrings() { } /// diff --git a/src/NadekoBot/Services/Database/Models/ClashWar.cs b/src/NadekoBot/Services/Database/Models/ClashWar.cs index 2daaf699..77c77994 100644 --- a/src/NadekoBot/Services/Database/Models/ClashWar.cs +++ b/src/NadekoBot/Services/Database/Models/ClashWar.cs @@ -29,7 +29,7 @@ namespace NadekoBot.Services.Database.Models public ulong ChannelId { get; set; } [NotMapped] - public ITextChannel Channel { get; internal set; } + public ITextChannel Channel { get; set; } public List Bases { get; set; } } diff --git a/src/NadekoBot/Services/Database/Models/TypingArticle.cs b/src/NadekoBot/Services/Database/Models/TypingArticle.cs new file mode 100644 index 00000000..508ace03 --- /dev/null +++ b/src/NadekoBot/Services/Database/Models/TypingArticle.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Services.Database.Models +{ + public class TypingArticle : DbEntity + { + public string Author { get; set; } + public string Text { get; set; } + } +} diff --git a/src/NadekoBot/Services/Database/NadekoContext.cs b/src/NadekoBot/Services/Database/NadekoContext.cs index ae32be4a..5ca23079 100644 --- a/src/NadekoBot/Services/Database/NadekoContext.cs +++ b/src/NadekoBot/Services/Database/NadekoContext.cs @@ -20,6 +20,7 @@ namespace NadekoBot.Services.Database public DbSet BotConfig { get; set; } public DbSet Repeaters { get; set; } public DbSet Currency { get; set; } + public DbSet TypingArticles { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/src/NadekoBot/Services/Database/Repositories/ITypingArticlesRepository.cs b/src/NadekoBot/Services/Database/Repositories/ITypingArticlesRepository.cs new file mode 100644 index 00000000..d60dae77 --- /dev/null +++ b/src/NadekoBot/Services/Database/Repositories/ITypingArticlesRepository.cs @@ -0,0 +1,14 @@ +using NadekoBot.Services.Database.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Services.Database.Repositories +{ + public interface ITypingArticlesRepository : IRepository + { + TypingArticle GetRandom(); + } +} diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/TypingArticlesRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/TypingArticlesRepository.cs new file mode 100644 index 00000000..5322b990 --- /dev/null +++ b/src/NadekoBot/Services/Database/Repositories/Impl/TypingArticlesRepository.cs @@ -0,0 +1,25 @@ +using NadekoBot.Services.Database.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +namespace NadekoBot.Services.Database.Repositories.Impl +{ + public class TypingArticlesRepository : Repository, ITypingArticlesRepository + { + private Random _rand = null; + private Random rand => _rand ?? (_rand = new Random()); + public TypingArticlesRepository(DbContext context) : base(context) + { + } + + public TypingArticle GetRandom() + { + var skip = (int)(rand.NextDouble() * _set.Count()); + return _set.Skip(skip).FirstOrDefault(); + } + } +} diff --git a/src/NadekoBot/Services/Database/UnitOfWork.cs b/src/NadekoBot/Services/Database/UnitOfWork.cs index f8e42e64..4934af41 100644 --- a/src/NadekoBot/Services/Database/UnitOfWork.cs +++ b/src/NadekoBot/Services/Database/UnitOfWork.cs @@ -39,6 +39,9 @@ namespace NadekoBot.Services.Database private ICurrencyRepository _currency; public ICurrencyRepository Currency => _currency ?? (_currency = new CurrencyRepository(_context)); + private ITypingArticlesRepository _typingArticles; + public ITypingArticlesRepository TypingArticles => _typingArticles ?? (_typingArticles = new TypingArticlesRepository(_context)); + public UnitOfWork(NadekoContext context) { _context = context; diff --git a/src/NadekoBot/_Classes/ServerSpecificConfig.cs b/src/NadekoBot/_Classes/ServerSpecificConfig.cs index 9142e574..46351c82 100644 --- a/src/NadekoBot/_Classes/ServerSpecificConfig.cs +++ b/src/NadekoBot/_Classes/ServerSpecificConfig.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace NadekoBot.Classes { - internal class SpecificConfigurations + public class SpecificConfigurations { public static SpecificConfigurations Default { get; } = new SpecificConfigurations(); public static bool Instantiated { get; private set; } @@ -73,7 +73,7 @@ namespace NadekoBot.Classes } } - internal class ServerSpecificConfig : INotifyPropertyChanged + public class ServerSpecificConfig : INotifyPropertyChanged { [JsonProperty("VoicePlusTextEnabled")] private bool voicePlusTextEnabled; diff --git a/src/NadekoBot/_Models/DataModels/AnnouncementModel.cs b/src/NadekoBot/_Models/DataModels/AnnouncementModel.cs deleted file mode 100644 index c4103dad..00000000 --- a/src/NadekoBot/_Models/DataModels/AnnouncementModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; - -namespace NadekoBot.DataModels -{ - internal class Announcement : IDataModel - { - public long ServerId { get; set; } = 0; - public bool Greet { get; set; } = false; - public bool GreetPM { get; set; } = false; - [JsonProperty("greetChannel")] - public long GreetChannelId { get; set; } = 0; - public string GreetText { get; set; } = "Welcome %user%!"; - public bool Bye { get; set; } = false; - public bool ByePM { get; set; } = false; - [JsonProperty("byeChannel")] - public long ByeChannelId { get; set; } = 0; - public string ByeText { get; set; } = "%user% has left the server."; - public bool DeleteGreetMessages { get; set; } = true; - } -} diff --git a/src/NadekoBot/_Models/DataModels/CommandModel.cs b/src/NadekoBot/_Models/DataModels/CommandModel.cs deleted file mode 100644 index 204ec061..00000000 --- a/src/NadekoBot/_Models/DataModels/CommandModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace NadekoBot.DataModels { - internal class Command : IDataModel { - public long UserId { get; set; } - public string UserName { get; set; } - public long ServerId { get; set; } - public string ServerName { get; set; } - public long ChannelId { get; set; } - public string ChannelName { get; set; } - public string CommandName { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/CurrencyStateModel.cs b/src/NadekoBot/_Models/DataModels/CurrencyStateModel.cs deleted file mode 100644 index 9c8b8671..00000000 --- a/src/NadekoBot/_Models/DataModels/CurrencyStateModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NadekoBot.DataModels { - internal class CurrencyState : IDataModel { - public long Value { get; set; } - [SQLite.Unique] - public long UserId { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/CurrencyTransactionModel.cs b/src/NadekoBot/_Models/DataModels/CurrencyTransactionModel.cs deleted file mode 100644 index 51fcccc3..00000000 --- a/src/NadekoBot/_Models/DataModels/CurrencyTransactionModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NadekoBot.DataModels { - internal class CurrencyTransaction : IDataModel { - public string Reason { get; set; } - public int Value { get; set; } - public long UserId { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/Donator.cs b/src/NadekoBot/_Models/DataModels/Donator.cs deleted file mode 100644 index 483898ec..00000000 --- a/src/NadekoBot/_Models/DataModels/Donator.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NadekoBot.DataModels { - internal class Donator : IDataModel { - public long UserId { get; set; } - public string UserName { get; set; } - public int Amount { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/IDataModel.cs b/src/NadekoBot/_Models/DataModels/IDataModel.cs deleted file mode 100644 index 90191474..00000000 --- a/src/NadekoBot/_Models/DataModels/IDataModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using SQLite; -using System; - -namespace NadekoBot.DataModels -{ - internal abstract class IDataModel - { - [PrimaryKey, AutoIncrement] - public int? Id { get; set; } - [Newtonsoft.Json.JsonProperty("createdAt")] - public DateTime DateAdded { get; set; } = DateTime.Now; - public IDataModel() { } - } -} diff --git a/src/NadekoBot/_Models/DataModels/Incident.cs b/src/NadekoBot/_Models/DataModels/Incident.cs deleted file mode 100644 index 2ce2ddd6..00000000 --- a/src/NadekoBot/_Models/DataModels/Incident.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace NadekoBot.DataModels -{ - class Incident : IDataModel - { - public long ServerId { get; set; } - public long ChannelId { get; set; } - public string Text { get; set; } - public bool Read { get; set; } = false; - } -} diff --git a/src/NadekoBot/_Models/DataModels/MusicPlaylist.cs b/src/NadekoBot/_Models/DataModels/MusicPlaylist.cs deleted file mode 100644 index 60973baa..00000000 --- a/src/NadekoBot/_Models/DataModels/MusicPlaylist.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NadekoBot.DataModels -{ - internal class MusicPlaylist : IDataModel - { - public string Name { get; set; } - public long CreatorId { get; set; } - public string CreatorName { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/PlaylistSongInfo.cs b/src/NadekoBot/_Models/DataModels/PlaylistSongInfo.cs deleted file mode 100644 index 84929781..00000000 --- a/src/NadekoBot/_Models/DataModels/PlaylistSongInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NadekoBot.DataModels -{ - internal class PlaylistSongInfo : IDataModel - { - public int PlaylistId { get; set; } - public int SongInfoId { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/PokeTypes.cs b/src/NadekoBot/_Models/DataModels/PokeTypes.cs deleted file mode 100644 index d0f538af..00000000 --- a/src/NadekoBot/_Models/DataModels/PokeTypes.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NadekoBot.DataModels -{ - class UserPokeTypes : IDataModel - { - public long UserId { get; set; } - public string type { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/RequestModel.cs b/src/NadekoBot/_Models/DataModels/RequestModel.cs deleted file mode 100644 index 7b86198f..00000000 --- a/src/NadekoBot/_Models/DataModels/RequestModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace NadekoBot.DataModels { - internal class Request : IDataModel { - public string UserName { get; set; } - public long UserId { get; set; } - public string ServerName { get; set; } - public long ServerId { get; set; } - [Newtonsoft.Json.JsonProperty("Request")] - public string RequestText { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/SongInfo.cs b/src/NadekoBot/_Models/DataModels/SongInfo.cs deleted file mode 100644 index 6fe980ac..00000000 --- a/src/NadekoBot/_Models/DataModels/SongInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using SQLite; - -namespace NadekoBot.DataModels -{ - internal class SongInfo : IDataModel - { - public string Provider { get; internal set; } - public int ProviderType { get; internal set; } - public string Title { get; internal set; } - public string Uri { get; internal set; } - [Unique] - public string Query { get; internal set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/StatsModel.cs b/src/NadekoBot/_Models/DataModels/StatsModel.cs deleted file mode 100644 index 480b569f..00000000 --- a/src/NadekoBot/_Models/DataModels/StatsModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace NadekoBot.DataModels { - internal class Stats : IDataModel { - public int ConnectedServers { get; set; } - public int OnlineUsers { get; set; } - public TimeSpan Uptime { get; set; } - public int RealOnlineUsers { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/TestDataModel.cs b/src/NadekoBot/_Models/DataModels/TestDataModel.cs deleted file mode 100644 index 247743ca..00000000 --- a/src/NadekoBot/_Models/DataModels/TestDataModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NadekoBot.DataModels -{ - internal class TestDataModel : IDataModel - { - public long TestNumber { get; set; } - public string TestString { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/TypingArticleModel.cs b/src/NadekoBot/_Models/DataModels/TypingArticleModel.cs deleted file mode 100644 index 2557a51c..00000000 --- a/src/NadekoBot/_Models/DataModels/TypingArticleModel.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace NadekoBot.DataModels { - internal class TypingArticle : IDataModel { - public string Text { get; set; } - } -} diff --git a/src/NadekoBot/_Models/DataModels/UserQuoteModel.cs b/src/NadekoBot/_Models/DataModels/UserQuoteModel.cs deleted file mode 100644 index 544252cc..00000000 --- a/src/NadekoBot/_Models/DataModels/UserQuoteModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NadekoBot.DataModels { - internal class UserQuote : IDataModel { - public string UserName { get; set; } - public string Keyword { get; set; } - public string Text { get; set; } - } -} diff --git a/src/NadekoBot/_Models/JSONModels/AnimeResult.cs b/src/NadekoBot/_Models/JSONModels/AnimeResult.cs deleted file mode 100644 index a092ae03..00000000 --- a/src/NadekoBot/_Models/JSONModels/AnimeResult.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace NadekoBot.Classes.JSONModels -{ - public class AnimeResult - { - public int id; - public string airing_status; - public string title_english; - public int total_episodes; - public string description; - public string image_url_lge; - - public override string ToString() => - "`Title:` **" + title_english + - "**\n`Status:` " + airing_status + - "\n`Episodes:` " + total_episodes + - "\n`Link:` http://anilist.co/anime/" + id + - "\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." + - "\n`img:` " + image_url_lge; - } -} \ No newline at end of file diff --git a/src/NadekoBot/_Models/JSONModels/Configuration.cs b/src/NadekoBot/_Models/JSONModels/Configuration.cs deleted file mode 100644 index 04a4895e..00000000 --- a/src/NadekoBot/_Models/JSONModels/Configuration.cs +++ /dev/null @@ -1,246 +0,0 @@ -using Discord; -using NadekoBot.Extensions; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.IO; -using System.Runtime.Serialization; -using System.Threading; -using System.Threading.Tasks; - -namespace NadekoBot.Classes.JSONModels -{ - public class Configuration - { - [JsonIgnore] - public static readonly Dictionary> DefaultCustomReactions = new Dictionary> - { - {@"\o\", new List() - { "/o/" } }, - {"/o/", new List() - { @"\o\" } }, - {"moveto", new List() { - @"(👉 ͡° ͜ʖ ͡°)👉 %target%" } }, - {"comeatmebro", new List() { - "%target% (ง’̀-‘́)ง" } }, - {"e", new List() { - "%user% did it 😒 🔫", - "%target% did it 😒 🔫" } }, - {"%mention% insult", new List() { - "%target% You are a poop.", - "%target% You're a jerk.", - "%target% I will eat you when I get my powers back." - } }, - {"%mention% praise", new List() - { - "%target% You are cool.", - "%target% You are nice!", - "%target% You did a good job.", - "%target% You did something nice.", - "%target% is awesome!", - "%target% Wow." - } }, - {"%mention% pat", new List() { - "http://i.imgur.com/IiQwK12.gif", - "http://i.imgur.com/JCXj8yD.gif", - "http://i.imgur.com/qqBl2bm.gif", - "http://i.imgur.com/eOJlnwP.gif", - "https://45.media.tumblr.com/229ec0458891c4dcd847545c81e760a5/tumblr_mpfy232F4j1rxrpjzo1_r2_500.gif", - "https://media.giphy.com/media/KZQlfylo73AMU/giphy.gif", - "https://media.giphy.com/media/12hvLuZ7uzvCvK/giphy.gif", - "http://gallery1.anivide.com/_full/65030_1382582341.gif", - "https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ", - } }, - {"%mention% cry", new List() - { - "http://i.imgur.com/Xg3i1Qy.gif", - "http://i.imgur.com/3K8DRrU.gif", - "http://i.imgur.com/k58BcAv.gif", - "http://i.imgur.com/I2fLXwo.gif" - } }, - {"%mention% are you real?", new List() - { - "%user%, I will be soon." - } }, - {"%mention% are you there?", new List() - { - "Yes. :)" - } }, - {"%mention% draw", new List() { - "Sorry, I don't gamble, type $draw for that function." - } }, - {"%mention% bb", new List() - { - "Bye %target%" - } }, - {"%mention% call", new List() { - "Calling %target%" - } }, - {"%mention% disguise", new List() { - "https://cdn.discordapp.com/attachments/140007341880901632/156721710458994690/Cc5mixjUYAADgBs.jpg", - "https://cdn.discordapp.com/attachments/140007341880901632/156721715831898113/hqdefault.jpg", - "https://cdn.discordapp.com/attachments/140007341880901632/156721724430352385/okawari_01_haruka_weird_mask.jpg", - "https://cdn.discordapp.com/attachments/140007341880901632/156721728763068417/mustache-best-girl.png" - - } }, - {"%mention% inv", new List() { - "To invite your bot, click on this link -> " - } }, - { "%mention% threaten", new List() { - "You wanna die, %target%?" - } }, - { "%mention% archer", new List() { - "http://i.imgur.com/Bha9NhL.jpg" - } } - }; - - public bool DontJoinServers { get; set; } = false; - public bool ForwardMessages { get; set; } = true; - public bool ForwardToAllOwners { get; set; } = false; - public bool IsRotatingStatus { get; set; } = false; - public int BufferSize { get; set; } = 4.MiB(); - - public string[] RaceAnimals { get; internal set; } = { - "🐼", - "🐻", - "🐧", - "🐨", - "🐬", - "🐞", - "🦀", - "🦄" }; - - [JsonIgnore] - public List Quotes { get; set; } = new List(); - - [JsonIgnore] - public List PokemonTypes { get; set; } = new List(); - - public string RemindMessageFormat { get; set; } = "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗"; - - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public Dictionary> CustomReactions { get; set; } - - public List RotatingStatuses { get; set; } = new List(); - public CommandPrefixesModel CommandPrefixes { get; set; } = new CommandPrefixesModel(); - public HashSet ServerBlacklist { get; set; } = new HashSet(); - public HashSet ChannelBlacklist { get; set; } = new HashSet(); - - public HashSet UserBlacklist { get; set; } = new HashSet() { - 105309315895693312, - 119174277298782216, - 143515953525817344 - }; - - [OnDeserialized] - internal void OnDeserialized(StreamingContext context) - { - if (CustomReactions == null) - { - CustomReactions = DefaultCustomReactions; - } - } - [OnSerializing] - internal void OnSerializing(StreamingContext context) - { - if (CustomReactions == null) - { - CustomReactions = DefaultCustomReactions; - } - } - - public string[] _8BallResponses { get; set; } = - { - "Most definitely yes", - "For sure", - "As I see it, yes", - "My sources say yes", - "Yes", - "Most likely", - "Perhaps", - "Maybe", - "Not sure", - "It is uncertain", - "Ask me again later", - "Don't count on it", - "Probably not", - "Very doubtful", - "Most likely no", - "Nope", - "No", - "My sources say no", - "Dont even think about it", - "Definitely no", - "NO - It may cause disease contraction" - }; - - public string CurrencySign { get; set; } = "🌸"; - public string CurrencyName { get; set; } = "NadekoFlower"; - public string DMHelpString { get; set; } = "Type `-h` for help."; - public string HelpString { get; set; } = @"You can use `{0}modules` command to see a list of all modules. -You can use `{0}commands ModuleName` -(for example `{0}commands Administration`) to see a list of all of the commands in that module. -For a specific command help, use `{0}h ""Command name""` (for example `-h ""!m q""`) - - -**LIST OF COMMANDS CAN BE FOUND ON THIS LINK** - - - -Nadeko Support Server: "; - } - - public class CommandPrefixesModel - { - public string Administration { get; set; } = "."; - public string Searches { get; set; } = "~"; - public string NSFW { get; set; } = "~"; - public string Conversations { get; set; } = "<@{0}>"; - public string ClashOfClans { get; set; } = ","; - public string Help { get; set; } = "-"; - public string Music { get; set; } = "!!"; - public string Trello { get; set; } = "trello "; - public string Games { get; set; } = ">"; - public string Gambling { get; set; } = "$"; - public string Permissions { get; set; } = ";"; - public string Programming { get; set; } = "%"; - public string Pokemon { get; set; } = ">"; - public string Utility { get; set; } = "."; - } - - public static class ConfigHandler - { - private static readonly SemaphoreSlim configLock = new SemaphoreSlim(1, 1); - public static async Task SaveConfig() - { - await configLock.WaitAsync(); - try - { - File.WriteAllText("data/config.json", JsonConvert.SerializeObject(NadekoBot.Config, Formatting.Indented)); - } - finally - { - configLock.Release(); - } - } - - public static bool IsBlackListed(MessageEventArgs evArgs) => IsUserBlacklisted(evArgs.User.Id) || - (!evArgs.Channel.IsPrivate && - (IsChannelBlacklisted(evArgs.Channel.Id) || IsServerBlacklisted(evArgs.Server.Id))); - - public static bool IsServerBlacklisted(ulong id) => NadekoBot.Config.ServerBlacklist.Contains(id); - - public static bool IsChannelBlacklisted(ulong id) => NadekoBot.Config.ChannelBlacklist.Contains(id); - - public static bool IsUserBlacklisted(ulong id) => NadekoBot.Config.UserBlacklist.Contains(id); - } - - public class Quote - { - public string Author { get; set; } - public string Text { get; set; } - - public override string ToString() => - $"{Text}\n\t*-{Author}*"; - } - -} diff --git a/src/NadekoBot/_Models/JSONModels/LocalizedStrings.cs b/src/NadekoBot/_Models/JSONModels/LocalizedStrings.cs deleted file mode 100644 index 861ebb69..00000000 --- a/src/NadekoBot/_Models/JSONModels/LocalizedStrings.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.IO; - -namespace NadekoBot.Classes.JSONModels { - public class LocalizedStrings { - public string[] Insults { get; set; } = { - " You are a poop.", " You're a jerk.", - " I will eat you when I get my powers back." - }; - - public string[] Praises { get; set; } = { - " You are cool.", - " You are nice!", - " You did a good job.", - " You did something nice.", - " is awesome!", - " Wow." - }; - - public static string[] GetAvailableLocales() { - Directory.CreateDirectory("data/locales"); - return Directory.GetFiles("data/locales"); - } - - //public static void HandleLocalization() { - // var locales = LocalizedStrings.GetAvailableLocales(); - - - // Console.WriteLine("Pick a language:\n" + - // "1. English"); - // for (var i = 0; i < locales.Length; i++) { - // Console.WriteLine((i + 2) + ". " + Path.GetFileNameWithoutExtension(locales[i])); - // } - // File.WriteAllText("data/locales/english.json", JsonConvert.SerializeObject(new LocalizedStrings(), Formatting.Indented)); - // try { - // Console.WriteLine($"Type in a number from {1} to {locales.Length + 1}\n"); - // var input = Console.ReadLine(); - // if (input != "1") - // Locale = LocalizedStrings.LoadLocale(locales[int.Parse(input) - 2]); - // } catch (Exception ex) { - // Console.ForegroundColor = ConsoleColor.Red; - // Console.WriteLine(ex); - // Console.ReadKey(); - // return; - // } - //} - - public static LocalizedStrings LoadLocale(string localeFile) => - Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText(localeFile)); - } -} diff --git a/src/NadekoBot/_Models/JSONModels/MagicItem.cs b/src/NadekoBot/_Models/JSONModels/MagicItem.cs deleted file mode 100644 index 1ef3db1b..00000000 --- a/src/NadekoBot/_Models/JSONModels/MagicItem.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NadekoBot.Classes.JSONModels -{ - class MagicItem - { - public string Name { get; set; } - public string Description { get; set; } - public override string ToString() => - $"✨`{Name}`\n\t*{Description}*"; - } -} diff --git a/src/NadekoBot/_Models/JSONModels/PokemonType.cs b/src/NadekoBot/_Models/JSONModels/PokemonType.cs deleted file mode 100644 index 02e50e2f..00000000 --- a/src/NadekoBot/_Models/JSONModels/PokemonType.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NadekoBot.Classes.JSONModels -{ - public class PokemonType - { - public PokemonType(string n, string i, string[] m, List multi) - { - Name = n; - Icon = i; - Moves = m; - Multipliers = multi; - } - public string Name { get; set; } - public List Multipliers { get; set; } - public string Icon { get; set; } - public string[] Moves { get; set; } - } - public class PokemonMultiplier - { - public PokemonMultiplier(string t, double m) - { - Type = t; - Multiplication = m; - } - public string Type { get; set; } - public double Multiplication { get; set; } - } -} diff --git a/src/NadekoBot/_Models/JSONModels/_JSONModels.cs b/src/NadekoBot/_Models/JSONModels/_JSONModels.cs deleted file mode 100644 index c60d32d8..00000000 --- a/src/NadekoBot/_Models/JSONModels/_JSONModels.cs +++ /dev/null @@ -1,155 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Diagnostics; - -namespace NadekoBot.Classes.JSONModels -{ - public class Credentials - { - public string Token { get; set; } = ""; - public string ClientId { get; set; } = "170254782546575360"; - public ulong BotId { get; set; } = 1231231231231; - public ulong[] OwnerIds { get; set; } = { 123123123123, 5675675679845 }; - public string GoogleAPIKey { get; set; } = ""; - public string SoundCloudClientID { get; set; } = ""; - public string MashapeKey { get; set; } = ""; - public string LOLAPIKey { get; set; } = ""; - public string TrelloAppKey { get; set; } = ""; - public string CarbonKey { get; set; } = ""; - public string OsuAPIKey { get; set; } = ""; - } - [DebuggerDisplay("{items[0].id.playlistId}")] - public class YoutubePlaylistSearch - { - public YtPlaylistItem[] items { get; set; } - } - public class YtPlaylistItem - { - public YtPlaylistId id { get; set; } - } - public class YtPlaylistId - { - public string kind { get; set; } - public string playlistId { get; set; } - } - [DebuggerDisplay("{items[0].id.videoId}")] - public class YoutubeVideoSearch - { - public YtVideoItem[] items { get; set; } - } - public class YtVideoItem - { - public YtVideoId id { get; set; } - } - public class YtVideoId - { - public string kind { get; set; } - public string videoId { get; set; } - } - public class PlaylistItemsSearch - { - public string nextPageToken { get; set; } - public PlaylistItem[] items { get; set; } - } - public class PlaylistItem - { - public YtVideoId contentDetails { get; set; } - } - - #region wikpedia example - // { - // "batchcomplete": true, - // "query": { - // "normalized": [ - // { - // "from": "u3fn92fb32f9yb329f32", - // "to": "U3fn92fb32f9yb329f32" - // } - // ], - // "pages": [ - // { - // "ns": 0, - // "title": "U3fn92fb32f9yb329f32", - // "missing": true, - // "contentmodel": "wikitext", - // "pagelanguage": "en", - // "pagelanguagehtmlcode": "en", - // "pagelanguagedir": "ltr", - // "fullurl": "https://en.wikipedia.org/wiki/U3fn92fb32f9yb329f32", - // "editurl": "https://en.wikipedia.org/w/index.php?title=U3fn92fb32f9yb329f32&action=edit", - // "canonicalurl": "https://en.wikipedia.org/wiki/U3fn92fb32f9yb329f32" - // } - // ] - // } - //} - #endregion - - public class WikipediaApiModel - { - public WikipediaQuery Query { get; set; } - } - - public class WikipediaQuery - { - public WikipediaPage[] Pages { get; set; } - } - - public class WikipediaPage - { - public bool Missing { get; set; } = false; - public string FullUrl { get; set; } - } - - public class WoWJoke - { - public string Question { get; set; } - public string Answer { get; set; } - public override string ToString() => $"`{Question}`\n\n**{Answer}**"; - } -} - -//{ -// "kind": "youtube#searchListResponse", -// "etag": "\"kiOs9cZLH2FUp6r6KJ8eyq_LIOk/hCJTmyH_v57mh_MvnUFSTHfjzBs\"", -// "nextPageToken": "CAEQAA", -// "regionCode": "RS", -// "pageInfo": { -// "totalResults": 4603, -// "resultsPerPage": 1 -// }, -// "items": [ -// { -// "kind": "youtube#searchResult", -// "etag": "\"kiOs9cZLH2FUp6r6KJ8eyq_LIOk/iD1S35mk0xOfwTB_8lpPZ9u-Vzc\"", -// "id": { -// "kind": "youtube#playlist", -// "playlistId": "PLs_KC2CCxJVMfOBnIyW5Kbu_GciNiYNAI" -// }, -// "snippet": { -// "publishedAt": "2016-04-14T11:35:29.000Z", -// "channelId": "UCMLwm18Qa20L2L-HGpgC3jQ", -// "title": "Popular Videos - Otorimonogatari & mousou express", -// "description": "", -// "thumbnails": { -// "default": { -// "url": "https://i.ytimg.com/vi/2FeptLky2mU/default.jpg", -// "width": 120, -// "height": 90 -// }, -// "medium": { -// "url": "https://i.ytimg.com/vi/2FeptLky2mU/mqdefault.jpg", -// "width": 320, -// "height": 180 -// }, -// "high": { -// "url": "https://i.ytimg.com/vi/2FeptLky2mU/hqdefault.jpg", -// "width": 480, -// "height": 360 -// } -// }, -// "channelTitle": "Otorimonogatari - Topic", -// "liveBroadcastContent": "none" -// } -// } -// ] -//} \ No newline at end of file diff --git a/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs index 920675b4..8e9aa652 100644 --- a/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs @@ -9,7 +9,7 @@ using System.Text.RegularExpressions; namespace NadekoBot.Modules.CustomReactions { - internal class CustomReactionsModule : DiscordModule + public class CustomReactionsModule : DiscordModule { public override string Prefix { get; } = ""; diff --git a/src/NadekoBot/_Modules/DiscordCommand.cs b/src/NadekoBot/_Modules/DiscordCommand.cs index 05f9a42a..39637e1b 100644 --- a/src/NadekoBot/_Modules/DiscordCommand.cs +++ b/src/NadekoBot/_Modules/DiscordCommand.cs @@ -34,6 +34,6 @@ namespace NadekoBot.Classes /// /// Initializes the CommandBuilder with values using CommandGroupBuilder /// - internal abstract void Init(CommandGroupBuilder cgb); + public abstract void Init(CommandGroupBuilder cgb); } } diff --git a/src/NadekoBot/_Modules/Permissions/Classes/PermissionChecker.cs b/src/NadekoBot/_Modules/Permissions/Classes/PermissionChecker.cs index cf658aad..6c1fcd89 100644 --- a/src/NadekoBot/_Modules/Permissions/Classes/PermissionChecker.cs +++ b/src/NadekoBot/_Modules/Permissions/Classes/PermissionChecker.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; namespace NadekoBot.Modules.Permissions.Classes { - internal class PermissionChecker : IPermissionChecker + public class PermissionChecker : IPermissionChecker { public static PermissionChecker Instance { get; } = new PermissionChecker(); diff --git a/src/NadekoBot/_Modules/Permissions/Classes/PermissionHelper.cs b/src/NadekoBot/_Modules/Permissions/Classes/PermissionHelper.cs index c972953e..e17801d9 100644 --- a/src/NadekoBot/_Modules/Permissions/Classes/PermissionHelper.cs +++ b/src/NadekoBot/_Modules/Permissions/Classes/PermissionHelper.cs @@ -6,7 +6,7 @@ using System.Linq; namespace NadekoBot.Modules.Permissions.Classes { - internal static class PermissionHelper + public static class PermissionHelper { public static bool ValidateBool(string passedArg) { @@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Permissions.Classes } } - internal static string ValidateModule(string mod) + public static string ValidateModule(string mod) { if (string.IsNullOrWhiteSpace(mod)) throw new ArgumentNullException(nameof(mod)); @@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Permissions.Classes throw new ArgumentException("That module does not exist."); } - internal static string ValidateCommand(string commandText) + public static string ValidateCommand(string commandText) { if (string.IsNullOrWhiteSpace(commandText)) throw new ArgumentNullException(nameof(commandText)); @@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Permissions.Classes throw new NullReferenceException("That command does not exist."); } - internal static Role ValidateRole(Server server, string roleName) + public static Role ValidateRole(Server server, string roleName) { if (string.IsNullOrWhiteSpace(roleName)) throw new ArgumentNullException(nameof(roleName)); @@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Permissions.Classes return role; } - internal static Channel ValidateChannel(Server server, string channelName) + public static Channel ValidateChannel(Server server, string channelName) { if (string.IsNullOrWhiteSpace(channelName)) throw new ArgumentNullException(nameof(channelName)); @@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Permissions.Classes return channel; } - internal static User ValidateUser(Server server, string userName) + public static User ValidateUser(Server server, string userName) { if (string.IsNullOrWhiteSpace(userName)) throw new ArgumentNullException(nameof(userName)); diff --git a/src/NadekoBot/_Modules/Permissions/Classes/PermissionsHandler.cs b/src/NadekoBot/_Modules/Permissions/Classes/PermissionsHandler.cs index 6839b276..29ebeb20 100644 --- a/src/NadekoBot/_Modules/Permissions/Classes/PermissionsHandler.cs +++ b/src/NadekoBot/_Modules/Permissions/Classes/PermissionsHandler.cs @@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Permissions.Classes Console.WriteLine("Permission initialization complete."); } - internal static Permissions GetRolePermissionsById(Server server, ulong id) + public static Permissions GetRolePermissionsById(Server server, ulong id) { ServerPermissions serverPerms; if (!PermissionsDict.TryGetValue(server.Id, out serverPerms)) @@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Permissions.Classes return toReturn; } - internal static Permissions GetUserPermissionsById(Server server, ulong id) + public static Permissions GetUserPermissionsById(Server server, ulong id) { ServerPermissions serverPerms; if (!PermissionsDict.TryGetValue(server.Id, out serverPerms)) @@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Permissions.Classes return toReturn; } - internal static Permissions GetChannelPermissionsById(Server server, ulong id) + public static Permissions GetChannelPermissionsById(Server server, ulong id) { ServerPermissions serverPerms; if (!PermissionsDict.TryGetValue(server.Id, out serverPerms)) @@ -74,13 +74,13 @@ namespace NadekoBot.Modules.Permissions.Classes return toReturn; } - internal static Permissions GetServerPermissions(Server server) + public static Permissions GetServerPermissions(Server server) { ServerPermissions serverPerms; return !PermissionsDict.TryGetValue(server.Id, out serverPerms) ? null : serverPerms.Permissions; } - internal static PermissionBanType GetPermissionBanType(Command command, User user, Channel channel) + public static PermissionBanType GetPermissionBanType(Command command, User user, Channel channel) { var server = user.Server; ServerPermissions serverPerms = PermissionsDict.GetOrAdd(server.Id, id => new ServerPermissions(id, server.Name)); @@ -174,7 +174,7 @@ namespace NadekoBot.Modules.Permissions.Classes return serverPerms.PermissionsControllerRole; } - internal static async Task SetPermissionsRole(Server server, string roleName) + public static async Task SetPermissionsRole(Server server, string roleName) { var serverPerms = PermissionsDict.GetOrAdd(server.Id, new ServerPermissions(server.Id, server.Name)); @@ -183,7 +183,7 @@ namespace NadekoBot.Modules.Permissions.Classes await WriteServerToJson(serverPerms).ConfigureAwait(false); } - internal static async Task SetVerbosity(Server server, bool val) + public static async Task SetVerbosity(Server server, bool val) { var serverPerms = PermissionsDict.GetOrAdd(server.Id, new ServerPermissions(server.Id, server.Name)); @@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Permissions.Classes await WriteServerToJson(serverPerms).ConfigureAwait(false); } - internal static async Task CopyRolePermissions(Role fromRole, Role toRole) + public static async Task CopyRolePermissions(Role fromRole, Role toRole) { var server = fromRole.Server; var serverPerms = PermissionsDict.GetOrAdd(server.Id, @@ -210,7 +210,7 @@ namespace NadekoBot.Modules.Permissions.Classes await WriteServerToJson(serverPerms).ConfigureAwait(false); } - internal static async Task CopyChannelPermissions(Channel fromChannel, Channel toChannel) + public static async Task CopyChannelPermissions(Channel fromChannel, Channel toChannel) { var server = fromChannel.Server; var serverPerms = PermissionsDict.GetOrAdd(server.Id, @@ -228,7 +228,7 @@ namespace NadekoBot.Modules.Permissions.Classes await WriteServerToJson(serverPerms).ConfigureAwait(false); } - internal static async Task CopyUserPermissions(User fromUser, User toUser) + public static async Task CopyUserPermissions(User fromUser, User toUser) { var server = fromUser.Server; var serverPerms = PermissionsDict.GetOrAdd(server.Id, diff --git a/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs b/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs index 7b9b1dc1..0eb94cec 100644 --- a/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs +++ b/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs @@ -7,7 +7,7 @@ using System.Text.RegularExpressions; namespace NadekoBot.Modules.Permissions { - internal class FilterInvitesCommand : DiscordCommand + public class FilterInvitesCommand : DiscordCommand { private readonly Regex filterRegex = new Regex(@"(?:discord(?:\.gg|app\.com\/invite)\/(?([\w]{16}|(?:[\w]+-?){3})))"); @@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Permissions return serverPerms.ChannelPermissions.TryGetValue(channel.Id, out perms) && perms.FilterInvites; } - internal override void Init(CommandGroupBuilder cgb) + public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand(Module.Prefix + "chnlfilterinv") .Alias(Module.Prefix + "cfi") diff --git a/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs b/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs index 781faa93..2c0c3cdf 100644 --- a/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs +++ b/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs @@ -7,7 +7,7 @@ using System.Linq; namespace NadekoBot.Modules.Permissions { - internal class FilterWords : DiscordCommand + public class FilterWords : DiscordCommand { public FilterWords(DiscordModule module) : base(module) { @@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Permissions return serverPerms.ChannelPermissions.TryGetValue(channel.Id, out perms) && perms.FilterWords; } - internal override void Init(CommandGroupBuilder cgb) + public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand(Module.Prefix + "chnlfilterwords") .Alias(Module.Prefix + "cfw") diff --git a/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs b/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs index 69d70eac..b9d6dc38 100644 --- a/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs +++ b/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace NadekoBot.Modules.Permissions { - internal class PermissionModule : DiscordModule + public class PermissionModule : DiscordModule { public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Permissions;