initial commit

This commit is contained in:
Kwoth 2016-12-13 00:44:52 +01:00
parent 7365970fe0
commit 63c9316b07
12 changed files with 1263 additions and 287 deletions

View File

@ -0,0 +1,798 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models;
using NadekoBot.Modules.Music.Classes;
namespace NadekoBot.Migrations
{
[DbContext(typeof(NadekoContext))]
[Migration("20161212184456_logging")]
partial class logging
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752");
modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<ulong>("ItemId");
b.Property<int>("Type");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("BlacklistItem");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("BufferSize");
b.Property<float>("CurrencyGenerationChance");
b.Property<int>("CurrencyGenerationCooldown");
b.Property<string>("CurrencyName");
b.Property<string>("CurrencyPluralName");
b.Property<string>("CurrencySign");
b.Property<string>("DMHelpString");
b.Property<bool>("ForwardMessages");
b.Property<bool>("ForwardToAllOwners");
b.Property<string>("HelpString");
b.Property<int>("MigrationVersion");
b.Property<string>("RemindMessageFormat");
b.Property<bool>("RotatingStatuses");
b.HasKey("Id");
b.ToTable("BotConfig");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("BaseDestroyed");
b.Property<string>("CallUser");
b.Property<int>("ClashWarId");
b.Property<int?>("SequenceNumber");
b.Property<int>("Stars");
b.Property<DateTime>("TimeAdded");
b.HasKey("Id");
b.HasIndex("ClashWarId");
b.ToTable("ClashCallers");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashWar", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<string>("EnemyClan");
b.Property<ulong>("GuildId");
b.Property<int>("Size");
b.Property<DateTime>("StartedAt");
b.Property<int>("WarState");
b.HasKey("Id");
b.ToTable("ClashOfClans");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("CommandName");
b.Property<int?>("GuildConfigId");
b.Property<int>("Seconds");
b.HasKey("Id");
b.HasIndex("GuildConfigId");
b.ToTable("CommandCooldown");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("InternalTrigger");
b.Property<decimal>("Modifier");
b.Property<string>("UnitType");
b.HasKey("Id");
b.ToTable("ConversionUnits");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("Amount");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Currency");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.CurrencyTransaction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("Amount");
b.Property<string>("Reason");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.ToTable("CurrencyTransactions");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.CustomReaction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong?>("GuildId");
b.Property<bool>("IsRegex");
b.Property<bool>("OwnerOnly");
b.Property<string>("Response");
b.Property<string>("Trigger");
b.HasKey("Id");
b.ToTable("CustomReactions");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Amount");
b.Property<string>("Name");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Donators");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("Text");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("EightBallResponses");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<int?>("GuildConfigId");
b.Property<int?>("GuildConfigId1");
b.HasKey("Id");
b.HasIndex("GuildConfigId");
b.HasIndex("GuildConfigId1");
b.ToTable("FilterChannelId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("GuildConfigId");
b.Property<string>("Word");
b.HasKey("Id");
b.HasIndex("GuildConfigId");
b.ToTable("FilteredWord");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<int?>("GuildConfigId");
b.Property<ulong>("GuildId");
b.Property<int>("Type");
b.Property<string>("Username");
b.HasKey("Id");
b.HasIndex("GuildConfigId");
b.ToTable("FollowedStream");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<int?>("GuildConfigId");
b.HasKey("Id");
b.HasIndex("GuildConfigId");
b.ToTable("GCChannelId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("AutoAssignRoleId");
b.Property<bool>("AutoDeleteByeMessages");
b.Property<int>("AutoDeleteByeMessagesTimer");
b.Property<bool>("AutoDeleteGreetMessages");
b.Property<int>("AutoDeleteGreetMessagesTimer");
b.Property<bool>("AutoDeleteSelfAssignedRoleMessages");
b.Property<ulong>("ByeMessageChannelId");
b.Property<string>("ChannelByeMessageText");
b.Property<string>("ChannelGreetMessageText");
b.Property<bool>("CleverbotEnabled");
b.Property<float>("DefaultMusicVolume");
b.Property<bool>("DeleteMessageOnCommand");
b.Property<string>("DmGreetMessageText");
b.Property<bool>("ExclusiveSelfAssignedRoles");
b.Property<bool>("FilterInvites");
b.Property<bool>("FilterWords");
b.Property<ulong>("GreetMessageChannelId");
b.Property<ulong>("GuildId");
b.Property<int?>("LogSettingId");
b.Property<string>("MuteRoleName");
b.Property<string>("PermissionRole");
b.Property<int?>("RootPermissionId");
b.Property<bool>("SendChannelByeMessage");
b.Property<bool>("SendChannelGreetMessage");
b.Property<bool>("SendDmGreetMessage");
b.Property<bool>("VerbosePermissions");
b.Property<bool>("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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<int?>("LogSettingId");
b.HasKey("Id");
b.HasIndex("LogSettingId");
b.ToTable("IgnoredLogChannels");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<int?>("LogSettingId");
b.HasKey("Id");
b.HasIndex("LogSettingId");
b.ToTable("IgnoredVoicePresenceCHannels");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong?>("ChannelCreatedId");
b.Property<ulong?>("ChannelDestroyedId");
b.Property<ulong?>("ChannelUpdatedId");
b.Property<ulong?>("LogOtherId");
b.Property<ulong?>("LogUserPresenceId");
b.Property<ulong?>("LogVoicePresenceId");
b.Property<ulong?>("LogVoicePresenceTTSId");
b.Property<ulong?>("MessageDeletedId");
b.Property<ulong?>("MessageUpdatedId");
b.Property<ulong?>("UserBannedId");
b.Property<ulong?>("UserJoinedId");
b.Property<ulong?>("UserLeftId");
b.Property<ulong?>("UserUnbannedId");
b.Property<ulong?>("UserUpdatedId");
b.HasKey("Id");
b.ToTable("LogSettings");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("ModuleName");
b.Property<string>("Prefix");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("ModulePrefixes");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author");
b.Property<ulong>("AuthorId");
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("MusicPlaylists");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("NextId");
b.Property<int>("PrimaryTarget");
b.Property<ulong>("PrimaryTargetId");
b.Property<int>("SecondaryTarget");
b.Property<string>("SecondaryTargetName");
b.Property<bool>("State");
b.HasKey("Id");
b.HasIndex("NextId")
.IsUnique();
b.ToTable("Permission");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("Status");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("PlayingStatus");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("MusicPlaylistId");
b.Property<string>("Provider");
b.Property<int>("ProviderType");
b.Property<string>("Query");
b.Property<string>("Title");
b.Property<string>("Uri");
b.HasKey("Id");
b.HasIndex("MusicPlaylistId");
b.ToTable("PlaylistSong");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("AuthorId");
b.Property<string>("AuthorName")
.IsRequired();
b.Property<ulong>("GuildId");
b.Property<string>("Keyword")
.IsRequired();
b.Property<string>("Text")
.IsRequired();
b.HasKey("Id");
b.ToTable("Quotes");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("Icon");
b.Property<string>("Name");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("RaceAnimals");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Reminder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<bool>("IsPrivate");
b.Property<string>("Message");
b.Property<ulong>("ServerId");
b.Property<ulong>("UserId");
b.Property<DateTime>("When");
b.HasKey("Id");
b.ToTable("Reminders");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Repeater", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<ulong>("GuildId");
b.Property<TimeSpan>("Interval");
b.Property<string>("Message");
b.HasKey("Id");
b.HasIndex("ChannelId")
.IsUnique();
b.ToTable("Repeaters");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.SelfAssignedRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("GuildId");
b.Property<ulong>("RoleId");
b.HasKey("Id");
b.HasIndex("GuildId", "RoleId")
.IsUnique();
b.ToTable("SelfAssignableRoles");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.UserPokeTypes", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("UserId");
b.Property<string>("type");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("PokeGame");
});
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.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")
.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")
.WithMany("ModulePrefixes")
.HasForeignKey("BotConfigId");
});
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");
});
}
}
}

