From eecaf9cd150ba4b7519999364d1a29574784fd8c Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 11 Oct 2016 05:27:36 +0200 Subject: [PATCH] Huge amount of work. Migrations, bugfixes, fixes to stream notifications, etc --- .../20161007091612_first.Designer.cs | 712 ----------------- .../20161007210034_cmdcds.Designer.cs | 737 ----------------- .../Migrations/20161007210034_cmdcds.cs | 44 - ...20161008022813_customreactions.Designer.cs | 755 ------------------ .../20161008022813_customreactions.cs | 34 - .../Migrations/20161009041508_second.cs | 25 - ...er.cs => 20161011031532_first.Designer.cs} | 45 +- ...91612_first.cs => 20161011031532_first.cs} | 96 ++- .../NadekoSqliteContextModelSnapshot.cs | 41 +- .../Administration/Commands/Migration.cs | 247 ++++-- .../Administration/Commands/Migration/0_9..cs | 150 ++++ .../Modules/ClashOfClans/ClashOfClans.cs | 5 +- .../Games/Commands/PlantAndPickCommands.cs | 27 +- src/NadekoBot/Modules/Help/Help.cs | 6 +- .../Commands/StreamNotificationCommands.cs | 63 +- .../Services/Database/Models/BotConfig.cs | 2 +- .../Database/Models/FollowedStream.cs | 1 - .../Services/Database/Models/GuildConfig.cs | 21 +- .../Services/Database/Models/LogSetting.cs | 2 +- .../Impl/GuildConfigRepository.cs | 2 + 20 files changed, 551 insertions(+), 2464 deletions(-) delete mode 100644 src/NadekoBot/Migrations/20161007091612_first.Designer.cs delete mode 100644 src/NadekoBot/Migrations/20161007210034_cmdcds.Designer.cs delete mode 100644 src/NadekoBot/Migrations/20161007210034_cmdcds.cs delete mode 100644 src/NadekoBot/Migrations/20161008022813_customreactions.Designer.cs delete mode 100644 src/NadekoBot/Migrations/20161008022813_customreactions.cs delete mode 100644 src/NadekoBot/Migrations/20161009041508_second.cs rename src/NadekoBot/Migrations/{20161009041508_second.Designer.cs => 20161011031532_first.Designer.cs} (97%) rename src/NadekoBot/Migrations/{20161007091612_first.cs => 20161011031532_first.cs} (91%) diff --git a/src/NadekoBot/Migrations/20161007091612_first.Designer.cs b/src/NadekoBot/Migrations/20161007091612_first.Designer.cs deleted file mode 100644 index 8a0b6f16..00000000 --- a/src/NadekoBot/Migrations/20161007091612_first.Designer.cs +++ /dev/null @@ -1,712 +0,0 @@ -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("20161007091612_first")] - partial class first - { - 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.Property("Type"); - - 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("CurrencyGenerationChance"); - - b.Property("CurrencyGenerationCooldown"); - - b.Property("CurrencyName"); - - b.Property("CurrencyPluralName"); - - b.Property("CurrencySign"); - - b.Property("DMHelpString"); - - b.Property("DontJoinServers"); - - b.Property("ForwardMessages"); - - b.Property("ForwardToAllOwners"); - - b.Property("HelpString"); - - b.Property("MigrationVersion"); - - 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.ConvertUnit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("InternalTrigger"); - - b.Property("Modifier"); - - b.Property("UnitType"); - - b.HasKey("Id"); - - b.ToTable("ConversionUnits"); - }); - - 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("EightBallResponses"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("GuildConfigId"); - - b.Property("GuildConfigId1"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.HasIndex("GuildConfigId1"); - - b.ToTable("FilterChannelId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("GuildConfigId"); - - b.Property("Word"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.ToTable("FilteredWord"); - }); - - 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("FilterInvites"); - - b.Property("FilterWords"); - - b.Property("GenerateCurrencyChannelId"); - - b.Property("GreetMessageChannelId"); - - b.Property("GuildId"); - - b.Property("LogSettingId"); - - b.Property("PermissionRole"); - - b.Property("RootPermissionId"); - - b.Property("SendChannelByeMessage"); - - b.Property("SendChannelGreetMessage"); - - b.Property("SendDmGreetMessage"); - - b.Property("VerbosePermissions"); - - b.Property("VoicePlusTextEnabled"); - - b.HasKey("Id"); - - b.HasIndex("GuildId") - .IsUnique(); - - b.HasIndex("LogSettingId"); - - b.HasIndex("RootPermissionId"); - - b.ToTable("GuildConfigs"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("LogSettingId"); - - b.HasKey("Id"); - - b.HasIndex("LogSettingId"); - - b.ToTable("IgnoredLogChannels"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("LogSettingId"); - - b.HasKey("Id"); - - b.HasIndex("LogSettingId"); - - b.ToTable("IgnoredVoicePresenceCHannels"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelCreated"); - - b.Property("ChannelDestroyed"); - - b.Property("ChannelId"); - - b.Property("ChannelUpdated"); - - b.Property("IsLogging"); - - b.Property("LogUserPresence"); - - b.Property("LogVoicePresence"); - - b.Property("MessageDeleted"); - - b.Property("MessageUpdated"); - - b.Property("UserBanned"); - - b.Property("UserJoined"); - - b.Property("UserLeft"); - - b.Property("UserPresenceChannelId"); - - b.Property("UserUnbanned"); - - b.Property("UserUpdated"); - - b.Property("VoicePresenceChannelId"); - - b.HasKey("Id"); - - b.ToTable("LogSettings"); - }); - - 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("ModulePrefixes"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Author"); - - b.Property("AuthorId"); - - b.Property("Name"); - - b.HasKey("Id"); - - b.ToTable("MusicPlaylists"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("NextId"); - - b.Property("PrimaryTarget"); - - b.Property("PrimaryTargetId"); - - b.Property("SecondaryTarget"); - - b.Property("SecondaryTargetName"); - - b.Property("State"); - - b.HasKey("Id"); - - b.HasIndex("NextId") - .IsUnique(); - - b.ToTable("Permission"); - }); - - 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.PlaylistSong", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("MusicPlaylistId"); - - b.Property("Provider"); - - b.Property("ProviderType"); - - b.Property("Query"); - - b.Property("Title"); - - b.Property("Uri"); - - b.HasKey("Id"); - - b.HasIndex("MusicPlaylistId"); - - b.ToTable("PlaylistSong"); - }); - - 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("RaceAnimals"); - }); - - 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.FilterChannelId", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId"); - - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId1"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId"); - }); - - 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.GuildConfig", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany() - .HasForeignKey("LogSettingId"); - - b.HasOne("NadekoBot.Services.Database.Models.Permission", "RootPermission") - .WithMany() - .HasForeignKey("RootPermissionId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany("IgnoredChannels") - .HasForeignKey("LogSettingId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany("IgnoredVoicePresenceChannelIds") - .HasForeignKey("LogSettingId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => - { - b.HasOne("NadekoBot.Services.Database.Models.BotConfig", "BotConfig") - .WithMany("ModulePrefixes") - .HasForeignKey("BotConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => - { - b.HasOne("NadekoBot.Services.Database.Models.Permission", "Next") - .WithOne("Previous") - .HasForeignKey("NadekoBot.Services.Database.Models.Permission", "NextId"); - }); - - 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.PlaylistSong", b => - { - b.HasOne("NadekoBot.Services.Database.Models.MusicPlaylist") - .WithMany("Songs") - .HasForeignKey("MusicPlaylistId") - .OnDelete(DeleteBehavior.Cascade); - }); - - 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/20161007210034_cmdcds.Designer.cs b/src/NadekoBot/Migrations/20161007210034_cmdcds.Designer.cs deleted file mode 100644 index 79c21557..00000000 --- a/src/NadekoBot/Migrations/20161007210034_cmdcds.Designer.cs +++ /dev/null @@ -1,737 +0,0 @@ -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("20161007210034_cmdcds")] - partial class cmdcds - { - 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.Property("Type"); - - 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("CurrencyGenerationChance"); - - b.Property("CurrencyGenerationCooldown"); - - b.Property("CurrencyName"); - - b.Property("CurrencyPluralName"); - - b.Property("CurrencySign"); - - b.Property("DMHelpString"); - - b.Property("DontJoinServers"); - - b.Property("ForwardMessages"); - - b.Property("ForwardToAllOwners"); - - b.Property("HelpString"); - - b.Property("MigrationVersion"); - - 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.CommandCooldown", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CommandName"); - - b.Property("GuildConfigId"); - - b.Property("Seconds"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.ToTable("CommandCooldown"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("InternalTrigger"); - - b.Property("Modifier"); - - b.Property("UnitType"); - - b.HasKey("Id"); - - b.ToTable("ConversionUnits"); - }); - - 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("EightBallResponses"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("GuildConfigId"); - - b.Property("GuildConfigId1"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.HasIndex("GuildConfigId1"); - - b.ToTable("FilterChannelId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("GuildConfigId"); - - b.Property("Word"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.ToTable("FilteredWord"); - }); - - 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("FilterInvites"); - - b.Property("FilterWords"); - - b.Property("GenerateCurrencyChannelId"); - - b.Property("GreetMessageChannelId"); - - b.Property("GuildId"); - - b.Property("LogSettingId"); - - b.Property("PermissionRole"); - - b.Property("RootPermissionId"); - - b.Property("SendChannelByeMessage"); - - b.Property("SendChannelGreetMessage"); - - b.Property("SendDmGreetMessage"); - - b.Property("VerbosePermissions"); - - b.Property("VoicePlusTextEnabled"); - - b.HasKey("Id"); - - b.HasIndex("GuildId") - .IsUnique(); - - b.HasIndex("LogSettingId"); - - b.HasIndex("RootPermissionId"); - - b.ToTable("GuildConfigs"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("LogSettingId"); - - b.HasKey("Id"); - - b.HasIndex("LogSettingId"); - - b.ToTable("IgnoredLogChannels"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("LogSettingId"); - - b.HasKey("Id"); - - b.HasIndex("LogSettingId"); - - b.ToTable("IgnoredVoicePresenceCHannels"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelCreated"); - - b.Property("ChannelDestroyed"); - - b.Property("ChannelId"); - - b.Property("ChannelUpdated"); - - b.Property("IsLogging"); - - b.Property("LogUserPresence"); - - b.Property("LogVoicePresence"); - - b.Property("MessageDeleted"); - - b.Property("MessageUpdated"); - - b.Property("UserBanned"); - - b.Property("UserJoined"); - - b.Property("UserLeft"); - - b.Property("UserPresenceChannelId"); - - b.Property("UserUnbanned"); - - b.Property("UserUpdated"); - - b.Property("VoicePresenceChannelId"); - - b.HasKey("Id"); - - b.ToTable("LogSettings"); - }); - - 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("ModulePrefixes"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Author"); - - b.Property("AuthorId"); - - b.Property("Name"); - - b.HasKey("Id"); - - b.ToTable("MusicPlaylists"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("NextId"); - - b.Property("PrimaryTarget"); - - b.Property("PrimaryTargetId"); - - b.Property("SecondaryTarget"); - - b.Property("SecondaryTargetName"); - - b.Property("State"); - - b.HasKey("Id"); - - b.HasIndex("NextId") - .IsUnique(); - - b.ToTable("Permission"); - }); - - 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.PlaylistSong", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("MusicPlaylistId"); - - b.Property("Provider"); - - b.Property("ProviderType"); - - b.Property("Query"); - - b.Property("Title"); - - b.Property("Uri"); - - b.HasKey("Id"); - - b.HasIndex("MusicPlaylistId"); - - b.ToTable("PlaylistSong"); - }); - - 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("RaceAnimals"); - }); - - 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.CommandCooldown", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("CommandCooldowns") - .HasForeignKey("GuildConfigId"); - }); - - 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.FilterChannelId", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId"); - - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId1"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId"); - }); - - 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.GuildConfig", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany() - .HasForeignKey("LogSettingId"); - - b.HasOne("NadekoBot.Services.Database.Models.Permission", "RootPermission") - .WithMany() - .HasForeignKey("RootPermissionId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany("IgnoredChannels") - .HasForeignKey("LogSettingId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany("IgnoredVoicePresenceChannelIds") - .HasForeignKey("LogSettingId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => - { - b.HasOne("NadekoBot.Services.Database.Models.BotConfig", "BotConfig") - .WithMany("ModulePrefixes") - .HasForeignKey("BotConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => - { - b.HasOne("NadekoBot.Services.Database.Models.Permission", "Next") - .WithOne("Previous") - .HasForeignKey("NadekoBot.Services.Database.Models.Permission", "NextId"); - }); - - 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.PlaylistSong", b => - { - b.HasOne("NadekoBot.Services.Database.Models.MusicPlaylist") - .WithMany("Songs") - .HasForeignKey("MusicPlaylistId") - .OnDelete(DeleteBehavior.Cascade); - }); - - 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/20161007210034_cmdcds.cs b/src/NadekoBot/Migrations/20161007210034_cmdcds.cs deleted file mode 100644 index cbed2902..00000000 --- a/src/NadekoBot/Migrations/20161007210034_cmdcds.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace NadekoBot.Migrations -{ - public partial class cmdcds : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "CommandCooldown", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("Autoincrement", true), - CommandName = table.Column(nullable: true), - GuildConfigId = table.Column(nullable: true), - Seconds = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CommandCooldown", x => x.Id); - table.ForeignKey( - name: "FK_CommandCooldown_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateIndex( - name: "IX_CommandCooldown_GuildConfigId", - table: "CommandCooldown", - column: "GuildConfigId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CommandCooldown"); - } - } -} diff --git a/src/NadekoBot/Migrations/20161008022813_customreactions.Designer.cs b/src/NadekoBot/Migrations/20161008022813_customreactions.Designer.cs deleted file mode 100644 index ca6a19c5..00000000 --- a/src/NadekoBot/Migrations/20161008022813_customreactions.Designer.cs +++ /dev/null @@ -1,755 +0,0 @@ -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("20161008022813_customreactions")] - partial class customreactions - { - 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.Property("Type"); - - 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("CurrencyGenerationChance"); - - b.Property("CurrencyGenerationCooldown"); - - b.Property("CurrencyName"); - - b.Property("CurrencyPluralName"); - - b.Property("CurrencySign"); - - b.Property("DMHelpString"); - - b.Property("DontJoinServers"); - - b.Property("ForwardMessages"); - - b.Property("ForwardToAllOwners"); - - b.Property("HelpString"); - - b.Property("MigrationVersion"); - - 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.CommandCooldown", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CommandName"); - - b.Property("GuildConfigId"); - - b.Property("Seconds"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.ToTable("CommandCooldown"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("InternalTrigger"); - - b.Property("Modifier"); - - b.Property("UnitType"); - - b.HasKey("Id"); - - b.ToTable("ConversionUnits"); - }); - - 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.CustomReaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("GuildId"); - - b.Property("IsRegex"); - - b.Property("Response"); - - b.Property("Trigger"); - - b.HasKey("Id"); - - b.ToTable("CustomReactions"); - }); - - 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("EightBallResponses"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("GuildConfigId"); - - b.Property("GuildConfigId1"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.HasIndex("GuildConfigId1"); - - b.ToTable("FilterChannelId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("GuildConfigId"); - - b.Property("Word"); - - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.ToTable("FilteredWord"); - }); - - 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("FilterInvites"); - - b.Property("FilterWords"); - - b.Property("GenerateCurrencyChannelId"); - - b.Property("GreetMessageChannelId"); - - b.Property("GuildId"); - - b.Property("LogSettingId"); - - b.Property("PermissionRole"); - - b.Property("RootPermissionId"); - - b.Property("SendChannelByeMessage"); - - b.Property("SendChannelGreetMessage"); - - b.Property("SendDmGreetMessage"); - - b.Property("VerbosePermissions"); - - b.Property("VoicePlusTextEnabled"); - - b.HasKey("Id"); - - b.HasIndex("GuildId") - .IsUnique(); - - b.HasIndex("LogSettingId"); - - b.HasIndex("RootPermissionId"); - - b.ToTable("GuildConfigs"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("LogSettingId"); - - b.HasKey("Id"); - - b.HasIndex("LogSettingId"); - - b.ToTable("IgnoredLogChannels"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelId"); - - b.Property("LogSettingId"); - - b.HasKey("Id"); - - b.HasIndex("LogSettingId"); - - b.ToTable("IgnoredVoicePresenceCHannels"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ChannelCreated"); - - b.Property("ChannelDestroyed"); - - b.Property("ChannelId"); - - b.Property("ChannelUpdated"); - - b.Property("IsLogging"); - - b.Property("LogUserPresence"); - - b.Property("LogVoicePresence"); - - b.Property("MessageDeleted"); - - b.Property("MessageUpdated"); - - b.Property("UserBanned"); - - b.Property("UserJoined"); - - b.Property("UserLeft"); - - b.Property("UserPresenceChannelId"); - - b.Property("UserUnbanned"); - - b.Property("UserUpdated"); - - b.Property("VoicePresenceChannelId"); - - b.HasKey("Id"); - - b.ToTable("LogSettings"); - }); - - 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("ModulePrefixes"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Author"); - - b.Property("AuthorId"); - - b.Property("Name"); - - b.HasKey("Id"); - - b.ToTable("MusicPlaylists"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("NextId"); - - b.Property("PrimaryTarget"); - - b.Property("PrimaryTargetId"); - - b.Property("SecondaryTarget"); - - b.Property("SecondaryTargetName"); - - b.Property("State"); - - b.HasKey("Id"); - - b.HasIndex("NextId") - .IsUnique(); - - b.ToTable("Permission"); - }); - - 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.PlaylistSong", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("MusicPlaylistId"); - - b.Property("Provider"); - - b.Property("ProviderType"); - - b.Property("Query"); - - b.Property("Title"); - - b.Property("Uri"); - - b.HasKey("Id"); - - b.HasIndex("MusicPlaylistId"); - - b.ToTable("PlaylistSong"); - }); - - 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("RaceAnimals"); - }); - - 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.CommandCooldown", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("CommandCooldowns") - .HasForeignKey("GuildConfigId"); - }); - - 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.FilterChannelId", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId"); - - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId1"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => - { - b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") - .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId"); - }); - - 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.GuildConfig", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany() - .HasForeignKey("LogSettingId"); - - b.HasOne("NadekoBot.Services.Database.Models.Permission", "RootPermission") - .WithMany() - .HasForeignKey("RootPermissionId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany("IgnoredChannels") - .HasForeignKey("LogSettingId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => - { - b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") - .WithMany("IgnoredVoicePresenceChannelIds") - .HasForeignKey("LogSettingId"); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => - { - b.HasOne("NadekoBot.Services.Database.Models.BotConfig", "BotConfig") - .WithMany("ModulePrefixes") - .HasForeignKey("BotConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => - { - b.HasOne("NadekoBot.Services.Database.Models.Permission", "Next") - .WithOne("Previous") - .HasForeignKey("NadekoBot.Services.Database.Models.Permission", "NextId"); - }); - - 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.PlaylistSong", b => - { - b.HasOne("NadekoBot.Services.Database.Models.MusicPlaylist") - .WithMany("Songs") - .HasForeignKey("MusicPlaylistId") - .OnDelete(DeleteBehavior.Cascade); - }); - - 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/20161008022813_customreactions.cs b/src/NadekoBot/Migrations/20161008022813_customreactions.cs deleted file mode 100644 index 7531b628..00000000 --- a/src/NadekoBot/Migrations/20161008022813_customreactions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace NadekoBot.Migrations -{ - public partial class customreactions : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "CustomReactions", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("Autoincrement", true), - GuildId = table.Column(nullable: true), - IsRegex = table.Column(nullable: false), - Response = table.Column(nullable: true), - Trigger = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CustomReactions", x => x.Id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CustomReactions"); - } - } -} diff --git a/src/NadekoBot/Migrations/20161009041508_second.cs b/src/NadekoBot/Migrations/20161009041508_second.cs deleted file mode 100644 index 0d02f292..00000000 --- a/src/NadekoBot/Migrations/20161009041508_second.cs +++ /dev/null @@ -1,25 +0,0 @@ -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.AddColumn( - name: "OwnerOnly", - table: "CustomReactions", - nullable: false, - defaultValue: false); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "OwnerOnly", - table: "CustomReactions"); - } - } -} diff --git a/src/NadekoBot/Migrations/20161009041508_second.Designer.cs b/src/NadekoBot/Migrations/20161011031532_first.Designer.cs similarity index 97% rename from src/NadekoBot/Migrations/20161009041508_second.Designer.cs rename to src/NadekoBot/Migrations/20161011031532_first.Designer.cs index 25a7fb06..9c5398ec 100644 --- a/src/NadekoBot/Migrations/20161009041508_second.Designer.cs +++ b/src/NadekoBot/Migrations/20161011031532_first.Designer.cs @@ -8,8 +8,8 @@ using NadekoBot.Services.Database.Impl; namespace NadekoBot.Migrations { [DbContext(typeof(NadekoSqliteContext))] - [Migration("20161009041508_second")] - partial class second + [Migration("20161011031532_first")] + partial class first { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -269,8 +269,6 @@ namespace NadekoBot.Migrations b.Property("GuildId"); - b.Property("LastStatus"); - b.Property("Type"); b.Property("Username"); @@ -282,6 +280,22 @@ namespace NadekoBot.Migrations b.ToTable("FollowedStream"); }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("GCChannelId"); + }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => { b.Property("Id") @@ -315,8 +329,6 @@ namespace NadekoBot.Migrations b.Property("FilterWords"); - b.Property("GenerateCurrencyChannelId"); - b.Property("GreetMessageChannelId"); b.Property("GuildId"); @@ -623,20 +635,6 @@ 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") @@ -691,6 +689,13 @@ namespace NadekoBot.Migrations .HasForeignKey("GuildConfigId"); }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("GenerateCurrencyChannelIds") + .HasForeignKey("GuildConfigId"); + }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => { b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") diff --git a/src/NadekoBot/Migrations/20161007091612_first.cs b/src/NadekoBot/Migrations/20161011031532_first.cs similarity index 91% rename from src/NadekoBot/Migrations/20161007091612_first.cs rename to src/NadekoBot/Migrations/20161011031532_first.cs index 0b8325dc..2a346ba7 100644 --- a/src/NadekoBot/Migrations/20161007091612_first.cs +++ b/src/NadekoBot/Migrations/20161011031532_first.cs @@ -81,6 +81,23 @@ namespace NadekoBot.Migrations table.PrimaryKey("PK_Currency", x => x.Id); }); + migrationBuilder.CreateTable( + name: "CustomReactions", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Autoincrement", true), + GuildId = table.Column(nullable: true), + IsRegex = table.Column(nullable: false), + OwnerOnly = table.Column(nullable: false), + Response = table.Column(nullable: true), + Trigger = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CustomReactions", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Donators", columns: table => new @@ -228,20 +245,6 @@ namespace NadekoBot.Migrations table.PrimaryKey("PK_SelfAssignableRoles", x => x.Id); }); - 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); - }); - migrationBuilder.CreateTable( name: "BlacklistItem", columns: table => new @@ -452,7 +455,6 @@ namespace NadekoBot.Migrations ExclusiveSelfAssignedRoles = table.Column(nullable: false), FilterInvites = table.Column(nullable: false), FilterWords = table.Column(nullable: false), - GenerateCurrencyChannelId = table.Column(nullable: true), GreetMessageChannelId = table.Column(nullable: false), GuildId = table.Column(nullable: false), LogSettingId = table.Column(nullable: true), @@ -481,6 +483,27 @@ namespace NadekoBot.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "CommandCooldown", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Autoincrement", true), + CommandName = table.Column(nullable: true), + GuildConfigId = table.Column(nullable: true), + Seconds = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CommandCooldown", x => x.Id); + table.ForeignKey( + name: "FK_CommandCooldown_GuildConfigs_GuildConfigId", + column: x => x.GuildConfigId, + principalTable: "GuildConfigs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateTable( name: "FilterChannelId", columns: table => new @@ -537,7 +560,6 @@ namespace NadekoBot.Migrations ChannelId = table.Column(nullable: false), GuildConfigId = table.Column(nullable: true), GuildId = table.Column(nullable: false), - LastStatus = table.Column(nullable: false), Type = table.Column(nullable: false), Username = table.Column(nullable: true) }, @@ -552,6 +574,26 @@ namespace NadekoBot.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "GCChannelId", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Autoincrement", true), + ChannelId = table.Column(nullable: false), + GuildConfigId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GCChannelId", x => x.Id); + table.ForeignKey( + name: "FK_GCChannelId_GuildConfigs_GuildConfigId", + column: x => x.GuildConfigId, + principalTable: "GuildConfigs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateIndex( name: "IX_BlacklistItem_BotConfigId", table: "BlacklistItem", @@ -562,6 +604,11 @@ namespace NadekoBot.Migrations table: "ClashCallers", column: "ClashWarId"); + migrationBuilder.CreateIndex( + name: "IX_CommandCooldown_GuildConfigId", + table: "CommandCooldown", + column: "GuildConfigId"); + migrationBuilder.CreateIndex( name: "IX_Currency_UserId", table: "Currency", @@ -599,6 +646,11 @@ namespace NadekoBot.Migrations table: "FollowedStream", column: "GuildConfigId"); + migrationBuilder.CreateIndex( + name: "IX_GCChannelId_GuildConfigId", + table: "GCChannelId", + column: "GuildConfigId"); + migrationBuilder.CreateIndex( name: "IX_GuildConfigs_GuildId", table: "GuildConfigs", @@ -672,12 +724,18 @@ namespace NadekoBot.Migrations migrationBuilder.DropTable( name: "ClashCallers"); + migrationBuilder.DropTable( + name: "CommandCooldown"); + migrationBuilder.DropTable( name: "ConversionUnits"); migrationBuilder.DropTable( name: "Currency"); + migrationBuilder.DropTable( + name: "CustomReactions"); + migrationBuilder.DropTable( name: "Donators"); @@ -693,6 +751,9 @@ namespace NadekoBot.Migrations migrationBuilder.DropTable( name: "FollowedStream"); + migrationBuilder.DropTable( + name: "GCChannelId"); + migrationBuilder.DropTable( name: "IgnoredLogChannels"); @@ -723,9 +784,6 @@ namespace NadekoBot.Migrations migrationBuilder.DropTable( name: "SelfAssignableRoles"); - migrationBuilder.DropTable( - name: "TypingArticles"); - migrationBuilder.DropTable( name: "ClashOfClans"); diff --git a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs index 0acf0498..19a4d2e1 100644 --- a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs +++ b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs @@ -268,8 +268,6 @@ namespace NadekoBot.Migrations b.Property("GuildId"); - b.Property("LastStatus"); - b.Property("Type"); b.Property("Username"); @@ -281,6 +279,22 @@ namespace NadekoBot.Migrations b.ToTable("FollowedStream"); }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("GCChannelId"); + }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => { b.Property("Id") @@ -314,8 +328,6 @@ namespace NadekoBot.Migrations b.Property("FilterWords"); - b.Property("GenerateCurrencyChannelId"); - b.Property("GreetMessageChannelId"); b.Property("GuildId"); @@ -622,20 +634,6 @@ 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") @@ -690,6 +688,13 @@ namespace NadekoBot.Migrations .HasForeignKey("GuildConfigId"); }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("GenerateCurrencyChannelIds") + .HasForeignKey("GuildConfigId"); + }); + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => { b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") diff --git a/src/NadekoBot/Modules/Administration/Commands/Migration.cs b/src/NadekoBot/Modules/Administration/Commands/Migration.cs index e5f6a7c1..0a486149 100644 --- a/src/NadekoBot/Modules/Administration/Commands/Migration.cs +++ b/src/NadekoBot/Modules/Administration/Commands/Migration.cs @@ -13,6 +13,8 @@ using Newtonsoft.Json; using NLog; using NadekoBot.Modules.Administration.Commands.Migration; using System.Collections.Concurrent; +using NadekoBot.Extensions; +using NadekoBot.Services.Database; namespace NadekoBot.Modules.Administration { @@ -62,10 +64,158 @@ namespace NadekoBot.Modules.Administration private async Task Migrate0_9To1_0() { - Config0_9 oldData; + using (var uow = DbHandler.UnitOfWork()) + { + var botConfig = uow.BotConfig.GetOrCreate(); + MigrateConfig0_9(botConfig); + MigratePermissions0_9(uow); + MigrateServerSpecificConfigs0_9(uow); + + //NOW save it + botConfig.MigrationVersion = 1; + await uow.CompleteAsync().ConfigureAwait(false); + } + } + + private void MigrateServerSpecificConfigs0_9(IUnitOfWork uow) + { + const string specificConfigsPath = "data/ServerSpecificConfigs.json"; + var configs = new ConcurrentDictionary(); try { - oldData = JsonConvert.DeserializeObject(File.ReadAllText("./data/config.json")); + configs = JsonConvert + .DeserializeObject>( + File.ReadAllText(specificConfigsPath), new JsonSerializerSettings() + { + Error = (s, e) => + { + if (e.ErrorContext.Member.ToString() == "GenerateCurrencyChannels") + { + e.ErrorContext.Handled = true; + } + } + }); + } + catch (Exception ex) + { + _log.Warn(ex, "ServerSpecificConfig deserialization failed"); + return; + } + + foreach (var config in configs) + { + var guildId = config.Key; + var data = config.Value; + + var guildConfig = uow.GuildConfigs.For(guildId); + + guildConfig.AutoAssignRoleId = data.AutoAssignedRole; + guildConfig.DeleteMessageOnCommand = data.AutoDeleteMessagesOnCommand; + guildConfig.DefaultMusicVolume = data.DefaultMusicVolume; + guildConfig.ExclusiveSelfAssignedRoles = data.ExclusiveSelfAssignedRoles; + guildConfig.GenerateCurrencyChannelIds = new HashSet(data.GenerateCurrencyChannels.Select(gc => new GCChannelId() { ChannelId = gc.Key })); + uow.SelfAssignedRoles.AddRange(data.ListOfSelfAssignableRoles.Select(r => new SelfAssignedRole() { GuildId = guildId, RoleId = r }).ToArray()); + var logSetting = guildConfig.LogSetting; + guildConfig.LogSetting.IgnoredChannels = new HashSet(data.LogserverIgnoreChannels.Select(id => new IgnoredLogChannel() { ChannelId = id })); + guildConfig.FollowedStreams = new HashSet(data.ObservingStreams.Select(x => + { + FollowedStream.FollowedStreamType type = FollowedStream.FollowedStreamType.Twitch; + switch (x.Type) + { + case StreamNotificationConfig0_9.StreamType.Twitch: + type = FollowedStream.FollowedStreamType.Twitch; + break; + case StreamNotificationConfig0_9.StreamType.Beam: + type = FollowedStream.FollowedStreamType.Beam; + break; + case StreamNotificationConfig0_9.StreamType.Hitbox: + type = FollowedStream.FollowedStreamType.Hitbox; + break; + default: + break; + } + + return new FollowedStream() + { + ChannelId = x.ChannelId, + GuildId = guildId, + Username = x.Username.ToLowerInvariant(), + Type = type + }; + })); + guildConfig.VoicePlusTextEnabled = data.VoicePlusTextEnabled; + } + try { File.Move("data/ServerSpecificConfigs.json", "data/DELETE_ME_ServerSpecificCOnfigs.json"); } catch { } + } + + private void MigratePermissions0_9(IUnitOfWork uow) + { + var PermissionsDict = new ConcurrentDictionary(); + Directory.CreateDirectory("data/permissions"); + foreach (var file in Directory.EnumerateFiles("data/permissions/")) + { + try + { + var strippedFileName = Path.GetFileNameWithoutExtension(file); + if (string.IsNullOrWhiteSpace(strippedFileName)) continue; + var id = ulong.Parse(strippedFileName); + var data = JsonConvert.DeserializeObject(File.ReadAllText(file)); + PermissionsDict.TryAdd(id, data); + } + catch { } + } + foreach (var perms in PermissionsDict) + { + var guildId = perms.Key; + var data = perms.Value; + + _log.Info("Migrating data from permissions folder for {0}", guildId); + + var gconfig = uow.GuildConfigs.For(guildId); + + gconfig.PermissionRole = data.PermissionsControllerRole; + gconfig.VerbosePermissions = data.Verbose; + gconfig.FilteredWords = new HashSet(data.Words.Select(w => w.ToLowerInvariant()) + .Distinct() + .Select(w => new FilteredWord() { Word = w })); + gconfig.FilterWords = data.Permissions.FilterWords; + gconfig.FilterInvites = data.Permissions.FilterInvites; + + gconfig.FilterInvitesChannelIds = new HashSet(); + gconfig.FilterInvitesChannelIds.AddRange(data.ChannelPermissions.Where(kvp => kvp.Value.FilterInvites) + .Select(cp => new FilterChannelId() + { + ChannelId = cp.Key + })); + + gconfig.FilterWordsChannelIds = new HashSet(); + gconfig.FilterWordsChannelIds.AddRange(data.ChannelPermissions.Where(kvp => kvp.Value.FilterWords) + .Select(cp => new FilterChannelId() + { + ChannelId = cp.Key + })); + + gconfig.CommandCooldowns = new HashSet(data.CommandCooldowns + .Where(cc => !string.IsNullOrWhiteSpace(cc.Key) && cc.Value > 0) + .Select(cc => new CommandCooldown() + { + CommandName = cc.Key, + Seconds = cc.Value + })); + var smodules = data.Permissions.Modules.Where(m => !m.Value); + + try { Directory.Move("data/permissions","data/DELETE_ME_permissions"); } catch { } + } + + } + + private void MigrateConfig0_9(BotConfig botConfig) + { + Config0_9 oldConfig; + const string configPath = "./data/config.json"; + try + { + oldConfig = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); } catch (FileNotFoundException) { @@ -77,94 +227,89 @@ namespace NadekoBot.Modules.Administration _log.Error("Unknow error while deserializing file config.json, pls check its integrity, aborting migration"); throw new MigrationException(); } - using (var uow = DbHandler.UnitOfWork()) - { - var botConfig = uow.BotConfig.GetOrCreate(); - //Basic - botConfig.DontJoinServers = oldData.DontJoinServers; - botConfig.ForwardMessages = oldData.ForwardMessages; - botConfig.ForwardToAllOwners = oldData.ForwardToAllOwners; - botConfig.BufferSize = (ulong) oldData.BufferSize; - botConfig.RemindMessageFormat = oldData.RemindMessageFormat; - botConfig.CurrencySign = oldData.CurrencySign; - botConfig.CurrencyName = oldData.CurrencyName; - botConfig.DMHelpString = oldData.DMHelpString; - botConfig.HelpString = oldData.HelpString; + //Basic + botConfig.DontJoinServers = oldConfig.DontJoinServers; + botConfig.ForwardMessages = oldConfig.ForwardMessages; + botConfig.ForwardToAllOwners = oldConfig.ForwardToAllOwners; + botConfig.BufferSize = (ulong)oldConfig.BufferSize; + botConfig.RemindMessageFormat = oldConfig.RemindMessageFormat; + botConfig.CurrencySign = oldConfig.CurrencySign; + botConfig.CurrencyName = oldConfig.CurrencyName; + botConfig.DMHelpString = oldConfig.DMHelpString; + botConfig.HelpString = oldConfig.HelpString; - //messages - botConfig.RotatingStatuses = oldData.IsRotatingStatus; - var messages = new List(); + //messages + botConfig.RotatingStatuses = oldConfig.IsRotatingStatus; + var messages = new List(); - oldData.RotatingStatuses.ForEach(i => messages.Add(new PlayingStatus { Status = i })); - botConfig.RotatingStatusMessages = messages; + oldConfig.RotatingStatuses.ForEach(i => messages.Add(new PlayingStatus { Status = i })); + botConfig.RotatingStatusMessages = messages; - //races - var races = new HashSet(); - oldData.RaceAnimals.ForEach(i => races.Add(new RaceAnimal() { Icon = i, Name = i })); + //races + var races = new HashSet(); + oldConfig.RaceAnimals.ForEach(i => races.Add(new RaceAnimal() { Icon = i, Name = i })); + if (races.Any()) botConfig.RaceAnimals = races; - //Prefix - var prefix = new HashSet + //Prefix + var prefix = new HashSet { new ModulePrefix() { ModuleName = "Administration", - Prefix = oldData.CommandPrefixes.Administration + Prefix = oldConfig.CommandPrefixes.Administration }, new ModulePrefix() { ModuleName = "Searches", - Prefix = oldData.CommandPrefixes.Searches + Prefix = oldConfig.CommandPrefixes.Searches }, - new ModulePrefix() {ModuleName = "NSFW", Prefix = oldData.CommandPrefixes.NSFW}, + new ModulePrefix() {ModuleName = "NSFW", Prefix = oldConfig.CommandPrefixes.NSFW}, new ModulePrefix() { ModuleName = "Conversations", - Prefix = oldData.CommandPrefixes.Conversations + Prefix = oldConfig.CommandPrefixes.Conversations }, new ModulePrefix() { ModuleName = "ClashOfClans", - Prefix = oldData.CommandPrefixes.ClashOfClans + Prefix = oldConfig.CommandPrefixes.ClashOfClans }, - new ModulePrefix() {ModuleName = "Help", Prefix = oldData.CommandPrefixes.Help}, - new ModulePrefix() {ModuleName = "Music", Prefix = oldData.CommandPrefixes.Music}, - new ModulePrefix() {ModuleName = "Trello", Prefix = oldData.CommandPrefixes.Trello}, - new ModulePrefix() {ModuleName = "Games", Prefix = oldData.CommandPrefixes.Games}, + new ModulePrefix() {ModuleName = "Help", Prefix = oldConfig.CommandPrefixes.Help}, + new ModulePrefix() {ModuleName = "Music", Prefix = oldConfig.CommandPrefixes.Music}, + new ModulePrefix() {ModuleName = "Trello", Prefix = oldConfig.CommandPrefixes.Trello}, + new ModulePrefix() {ModuleName = "Games", Prefix = oldConfig.CommandPrefixes.Games}, new ModulePrefix() { ModuleName = "Gambling", - Prefix = oldData.CommandPrefixes.Gambling + Prefix = oldConfig.CommandPrefixes.Gambling }, new ModulePrefix() { ModuleName = "Permissions", - Prefix = oldData.CommandPrefixes.Permissions + Prefix = oldConfig.CommandPrefixes.Permissions }, new ModulePrefix() { ModuleName = "Programming", - Prefix = oldData.CommandPrefixes.Programming + Prefix = oldConfig.CommandPrefixes.Programming }, - new ModulePrefix() {ModuleName = "Pokemon", Prefix = oldData.CommandPrefixes.Pokemon}, - new ModulePrefix() {ModuleName = "Utility", Prefix = oldData.CommandPrefixes.Utility} + new ModulePrefix() {ModuleName = "Pokemon", Prefix = oldConfig.CommandPrefixes.Pokemon}, + new ModulePrefix() {ModuleName = "Utility", Prefix = oldConfig.CommandPrefixes.Utility} }; - botConfig.ModulePrefixes = prefix; + botConfig.ModulePrefixes = prefix; - //Blacklist - var blacklist = oldData.ServerBlacklist.Select(server => new BlacklistItem() {ItemId = server, Type = BlacklistItem.BlacklistType.Server}).ToList(); - blacklist.AddRange(oldData.ChannelBlacklist.Select(channel => new BlacklistItem() {ItemId = channel, Type = BlacklistItem.BlacklistType.Channel})); - blacklist.AddRange(oldData.UserBlacklist.Select(user => new BlacklistItem() {ItemId = user, Type = BlacklistItem.BlacklistType.User})); - botConfig.Blacklist = new HashSet(blacklist); + //Blacklist + var blacklist = new HashSet(oldConfig.ServerBlacklist.Select(server => new BlacklistItem() { ItemId = server, Type = BlacklistItem.BlacklistType.Server })); + blacklist.AddRange(oldConfig.ChannelBlacklist.Select(channel => new BlacklistItem() { ItemId = channel, Type = BlacklistItem.BlacklistType.Channel })); + blacklist.AddRange(oldConfig.UserBlacklist.Select(user => new BlacklistItem() { ItemId = user, Type = BlacklistItem.BlacklistType.User })); + botConfig.Blacklist = blacklist; - //Eightball - botConfig.EightBallResponses = new HashSet(oldData._8BallResponses.Select(response => new EightBallResponse() {Text = response})); + //Eightball + botConfig.EightBallResponses = new HashSet(oldConfig._8BallResponses.Select(response => new EightBallResponse() { Text = response })); - //NOW save it - botConfig.MigrationVersion = 1; - await uow.CompleteAsync().ConfigureAwait(false); - } + try { File.Move(configPath, "./data/DELETE_ME_config.json"); } catch { } } } } diff --git a/src/NadekoBot/Modules/Administration/Commands/Migration/0_9..cs b/src/NadekoBot/Modules/Administration/Commands/Migration/0_9..cs index 87a18f9b..a64f588b 100644 --- a/src/NadekoBot/Modules/Administration/Commands/Migration/0_9..cs +++ b/src/NadekoBot/Modules/Administration/Commands/Migration/0_9..cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; @@ -45,4 +46,153 @@ namespace NadekoBot.Modules.Administration.Commands.Migration public string DMHelpString { get; set; } public string HelpString { get; set; } } + + /// + /// Holds a permission list + /// + public class Permissions + { + /// + /// Name of the parent object whose permissions these are + /// + public string Name { get; set; } + /// + /// Module name with allowed/disallowed + /// + public ConcurrentDictionary Modules { get; set; } + /// + /// Command name with allowed/disallowed + /// + public ConcurrentDictionary Commands { get; set; } + /// + /// Should the bot filter invites to other discord servers (and ref links in the future) + /// + public bool FilterInvites { get; set; } + /// + /// Should the bot filter words which are specified in the Words hashset + /// + public bool FilterWords { get; set; } + + public Permissions(string name) + { + Name = name; + Modules = new ConcurrentDictionary(); + Commands = new ConcurrentDictionary(); + FilterInvites = false; + FilterWords = false; + } + + public void CopyFrom(Permissions other) + { + Modules.Clear(); + foreach (var mp in other.Modules) + Modules.AddOrUpdate(mp.Key, mp.Value, (s, b) => mp.Value); + Commands.Clear(); + foreach (var cp in other.Commands) + Commands.AddOrUpdate(cp.Key, cp.Value, (s, b) => cp.Value); + FilterInvites = other.FilterInvites; + FilterWords = other.FilterWords; + } + + public override string ToString() + { + var toReturn = ""; + var bannedModules = Modules.Where(kvp => kvp.Value == false); + var bannedModulesArray = bannedModules as KeyValuePair[] ?? bannedModules.ToArray(); + if (bannedModulesArray.Any()) + { + toReturn += "`Banned Modules:`\n"; + toReturn = bannedModulesArray.Aggregate(toReturn, (current, m) => current + $"\t`[x] {m.Key}`\n"); + } + var bannedCommands = Commands.Where(kvp => kvp.Value == false); + var bannedCommandsArr = bannedCommands as KeyValuePair[] ?? bannedCommands.ToArray(); + if (bannedCommandsArr.Any()) + { + toReturn += "`Banned Commands:`\n"; + toReturn = bannedCommandsArr.Aggregate(toReturn, (current, c) => current + $"\t`[x] {c.Key}`\n"); + } + return toReturn; + } + } + + public class ServerPermissions0_9 + { + /// + /// The guy who can edit the permissions + /// + public string PermissionsControllerRole { get; set; } + /// + /// Does it print the error when a restriction occurs + /// + public bool Verbose { get; set; } + /// + /// The id of the thing (user/server/channel) + /// + public ulong Id { get; set; } //a string because of the role name. + /// + /// Permission object bound to the id of something/role name + /// + public Permissions Permissions { get; set; } + /// + /// Banned words, usually profanities, like word "java" + /// + public HashSet Words { get; set; } + + public Dictionary UserPermissions { get; set; } + public Dictionary ChannelPermissions { get; set; } + public Dictionary RolePermissions { get; set; } + /// + /// Dictionary of command names with their respective cooldowns + /// + public ConcurrentDictionary CommandCooldowns { get; set; } + + public ServerPermissions0_9(ulong id, string name) + { + Id = id; + PermissionsControllerRole = "Nadeko"; + Verbose = true; + + Permissions = new Permissions(name); + Permissions.Modules.TryAdd("NSFW", false); + UserPermissions = new Dictionary(); + ChannelPermissions = new Dictionary(); + RolePermissions = new Dictionary(); + CommandCooldowns = new ConcurrentDictionary(); + Words = new HashSet(); + } + } + + internal class ServerSpecificConfig + { + public bool VoicePlusTextEnabled { get; set; } + private bool SendPrivateMessageOnMention { get; set; } + private ulong? LogChannel { get; set; } = null; + public HashSet LogserverIgnoreChannels { get; set; } + private ulong? LogPresenceChannel = null; + public ConcurrentDictionary VoiceChannelLog { get; set; } + public HashSet ListOfSelfAssignableRoles { get; set; } + public ulong AutoAssignedRole { get; set; } + public ConcurrentDictionary GenerateCurrencyChannels { get; set; } + public bool AutoDeleteMessagesOnCommand { get; set; } + public bool ExclusiveSelfAssignedRoles { get; set; } + public float DefaultMusicVolume { get; set; } + public HashSet ObservingStreams { get; set; } + } + + public class StreamNotificationConfig0_9 + { + public string Username { get; set; } + public StreamType Type { get; set; } + public ulong ServerId { get; set; } + public ulong ChannelId { get; set; } + public bool LastStatus { get; set; } + + public enum StreamType + { + Twitch, + Beam, + Hitbox, + YoutubeGaming + } + } } \ No newline at end of file diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index b4254162..6bc586fe 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -19,7 +19,7 @@ namespace NadekoBot.Modules.ClashOfClans { public static ConcurrentDictionary> ClashWars { get; set; } = new ConcurrentDictionary>(); - public ClashOfClans(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) + static ClashOfClans() { using (var uow = DbHandler.UnitOfWork()) { @@ -36,6 +36,9 @@ namespace NadekoBot.Modules.ClashOfClans .ToDictionary(g => g.Key, g => g.ToList())); } } + public ClashOfClans(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) + { + } private static async Task CheckWar(TimeSpan callExpire, ClashWar war) { diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index 022e8f13..1c021a03 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -5,6 +5,7 @@ using NadekoBot.Attributes; using NadekoBot.Extensions; using NadekoBot.Services; using NadekoBot.Services.Database; +using NadekoBot.Services.Database.Models; using NLog; using System; using System.Collections.Concurrent; @@ -33,7 +34,7 @@ namespace NadekoBot.Modules.Games { private Random rng; - private ConcurrentDictionary generationChannels = new ConcurrentDictionary(); + private ConcurrentHashSet generationChannels = new ConcurrentHashSet(); //channelid/message private ConcurrentDictionary> plantedFlowers = new ConcurrentDictionary>(); //channelId/last generation @@ -53,9 +54,8 @@ namespace NadekoBot.Modules.Games { var conf = uow.BotConfig.GetOrCreate(); var x = - generationChannels = new ConcurrentDictionary(uow.GuildConfigs.GetAll() - .Where(c => c.GenerateCurrencyChannelId != null) - .ToDictionary(c => c.GenerateCurrencyChannelId.Value, c => true)); + generationChannels = new ConcurrentHashSet(uow.GuildConfigs.GetAll() + .SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj=>obj.ChannelId))); chance = conf.CurrencyGenerationChance; cooldown = conf.CurrencyGenerationCooldown; } @@ -71,8 +71,7 @@ namespace NadekoBot.Modules.Games if (channel == null) return Task.CompletedTask; - bool shouldGenerate; - if (!generationChannels.TryGetValue(channel.Id, out shouldGenerate) || !shouldGenerate) + if (!generationChannels.Contains(channel.Id)) return Task.CompletedTask; var t = Task.Run(async () => @@ -135,8 +134,6 @@ namespace NadekoBot.Modules.Games public async Task Plant(IUserMessage imsg) { var channel = (ITextChannel)imsg.Channel; - if (channel == null) - return; var removed = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)imsg.Author, "Planted a flower.", 1, false).ConfigureAwait(false); if (!removed) @@ -167,25 +164,23 @@ namespace NadekoBot.Modules.Games public async Task Gencurrency(IUserMessage imsg) { var channel = (ITextChannel)imsg.Channel; - if (channel == null) - return; bool enabled; using (var uow = DbHandler.UnitOfWork()) { var guildConfig = uow.GuildConfigs.For(channel.Id); - if (guildConfig.GenerateCurrencyChannelId == null) + var toAdd = new GCChannelId() { ChannelId = channel.Id }; + if (guildConfig.GenerateCurrencyChannelIds.Contains(toAdd)) { - guildConfig.GenerateCurrencyChannelId = channel.Id; - generationChannels.TryAdd(channel.Id, true); + guildConfig.GenerateCurrencyChannelIds.Add(toAdd); + generationChannels.Add(channel.Id); enabled = true; } else { - guildConfig.GenerateCurrencyChannelId = null; - bool throwaway; - generationChannels.TryRemove(channel.Id, out throwaway); + guildConfig.GenerateCurrencyChannelIds.Remove(toAdd); + generationChannels.TryRemove(channel.Id); enabled = false; } await uow.CompleteAsync(); diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index b9b90702..96d2c4f6 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -154,8 +154,8 @@ namespace NadekoBot.Modules.Help var channel = (ITextChannel)umsg.Channel; await channel.SendMessageAsync( -@"**LIST OF COMMANDS**: -**Hosting Guides and docs can be found here**: ").ConfigureAwait(false); +@"**LIST OF COMMANDS**: +**Hosting Guides and docs can be found here**: ").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -165,7 +165,7 @@ namespace NadekoBot.Modules.Help var channel = (ITextChannel)umsg.Channel; await channel.SendMessageAsync( -$@"You can support the project on patreon. or +$@"You can support the NadekoBot project on patreon. or You can send donations to `nadekodiscordbot@gmail.com` Don't forget to leave your discord name or id in the message. diff --git a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs index 093328bc..37eb9e4a 100644 --- a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs @@ -18,17 +18,32 @@ namespace NadekoBot.Modules.Searches { public partial class Searches { + public class StreamStatus + { + public StreamStatus(string link, bool isLive, string views) + { + Link = link; + IsLive = isLive; + Views = views; + } + + public bool IsLive { get; set; } + public string Link { get; set; } + public string Views { get; set; } + } [Group] public class StreamNotificationCommands { private Timer checkTimer { get; } - private ConcurrentDictionary> cachedStatuses = new ConcurrentDictionary>(); + private ConcurrentDictionary oldCachedStatuses = new ConcurrentDictionary(); + private ConcurrentDictionary cachedStatuses = new ConcurrentDictionary(); private bool FirstPass { get; set; } = true; public StreamNotificationCommands() { checkTimer = new Timer(async (state) => { + oldCachedStatuses = new ConcurrentDictionary(cachedStatuses); cachedStatuses.Clear(); try { @@ -39,19 +54,23 @@ namespace NadekoBot.Modules.Searches } foreach (var stream in streams) { - Tuple data; + StreamStatus data; try { data = await GetStreamStatus(stream).ConfigureAwait(false); + if (data == null) + return; } catch { continue; } - if (data.Item1 != stream.LastStatus) + StreamStatus oldData; + oldCachedStatuses.TryGetValue(data.Link, out oldData); + + if (oldData == null || data.IsLive != oldData.IsLive) { - stream.LastStatus = data.Item1; if (FirstPass) continue; var server = NadekoBot.Client.GetGuild(stream.GuildId); @@ -59,32 +78,30 @@ namespace NadekoBot.Modules.Searches if (channel == null) continue; var msg = $"`{stream.Username}`'s stream is now " + - $"**{(data.Item1 ? "ONLINE" : "OFFLINE")}** with " + - $"**{data.Item2}** viewers."; - if (stream.LastStatus) + $"**{(data.IsLive ? "ONLINE" : "OFFLINE")}** with " + + $"**{data.Views}** viewers."; + if (data.IsLive) if (stream.Type == FollowedStream.FollowedStreamType.Hitbox) msg += $"\n`Here is the Link:`【 http://www.hitbox.tv/{stream.Username}/ 】"; else if (stream.Type == FollowedStream.FollowedStreamType.Twitch) msg += $"\n`Here is the Link:`【 http://www.twitch.tv/{stream.Username}/ 】"; else if (stream.Type == FollowedStream.FollowedStreamType.Beam) msg += $"\n`Here is the Link:`【 http://www.beam.pro/{stream.Username}/ 】"; - //else if (stream.Type == FollowedStream.FollowedStreamType.YoutubeGaming) - // msg += $"\n`Here is the Link:`【 not implemented yet - {stream.Username} 】"; try { await channel.SendMessageAsync(msg).ConfigureAwait(false); } catch { } } } FirstPass = false; } catch { } - }, null, TimeSpan.Zero, TimeSpan.FromSeconds(15)); + }, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); } - private async Task> GetStreamStatus(FollowedStream stream, bool checkCache = true) + private async Task GetStreamStatus(FollowedStream stream, bool checkCache = true) { bool isLive; string response; JObject data; - Tuple result; + StreamStatus result; switch (stream.Type) { case FollowedStream.FollowedStreamType.Hitbox: @@ -97,7 +114,7 @@ namespace NadekoBot.Modules.Searches } data = JObject.Parse(response); isLive = data["media_is_live"].ToString() == "1"; - result = new Tuple(isLive, data["media_views"].ToString()); + result = new StreamStatus(hitboxUrl, isLive, data["media_views"].ToString()); cachedStatuses.TryAdd(hitboxUrl, result); return result; case FollowedStream.FollowedStreamType.Twitch: @@ -110,7 +127,7 @@ namespace NadekoBot.Modules.Searches } data = JObject.Parse(response); isLive = !string.IsNullOrWhiteSpace(data["stream"].ToString()); - result = new Tuple(isLive, isLive ? data["stream"]["viewers"].ToString() : stream.Username); + result = new StreamStatus(twitchUrl, isLive, isLive ? data["stream"]["viewers"].ToString() : "0"); cachedStatuses.TryAdd(twitchUrl, result); return result; case FollowedStream.FollowedStreamType.Beam: @@ -123,13 +140,13 @@ namespace NadekoBot.Modules.Searches } data = JObject.Parse(response); isLive = data["online"].ToObject() == true; - result = new Tuple(isLive, data["viewersCurrent"].ToString()); + result = new StreamStatus(beamUrl, isLive, data["viewersCurrent"].ToString()); cachedStatuses.TryAdd(beamUrl, result); return result; default: break; } - return new Tuple(false, "0"); + return null; } [NadekoCommand, Usage, Description, Aliases] @@ -181,6 +198,7 @@ namespace NadekoBot.Modules.Searches [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] + [RequirePermission(GuildPermission.ManageMessages)] public async Task RemoveStream(IUserMessage msg, [Remainder] string username) { var channel = (ITextChannel)msg.Channel; @@ -223,9 +241,9 @@ namespace NadekoBot.Modules.Searches Username = stream, Type = platform })); - if (streamStatus.Item1) + if (streamStatus.IsLive) { - await channel.SendMessageAsync($"`Streamer {username} is online with {streamStatus.Item2}.`"); + await channel.SendMessageAsync($"`Streamer {username} is online with {streamStatus.Views} viewers.`"); } else { @@ -258,7 +276,7 @@ namespace NadekoBot.Modules.Searches await channel.SendMessageAsync($":anger: I am already following `{username}` ({type}) stream on this channel.").ConfigureAwait(false); return; } - Tuple data; + StreamStatus data; try { data = await GetStreamStatus(stream).ConfigureAwait(false); @@ -268,17 +286,14 @@ namespace NadekoBot.Modules.Searches await channel.SendMessageAsync(":anger: Stream probably doesn't exist.").ConfigureAwait(false); return; } - var msg = $"Stream is currently **{(data.Item1 ? "ONLINE" : "OFFLINE")}** with **{data.Item2}** viewers"; - if (data.Item1) + var msg = $"Stream is currently **{(data.IsLive ? "ONLINE" : "OFFLINE")}** with **{data.Views}** viewers"; + if (data.IsLive) if (type == FollowedStream.FollowedStreamType.Hitbox) msg += $"\n`Here is the Link:`【 http://www.hitbox.tv/{stream.Username}/ 】"; else if (type == FollowedStream.FollowedStreamType.Twitch) msg += $"\n`Here is the Link:`【 http://www.twitch.tv/{stream.Username}/ 】"; else if (type == FollowedStream.FollowedStreamType.Beam) msg += $"\n`Here is the Link:`【 https://beam.pro/{stream.Username}/ 】"; - //else if (type == FollowedStream.FollowedStreamType.YoutubeGaming) - // msg += $"\n`Here is the Link:` not implemented yet - {stream.Username}"; - stream.LastStatus = data.Item1; using (var uow = DbHandler.UnitOfWork()) { uow.GuildConfigs.For(channel.Guild.Id).FollowedStreams.Add(stream); diff --git a/src/NadekoBot/Services/Database/Models/BotConfig.cs b/src/NadekoBot/Services/Database/Models/BotConfig.cs index 39bb8e38..5cf92cb7 100644 --- a/src/NadekoBot/Services/Database/Models/BotConfig.cs +++ b/src/NadekoBot/Services/Database/Models/BotConfig.cs @@ -44,7 +44,7 @@ For a specific command help, use `{1}h CommandName` (for example {1}h !!q) **LIST OF COMMANDS CAN BE FOUND ON THIS LINK** - + Nadeko Support Server: https://discord.gg/0ehQwTK2RBjAxzEY"; diff --git a/src/NadekoBot/Services/Database/Models/FollowedStream.cs b/src/NadekoBot/Services/Database/Models/FollowedStream.cs index 8bab223e..b1e8d245 100644 --- a/src/NadekoBot/Services/Database/Models/FollowedStream.cs +++ b/src/NadekoBot/Services/Database/Models/FollowedStream.cs @@ -11,7 +11,6 @@ namespace NadekoBot.Services.Database.Models public ulong ChannelId { get; set; } public string Username { get; set; } public FollowedStreamType Type { get; set; } - public bool LastStatus { get; set; } public ulong GuildId { get; set; } public enum FollowedStreamType diff --git a/src/NadekoBot/Services/Database/Models/GuildConfig.cs b/src/NadekoBot/Services/Database/Models/GuildConfig.cs index cc0c87ee..d7c0085f 100644 --- a/src/NadekoBot/Services/Database/Models/GuildConfig.cs +++ b/src/NadekoBot/Services/Database/Models/GuildConfig.cs @@ -41,7 +41,7 @@ namespace NadekoBot.Services.Database.Models public HashSet FollowedStreams { get; set; } = new HashSet(); //currencyGeneration - public ulong? GenerateCurrencyChannelId { get; set; } + public HashSet GenerateCurrencyChannelIds { get; set; } = new HashSet(); //permissions public Permission RootPermission { get; set; } @@ -64,8 +64,25 @@ namespace NadekoBot.Services.Database.Models public ulong ChannelId { get; set; } } - public class FilteredWord :DbEntity + public class FilteredWord : DbEntity { public string Word { get; set; } } + + public class GCChannelId : DbEntity + { + public ulong ChannelId { get; set; } + + public override bool Equals(object obj) + { + var gc = obj as GCChannelId; + if (gc == null) + return false; + + return gc.ChannelId == this.ChannelId; + } + + public override int GetHashCode() => + this.ChannelId.GetHashCode(); + } } diff --git a/src/NadekoBot/Services/Database/Models/LogSetting.cs b/src/NadekoBot/Services/Database/Models/LogSetting.cs index 02a97858..03735dae 100644 --- a/src/NadekoBot/Services/Database/Models/LogSetting.cs +++ b/src/NadekoBot/Services/Database/Models/LogSetting.cs @@ -11,7 +11,7 @@ namespace NadekoBot.Services.Database.Models { public bool IsLogging { get; set; } public ulong ChannelId { get; set; } - public ConcurrentHashSet IgnoredChannels { get; set; } + public HashSet IgnoredChannels { get; set; } public bool MessageUpdated { get; set; } = true; public bool MessageDeleted { get; set; } = true; diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs index b15d8ab8..44d6a938 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs @@ -24,6 +24,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl .ThenInclude(gc => gc.Previous) .Include(gc => gc.RootPermission) .ThenInclude(gc => gc.Next) + .Include(gc => gc.GenerateCurrencyChannelIds) .Include(gc => gc.FilterInvitesChannelIds) .Include(gc => gc.FilterWordsChannelIds) .Include(gc => gc.FilteredWords) @@ -45,6 +46,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl .Include(gc => gc.FilterInvitesChannelIds) .Include(gc => gc.FilterWordsChannelIds) .Include(gc => gc.FilteredWords) + .Include(gc => gc.GenerateCurrencyChannelIds) .Include(gc => gc.CommandCooldowns) .FirstOrDefault(c => c.GuildId == guildId);