View File

@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations
{
public partial class logging : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
//migrationBuilder.DropIndex(
// name: "IX_GuildConfigs_LogSettingId",
// table: "GuildConfigs");
//migrationBuilder.DropIndex(
// name: "IX_IgnoredLogChannels_LogSettingId",
// table: "IgnoredLogChannels");
//migrationBuilder.DropIndex(
// name: "IX_IgnoredVoicePresenceChannels_LogSettingId",
// table: "IgnoredVoicePresenceChannels");
//migrationBuilder.DropTable("LogSettings");
//migrationBuilder.DropTable("IgnoredLogChannels");
//migrationBuilder.DropTable("IgnoredVoicePresenceChannels");
//migrationBuilder.CreateTable(
// name: "LogSettings",
// columns: table => new
// {
// Id = table.Column<int>(nullable: false)
// .Annotation("Autoincrement", true),
// LogOtherId = table.Column<ulong>(nullable: true),
// MessageUpdatedId = table.Column<ulong>(nullable: true),
// MessageDeletedId = table.Column<ulong>(nullable: true),
// UserJoinedId = table.Column<ulong>(nullable: true),
// UserLeftId = table.Column<ulong>(nullable: true),
// UserBannedId = table.Column<ulong>(nullable: true),
// UserUnbannedId = table.Column<ulong>(nullable: true),
// UserUpdatedId = table.Column<ulong>(nullable: true),
// ChannelCreatedId = table.Column<ulong>(nullable: true),
// ChannelDestroyedId = table.Column<ulong>(nullable: true),
// ChannelUpdatedId = table.Column<ulong>(nullable: true),
// LogUserPresenceId = table.Column<ulong>(nullable: true),
// LogVoicePresenceId = table.Column<ulong>(nullable: true),
// LogVoicePresenceTTSId = table.Column<ulong>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_LogSettings", x => x.Id);
// });
//migrationBuilder.CreateTable(
// name: "IgnoredLogChannels",
// columns: table => new
// {
// Id = table.Column<int>(nullable: false)
// .Annotation("Autoincrement", true),
// ChannelId = table.Column<ulong>(nullable: false),
// LogSettingId = table.Column<int>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_IgnoredLogChannels", x => x.Id);
// table.ForeignKey(
// name: "FK_IgnoredLogChannels_LogSettings_LogSettingId",
// column: x => x.LogSettingId,
// principalTable: "LogSettings",
// principalColumn: "Id",
// onDelete: ReferentialAction.Restrict);
// });
//migrationBuilder.CreateTable(
// name: "IgnoredVoicePresenceChannels",
// columns: table => new
// {
// Id = table.Column<int>(nullable: false)
// .Annotation("Autoincrement", true),
// ChannelId = table.Column<ulong>(nullable: false),
// LogSettingId = table.Column<int>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_IgnoredVoicePresenceChannels", x => x.Id);
// table.ForeignKey(
// name: "FK_IgnoredVoicePresenceChannels_LogSettings_LogSettingId",
// column: x => x.LogSettingId,
// principalTable: "LogSettings",
// principalColumn: "Id",
// onDelete: ReferentialAction.Restrict);
// });
//migrationBuilder.CreateIndex(
// name: "IX_GuildConfigs_LogSettingId",
// table: "GuildConfigs",
// column: "LogSettingId");
//migrationBuilder.CreateIndex(
// name: "IX_IgnoredLogChannels_LogSettingId",
// table: "IgnoredLogChannels",
// column: "LogSettingId");
//migrationBuilder.CreateIndex(
// name: "IX_IgnoredVoicePresenceChannels_LogSettingId",
// table: "IgnoredVoicePresenceChannels",
// column: "LogSettingId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -421,37 +421,33 @@ namespace NadekoBot.Migrations
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("ChannelCreated");
b.Property<ulong?>("ChannelCreatedId");
b.Property<bool>("ChannelDestroyed");
b.Property<ulong?>("ChannelDestroyedId");
b.Property<ulong>("ChannelId");
b.Property<ulong?>("ChannelUpdatedId");
b.Property<bool>("ChannelUpdated");
b.Property<ulong?>("LogOtherId");
b.Property<bool>("IsLogging");
b.Property<ulong?>("LogUserPresenceId");
b.Property<bool>("LogUserPresence");
b.Property<ulong?>("LogVoicePresenceId");
b.Property<bool>("LogVoicePresence");
b.Property<ulong?>("LogVoicePresenceTTSId");
b.Property<bool>("MessageDeleted");
b.Property<ulong?>("MessageDeletedId");
b.Property<bool>("MessageUpdated");
b.Property<ulong?>("MessageUpdatedId");
b.Property<bool>("UserBanned");
b.Property<ulong?>("UserBannedId");
b.Property<bool>("UserJoined");
b.Property<ulong?>("UserJoinedId");
b.Property<bool>("UserLeft");
b.Property<ulong?>("UserLeftId");
b.Property<ulong>("UserPresenceChannelId");
b.Property<ulong?>("UserUnbannedId");
b.Property<bool>("UserUnbanned");
b.Property<bool>("UserUpdated");
b.Property<ulong>("VoicePresenceChannelId");
b.Property<ulong?>("UserUpdatedId");
b.HasKey("Id");
@ -663,7 +659,7 @@ namespace NadekoBot.Migrations
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("UserId");
b.Property<ulong>("UserId");
b.Property<string>("type");

View File

@ -4,6 +4,7 @@ using Discord.WebSocket;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Modules.Permissions;
using NadekoBot.Services;
using NadekoBot.Services.Database.Models;
using NLog;
@ -88,10 +89,10 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out logSetting)
|| !logSetting.IsLogging)
|| (logSetting.LogOtherId == null))
return;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(users.First().Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(users.First().Guild, logSetting, LogType.Other)) == null)
return;
var punishment = "";
@ -119,12 +120,11 @@ namespace NadekoBot.Modules.Administration
{
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.UserUpdated)
|| (logSetting.UserUpdatedId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(before.Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -175,13 +175,12 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.ChannelUpdated
|| (logSetting.ChannelUpdatedId == null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == after.Id))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(before.Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -213,13 +212,12 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.ChannelDestroyed
|| (logSetting.ChannelDestroyedId == null)
|| logSetting.IgnoredChannels.Any(ilc=>ilc.ChannelId == ch.Id))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(ch.Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -238,12 +236,11 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.ChannelCreated)
|| (logSetting.ChannelCreatedId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(ch.Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelCreated)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -268,11 +265,11 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out logSetting)
|| !logSetting.LogVoicePresence)
|| (logSetting.LogVoicePresenceId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogChannelType.Voice)) == null)
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresence)) == null)
return Task.CompletedTask;
string str = null;
@ -298,12 +295,12 @@ namespace NadekoBot.Modules.Administration
{
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out logSetting)
|| !logSetting.LogUserPresence
|| (logSetting.LogUserPresenceId == null)
|| before.Status == after.Status)
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogChannelType.UserPresence)) == null)
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogType.UserPresence)) == null)
return Task.CompletedTask;
string str;
if (before.Status != after.Status)
@ -320,12 +317,11 @@ namespace NadekoBot.Modules.Administration
{
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.UserLeft)
|| (logSetting.UserLeftId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -340,12 +336,11 @@ namespace NadekoBot.Modules.Administration
{
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.UserJoined)
|| (logSetting.UserJoinedId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -360,12 +355,11 @@ namespace NadekoBot.Modules.Administration
{
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.UserUnbanned)
|| (logSetting.UserUnbannedId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -380,12 +374,11 @@ namespace NadekoBot.Modules.Administration
{
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.UserBanned)
|| (logSetting.UserBannedId == null))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(guild, logSetting)) == null)
if ((logChannel = TryGetLogChannel(guild, logSetting, LogType.UserBanned)) == null)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -408,13 +401,12 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.MessageDeleted
|| (logSetting.MessageDeletedId == null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(channel.Guild, logSetting)) == null || logChannel.Id == msg.Id)
if ((logChannel = TryGetLogChannel(channel.Guild, logSetting, LogType.MessageDeleted)) == null || logChannel.Id == msg.Id)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -449,13 +441,12 @@ namespace NadekoBot.Modules.Administration
LogSetting logSetting;
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out logSetting)
|| !logSetting.IsLogging
|| !logSetting.MessageUpdated
|| (logSetting.MessageUpdatedId == null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
return Task.CompletedTask;
ITextChannel logChannel;
if ((logChannel = TryGetLogChannel(channel.Guild, logSetting)) == null || logChannel.Id == after.Channel.Id)
if ((logChannel = TryGetLogChannel(channel.Guild, logSetting, LogType.MessageUpdated)) == null || logChannel.Id == after.Channel.Id)
return Task.CompletedTask;
var task = Task.Run(async () =>
@ -470,85 +461,143 @@ namespace NadekoBot.Modules.Administration
return Task.CompletedTask;
}
// private Task _client_MessageReceived(IMessage imsg)
// {
// var msg = imsg as IUserMessage;
// if (msg == null || msg.IsAuthor())
// return Task.CompletedTask;
public enum LogType {
Other,
MessageUpdated,
MessageDeleted,
UserJoined,
UserLeft,
UserBanned,
UserUnbanned,
UserUpdated,
ChannelCreated,
ChannelDestroyed,
ChannelUpdated,
UserPresence,
VoicePresence,
VoicePresenceTTS
};
// var channel = msg.Channel as ITextChannel;
// if (channel == null)
// return Task.CompletedTask;
// LogSetting logSetting;
// if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out logSetting)
// || !logSetting.IsLogging
// || !logSetting.MessageReceived)
// return Task.CompletedTask;
// ITextChannel logChannel;
// if ((logChannel = TryGetLogChannel(channel.Guild, logSetting)) == null || logChannel.Id == imsg.Channel.Id)
// return Task.CompletedTask;
// var task = Task.Run(async () =>
// {
// var str = $@"🕔`{prettyCurrentTime}` **New Message** `#{channel.Name}`
//👤`{msg.Author.Username}`: {msg.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator)}";
// if (msg.Attachments.Any())
// str += $"{Environment.NewLine}`Attachements`: {string.Join(", ", msg.Attachments.Select(a => a.ProxyUrl))}";
// await logChannel.SendMessageAsync(str).ConfigureAwait(false);
// });
// return Task.CompletedTask;
// }
private enum LogChannelType { Text, Voice, UserPresence };
private static ITextChannel TryGetLogChannel(IGuild guild, LogSetting logSetting, LogChannelType logChannelType = LogChannelType.Text)
private static ITextChannel TryGetLogChannel(IGuild guild, LogSetting logSetting, LogType logChannelType)
{
ulong id = 0;
ulong? id = null;
switch (logChannelType)
{
case LogChannelType.Text:
id = logSetting.ChannelId;
case LogType.Other:
id = logSetting.LogOtherId;
break;
case LogChannelType.Voice:
id = logSetting.VoicePresenceChannelId;
case LogType.MessageUpdated:
id = logSetting.MessageUpdatedId;
break;
case LogChannelType.UserPresence:
id = logSetting.UserPresenceChannelId;
case LogType.MessageDeleted:
id = logSetting.MessageDeletedId;
break;
case LogType.UserJoined:
id = logSetting.UserJoinedId;
break;
case LogType.UserLeft:
id = logSetting.UserLeftId;
break;
case LogType.UserBanned:
id = logSetting.UserBannedId;
break;
case LogType.UserUnbanned:
id = logSetting.UserUnbannedId;
break;
case LogType.UserUpdated:
id = logSetting.UserUpdatedId;
break;
case LogType.ChannelCreated:
id = logSetting.ChannelCreatedId;
break;
case LogType.ChannelDestroyed:
id = logSetting.ChannelDestroyedId;
break;
case LogType.ChannelUpdated:
id = logSetting.ChannelUpdatedId;
break;
case LogType.UserPresence:
id = logSetting.LogUserPresenceId;
break;
case LogType.VoicePresence:
id = logSetting.LogVoicePresenceId;
break;
case LogType.VoicePresenceTTS:
id = logSetting.LogVoicePresenceTTSId;
break;
default:
break;
}
var channel = guild.GetTextChannel(id);
if (!id.HasValue)
{
UnsetLogSetting(guild.Id, logChannelType);
return null;
}
var channel = guild.GetTextChannel(id.Value);
if (channel == null)
using (var uow = DbHandler.UnitOfWork())
{
var newLogSetting = uow.GuildConfigs.For(guild.Id).LogSetting;
switch (logChannelType)
{
case LogChannelType.Text:
logSetting.IsLogging = false;
break;
case LogChannelType.Voice:
logSetting.LogVoicePresence = false;
break;
case LogChannelType.UserPresence:
logSetting.LogUserPresence = false;
break;
}
GuildLogSettings.AddOrUpdate(guild.Id, newLogSetting, (gid, old) => newLogSetting);
uow.Complete();
UnsetLogSetting(guild.Id, logChannelType);
return null;
}
else
return channel;
}
private static void UnsetLogSetting(ulong guildId, LogType logChannelType)
{
using (var uow = DbHandler.UnitOfWork())
{
var newLogSetting = uow.GuildConfigs.For(guildId).LogSetting;
switch (logChannelType)
{
case LogType.Other:
break;
case LogType.MessageUpdated:
break;
case LogType.MessageDeleted:
break;
case LogType.UserJoined:
break;
case LogType.UserLeft:
break;
case LogType.UserBanned:
break;
case LogType.UserUnbanned:
break;
case LogType.UserUpdated:
break;
case LogType.ChannelCreated:
break;
case LogType.ChannelDestroyed:
break;
case LogType.ChannelUpdated:
break;
case LogType.UserPresence:
break;
case LogType.VoicePresence:
break;
case LogType.VoicePresenceTTS:
break;
default:
break;
}
GuildLogSettings.AddOrUpdate(guildId, newLogSetting, (gid, old) => newLogSetting);
uow.Complete();
}
}
public enum EnableDisable {
Enable,
Disable
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.Administrator)]
[OwnerOnly]
public async Task LogServer(IUserMessage msg)
public async Task LogServer(IUserMessage msg, PermissionAction action)
{
var channel = (ITextChannel)msg.Channel;
LogSetting logSetting;
@ -556,16 +605,25 @@ namespace NadekoBot.Modules.Administration
{
logSetting = uow.GuildConfigs.For(channel.Guild.Id).LogSetting;
GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
logSetting.IsLogging = !logSetting.IsLogging;
if (logSetting.IsLogging)
logSetting.ChannelId = channel.Id;
await uow.CompleteAsync();
logSetting.LogOtherId =
logSetting.MessageUpdatedId =
logSetting.MessageDeletedId =
logSetting.UserJoinedId =
logSetting.UserLeftId =
logSetting.UserBannedId =
logSetting.UserUnbannedId =
logSetting.UserUpdatedId =
logSetting.ChannelCreatedId =
logSetting.ChannelDestroyedId =
logSetting.ChannelUpdatedId =
logSetting.LogUserPresenceId =
logSetting.LogVoicePresenceId =
logSetting.LogVoicePresenceTTSId = (action.Value ? channel.Id : (ulong?)null);
}
if (logSetting.IsLogging)
await channel.SendMessageAsync("✅ **Logging enabled.**").ConfigureAwait(false);
if (action.Value)
await channel.SendMessageAsync("✅ Logging all events on this channel.").ConfigureAwait(false);
else
await channel.SendMessageAsync(" **Logging disabled.**").ConfigureAwait(false);
await channel.SendMessageAsync(" Logging disabled.").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
@ -597,146 +655,79 @@ namespace NadekoBot.Modules.Administration
await channel.SendMessageAsync($" Logging will **no longer ignore** #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false);
}
//[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
//[RequireContext(ContextType.Guild)]
//[OwnerOnly]
//public async Task LogAdd(IUserMessage msg, [Remainder] string eventName)
//{
// var channel = (ITextChannel)msg.Channel;
// //eventName = eventName?.Replace(" ","").ToLowerInvariant();
// switch (eventName.ToLowerInvariant())
// {
// case "messageupdated":
// case "messagedeleted":
// case "userjoined":
// case "userleft":
// case "userbanned":
// case "userunbanned":
// case "channelcreated":
// case "channeldestroyed":
// case "channelupdated":
// using (var uow = DbHandler.UnitOfWork())
// {
// var logSetting = uow.GuildConfigs.For(channel.Guild.Id).LogSetting;
// GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
// var prop = logSetting.GetType().GetProperty(eventName);
// prop.SetValue(logSetting, true);
// await uow.CompleteAsync().ConfigureAwait(false);
// }
// await channel.SendMessageAsync($"`Now logging {eventName} event.`").ConfigureAwait(false);
// break;
// default:
// await channel.SendMessageAsync($"`Event \"{eventName}\" not found.`").ConfigureAwait(false);
// break;
// }
//}
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
//[RequireContext(ContextType.Guild)]
//public async Task LogRemove(IUserMessage msg, string eventName)
//{
// var channel = (ITextChannel)msg.Channel;
// eventName = eventName.ToLowerInvariant();
// switch (eventName)
// {
// case "messagereceived":
// case "messageupdated":
// case "messagedeleted":
// case "userjoined":
// case "userleft":
// case "userbanned":
// case "userunbanned":
// case "channelcreated":
// case "channeldestroyed":
// case "channelupdated":
// using (var uow = DbHandler.UnitOfWork())
// {
// var config = uow.GuildConfigs.For(channel.Guild.Id);
// LogSetting logSetting = GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting);
// logSetting.GetType().GetProperty(eventName).SetValue(logSetting, false);
// config.LogSetting = logSetting;
// await uow.CompleteAsync().ConfigureAwait(false);
// }
// await channel.SendMessageAsync($"`No longer logging {eventName} event.`").ConfigureAwait(false);
// break;
// default:
// await channel.SendMessageAsync($"`Event \"{eventName}\" not found.`").ConfigureAwait(false);
// break;
// }
//}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.Administrator)]
public async Task LogEvents(IUserMessage imsg)
{
await imsg.Channel.SendConfirmAsync("Log events you can subscribe to:", String.Join(", ", Enum.GetValues(typeof(LogType)).Cast<string>()));
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.Administrator)]
public async Task UserPresence(IUserMessage imsg)
public async Task Log(IUserMessage imsg, LogType type)
{
var channel = (ITextChannel)imsg.Channel;
bool enabled;
ulong? channelId = null;
using (var uow = DbHandler.UnitOfWork())
{
var logSetting = uow.GuildConfigs.For(channel.Guild.Id).LogSetting;
GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
enabled = logSetting.LogUserPresence = !logSetting.LogUserPresence;
if(enabled)
logSetting.UserPresenceChannelId = channel.Id;
switch (type)
{
case LogType.Other:
channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? channel.Id : default(ulong?));
break;
case LogType.MessageUpdated:
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? channel.Id : default(ulong?));
break;
case LogType.MessageDeleted:
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? channel.Id : default(ulong?));
break;
case LogType.UserJoined:
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? channel.Id : default(ulong?));
break;
case LogType.UserLeft:
channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? channel.Id : default(ulong?));
break;
case LogType.UserBanned:
channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? channel.Id : default(ulong?));
break;
case LogType.UserUnbanned:
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? channel.Id : default(ulong?));
break;
case LogType.UserUpdated:
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? channel.Id : default(ulong?));
break;
case LogType.ChannelCreated:
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? channel.Id : default(ulong?));
break;
case LogType.ChannelDestroyed:
channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? channel.Id : default(ulong?));
break;
case LogType.ChannelUpdated:
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? channel.Id : default(ulong?));
break;
case LogType.UserPresence:
channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? channel.Id : default(ulong?));
break;
case LogType.VoicePresence:
channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? channel.Id : default(ulong?));
break;
case LogType.VoicePresenceTTS:
channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? channel.Id : default(ulong?));
break;
}
await uow.CompleteAsync().ConfigureAwait(false);
}
if (enabled)
await channel.SendMessageAsync($"✅ Logging **user presence** updates in #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false);
if (channelId != null)
await channel.SendMessageAsync($"✅ Logging `{type}` event in #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false);
else
await channel.SendMessageAsync($" Stopped logging **user presence** updates.").ConfigureAwait(false);
await channel.SendMessageAsync($" Stopped logging `{type}` event.").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.Administrator)]
public async Task VoicePresence(IUserMessage imsg)
{
var channel = (ITextChannel)imsg.Channel;
bool enabled;
using (var uow = DbHandler.UnitOfWork())
{
var logSetting = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.LogSetting)
.ThenInclude(ls => ls.IgnoredVoicePresenceChannelIds))
.LogSetting;
GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
enabled = logSetting.LogVoicePresence = !logSetting.LogVoicePresence;
if (enabled)
logSetting.VoicePresenceChannelId = channel.Id;
await uow.CompleteAsync().ConfigureAwait(false);
}
if (enabled)
await channel.SendMessageAsync($"✅ Logging **voice presence** updates in #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false);
else
await channel.SendMessageAsync($" Stopped logging **voice presence** updates.").ConfigureAwait(false);
}
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
//[RequireContext(ContextType.Guild)]
//public async Task VoiPresIgnore(IUserMessage imsg, IVoiceChannel voiceChannel)
//{
// var channel = (ITextChannel)imsg.Channel;
// int removed;
// using (var uow = DbHandler.UnitOfWork())
// {
// var config = uow.GuildConfigs.For(channel.Guild.Id);
// LogSetting logSetting = GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting);
// removed = logSetting.IgnoredVoicePresenceChannelIds.RemoveWhere(ivpc => ivpc.ChannelId == voiceChannel.Id);
// if (removed == 0)
// logSetting.IgnoredVoicePresenceChannelIds.Add(new IgnoredVoicePresenceChannel { ChannelId = voiceChannel.Id });
// config.LogSetting = logSetting;
// await uow.CompleteAsync().ConfigureAwait(false);
// }
// if (removed == 0)
// await channel.SendMessageAsync($"`Enabled logging voice presence updates for {voiceChannel.Name} ({voiceChannel.Id}) channel.`").ConfigureAwait(false);
// else
// await channel.SendMessageAsync($"`Disabled logging voice presence updates for {voiceChannel.Name} ({voiceChannel.Id}) channel.`").ConfigureAwait(false);
//}
}
}
}

View File

@ -195,12 +195,9 @@ namespace NadekoBot.Modules.Administration
guildConfig.GenerateCurrencyChannelIds = new HashSet<GCChannelId>(data.GenerateCurrencyChannels.Select(gc => new GCChannelId() { ChannelId = gc.Key }));
selfAssRoles.AddRange(data.ListOfSelfAssignableRoles.Select(r => new SelfAssignedRole() { GuildId = guildConfig.GuildId, RoleId = r }).ToArray());
var logSetting = guildConfig.LogSetting;
guildConfig.LogSetting.IsLogging = data.LogChannel != null;
guildConfig.LogSetting.ChannelId = data.LogChannel ?? 0;
guildConfig.LogSetting.IgnoredChannels = new HashSet<IgnoredLogChannel>(data.LogserverIgnoreChannels.Select(id => new IgnoredLogChannel() { ChannelId = id }));
guildConfig.LogSetting.LogUserPresence = data.LogPresenceChannel != null;
guildConfig.LogSetting.UserPresenceChannelId = data.LogPresenceChannel ?? 0;
guildConfig.LogSetting.LogUserPresenceId = data.LogPresenceChannel;
guildConfig.FollowedStreams = new HashSet<FollowedStream>(data.ObservingStreams.Select(x =>

View File

@ -3785,6 +3785,60 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to log.
/// </summary>
public static string log_cmd {
get {
return ResourceManager.GetString("log_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Toggles logging event. Disables it if it&apos;s active anywhere on the server. Enables if it&apos;s not active. Use `{0}logevents` to see a lit of all events you can subscribe to..
/// </summary>
public static string log_desc {
get {
return ResourceManager.GetString("log_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}log userpresence` or `{0}log userbanned`.
/// </summary>
public static string log_usage {
get {
return ResourceManager.GetString("log_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to logevents.
/// </summary>
public static string logevents_cmd {
get {
return ResourceManager.GetString("logevents_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Shows a list of all events you can subscribe to with `{0}log`.
/// </summary>
public static string logevents_desc {
get {
return ResourceManager.GetString("logevents_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}logevents`.
/// </summary>
public static string logevents_usage {
get {
return ResourceManager.GetString("logevents_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to logignore.
/// </summary>
@ -3822,7 +3876,7 @@ namespace NadekoBot.Resources {
}
/// <summary>
/// Looks up a localized string similar to Logs server activity in this channel..
/// Looks up a localized string similar to Enables or Disables ALL log events. If enabled, all log events will log to this channel..
/// </summary>
public static string logserver_desc {
get {
@ -3831,7 +3885,7 @@ namespace NadekoBot.Resources {
}
/// <summary>
/// Looks up a localized string similar to `{0}logserver`.
/// Looks up a localized string similar to `{0}logserver enable` or `{0}logserver disable`.
/// </summary>
public static string logserver_usage {
get {

View File

@ -229,10 +229,10 @@
<value>logserver</value>
</data>
<data name="logserver_desc" xml:space="preserve">
<value>Logs server activity in this channel.</value>
<value>Enables or Disables ALL log events. If enabled, all log events will log to this channel.</value>
</data>
<data name="logserver_usage" xml:space="preserve">
<value>`{0}logserver`</value>
<value>`{0}logserver enable` or `{0}logserver disable`</value>
</data>
<data name="logignore_cmd" xml:space="preserve">
<value>logignore</value>
@ -2745,4 +2745,22 @@
<data name="type_usage" xml:space="preserve">
<value>`{0}type @someone`</value>
</data>
<data name="logevents_cmd" xml:space="preserve">
<value>logevents</value>
</data>
<data name="logevents_desc" xml:space="preserve">
<value>Shows a list of all events you can subscribe to with `{0}log`</value>
</data>
<data name="logevents_usage" xml:space="preserve">
<value>`{0}logevents`</value>
</data>
<data name="log_cmd" xml:space="preserve">
<value>log</value>
</data>
<data name="log_desc" xml:space="preserve">
<value>Toggles logging event. Disables it if it's active anywhere on the server. Enables if it's not active. Use `{0}logevents` to see a lit of all events you can subscribe to.</value>
</data>
<data name="log_usage" xml:space="preserve">
<value>`{0}log userpresence` or `{0}log userbanned`</value>
</data>
</root>

View File

@ -1,4 +1,6 @@
namespace NadekoBot.Services.Database.Models
using System.ComponentModel.DataAnnotations.Schema;
namespace NadekoBot.Services.Database.Models
{
public class IgnoredLogChannel : DbEntity
{

View File

@ -4,31 +4,28 @@ namespace NadekoBot.Services.Database.Models
{
public class LogSetting : DbEntity
{
public bool IsLogging { get; set; }
public ulong ChannelId { get; set; }
public HashSet<IgnoredLogChannel> IgnoredChannels { get; set; }
public bool MessageUpdated { get; set; } = true;
public bool MessageDeleted { get; set; } = true;
public ulong? LogOtherId { get; set; } = null;
public ulong? MessageUpdatedId { get; set; } = null;
public ulong? MessageDeletedId { get; set; } = null;
public bool UserJoined { get; set; } = true;
public bool UserLeft { get; set; } = true;
public bool UserBanned { get; set; } = true;
public bool UserUnbanned { get; set; } = true;
public bool UserUpdated { get; set; } = true;
public ulong? UserJoinedId { get; set; } = null;
public ulong? UserLeftId { get; set; } = null;
public ulong? UserBannedId { get; set; } = null;
public ulong? UserUnbannedId { get; set; } = null;
public ulong? UserUpdatedId { get; set; } = null;
public bool ChannelCreated { get; set; } = true;
public bool ChannelDestroyed { get; set; } = true;
public bool ChannelUpdated { get; set; } = true;
public ulong? ChannelCreatedId { get; set; } = null;
public ulong? ChannelDestroyedId { get; set; } = null;
public ulong? ChannelUpdatedId { get; set; } = null;
//userpresence
public bool LogUserPresence { get; set; } = false;
public ulong UserPresenceChannelId { get; set; }
public ulong? LogUserPresenceId { get; set; } = null;
//voicepresence
public bool LogVoicePresence { get; set; } = false;
public ulong VoicePresenceChannelId { get; set; }
public HashSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceChannelIds { get; set; }
public ulong? LogVoicePresenceId { get; set; } = null;
public ulong? LogVoicePresenceTTSId { get; set; } = null;
public HashSet<IgnoredLogChannel> IgnoredVoicePresenceChannels { get; set; }
}
}

View File

@ -44,11 +44,11 @@ namespace NadekoBot.Services.Database
this.Database.Migrate();
EnsureSeedData();
}
//Uncomment this to db initialisation with dotnet ef migration add [module]
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//{
// optionsBuilder.UseSqlite("Filename=./data/NadekoBot.db");
//}
////Uncomment this to db initialisation with dotnet ef migration add [module]
////protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
////{
//// optionsBuilder.UseSqlite("Filename=./data/NadekoBot.db");
////}
public void EnsureSeedData()
{
@ -231,6 +231,17 @@ namespace NadekoBot.Services.Database
.IsUnique();
#endregion
#region PokeGame
var ignoredLogChannel = modelBuilder.Entity<LogSetting>();
//ignoredLogChannel.HasMany(i => i.IgnoredChannels)
// .WithOne(ls => ls.LogSetting);
//ignoredLogChannel.HasMany(i => i.IgnoredVoicePresenceChannels)
// .WithOne(ls => ls.LogSetting);
#endregion
}
}

View File

@ -17,7 +17,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl
_set.Include(gc => gc.LogSetting)
.ThenInclude(ls => ls.IgnoredChannels)
.Include(gc => gc.LogSetting)
.ThenInclude(ls => ls.IgnoredVoicePresenceChannelIds)
.ThenInclude(ls => ls.IgnoredVoicePresenceChannels)
.Include(gc => gc.RootPermission)
.ThenInclude(gc => gc.Previous)
.Include(gc => gc.RootPermission)
@ -44,8 +44,6 @@ namespace NadekoBot.Services.Database.Repositories.Impl
.Include(gc => gc.FollowedStreams)
.Include(gc => gc.LogSetting)
.ThenInclude(ls => ls.IgnoredChannels)
.Include(gc => gc.LogSetting)
.ThenInclude(ls => ls.IgnoredVoicePresenceChannelIds)
.Include(gc => gc.FilterInvitesChannelIds)
.Include(gc => gc.FilterWordsChannelIds)
.Include(gc => gc.FilteredWords)

View File

@ -31,6 +31,7 @@
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0",
"Microsoft.Extensions.Configuration": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",