mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
- Database namespace is now NadekoBot.Db
- Db related code is now in src/NadekoBot/Db - Finished major part of the db refactor, but many optimizations are left to be made
This commit is contained in:
68
src/NadekoBot/Db/Models/AntiProtection.cs
Normal file
68
src/NadekoBot/Db/Models/AntiProtection.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class AntiRaidSetting : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public int UserThreshold { get; set; }
|
||||
public int Seconds { get; set; }
|
||||
public PunishmentAction Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Duration of the punishment, in minutes. This works only for supported Actions, like:
|
||||
/// Mute, Chatmute, Voicemute, etc...
|
||||
/// </summary>
|
||||
public int PunishDuration { get; set; }
|
||||
}
|
||||
|
||||
public class AntiSpamSetting : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public PunishmentAction Action { get; set; }
|
||||
public int MessageThreshold { get; set; } = 3;
|
||||
public int MuteTime { get; set; } = 0;
|
||||
public ulong? RoleId { get; set; }
|
||||
public HashSet<AntiSpamIgnore> IgnoredChannels { get; set; } = new HashSet<AntiSpamIgnore>();
|
||||
}
|
||||
|
||||
public class AntiAltSetting
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int GuildConfigId { get; set; }
|
||||
public TimeSpan MinAge { get; set; }
|
||||
public PunishmentAction Action { get; set; }
|
||||
public int ActionDurationMinutes { get; set; }
|
||||
public ulong? RoleId { get; set; }
|
||||
}
|
||||
|
||||
public enum PunishmentAction
|
||||
{
|
||||
Mute,
|
||||
Kick,
|
||||
Ban,
|
||||
Softban,
|
||||
RemoveRoles,
|
||||
ChatMute,
|
||||
VoiceMute,
|
||||
AddRole
|
||||
}
|
||||
|
||||
public class AntiSpamIgnore : DbEntity
|
||||
{
|
||||
public ulong ChannelId { get; set; }
|
||||
|
||||
public override int GetHashCode() => ChannelId.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is AntiSpamIgnore inst
|
||||
? inst.ChannelId == ChannelId
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
14
src/NadekoBot/Db/Models/AutoCommand.cs
Normal file
14
src/NadekoBot/Db/Models/AutoCommand.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class AutoCommand : DbEntity
|
||||
{
|
||||
public string CommandText { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public string ChannelName { get; set; }
|
||||
public ulong? GuildId { get; set; }
|
||||
public string GuildName { get; set; }
|
||||
public ulong? VoiceChannelId {get; set; }
|
||||
public string VoiceChannelName { get; set; }
|
||||
public int Interval { get; set; }
|
||||
}
|
||||
}
|
8
src/NadekoBot/Db/Models/BanTemplate.cs
Normal file
8
src/NadekoBot/Db/Models/BanTemplate.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class BanTemplate : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
18
src/NadekoBot/Db/Models/BlacklistEntry.cs
Normal file
18
src/NadekoBot/Db/Models/BlacklistEntry.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class BlacklistEntry : DbEntity
|
||||
{
|
||||
public ulong ItemId { get; set; }
|
||||
public BlacklistType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum BlacklistType
|
||||
{
|
||||
Server,
|
||||
Channel,
|
||||
User
|
||||
}
|
||||
}
|
49
src/NadekoBot/Db/Models/ClubInfo.cs
Normal file
49
src/NadekoBot/Db/Models/ClubInfo.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using NadekoBot.Core.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Db.Models
|
||||
{
|
||||
public class ClubInfo : DbEntity
|
||||
{
|
||||
[MaxLength(20)]
|
||||
public string Name { get; set; }
|
||||
public int Discrim { get; set; }
|
||||
|
||||
public string ImageUrl { get; set; } = "";
|
||||
public int MinimumLevelReq { get; set; } = 5;
|
||||
public int Xp { get; set; } = 0;
|
||||
|
||||
public int OwnerId { get; set; }
|
||||
public DiscordUser Owner { get; set; }
|
||||
|
||||
public List<DiscordUser> Users { get; set; } = new List<DiscordUser>();
|
||||
|
||||
public List<ClubApplicants> Applicants { get; set; } = new List<ClubApplicants>();
|
||||
public List<ClubBans> Bans { get; set; } = new List<ClubBans>();
|
||||
public string Description { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name + "#" + Discrim;
|
||||
}
|
||||
}
|
||||
|
||||
public class ClubApplicants
|
||||
{
|
||||
public int ClubId { get; set; }
|
||||
public ClubInfo Club { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public DiscordUser User { get; set; }
|
||||
}
|
||||
|
||||
public class ClubBans
|
||||
{
|
||||
public int ClubId { get; set; }
|
||||
public ClubInfo Club { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public DiscordUser User { get; set; }
|
||||
}
|
||||
}
|
25
src/NadekoBot/Db/Models/CommandAlias.cs
Normal file
25
src/NadekoBot/Db/Models/CommandAlias.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class CommandAlias : DbEntity
|
||||
{
|
||||
public string Trigger { get; set; }
|
||||
public string Mapping { get; set; }
|
||||
|
||||
//// override object.Equals
|
||||
//public override bool Equals(object obj)
|
||||
//{
|
||||
// if (obj == null || GetType() != obj.GetType())
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return ((CommandAlias)obj).Trigger.Trim().ToLowerInvariant() == Trigger.Trim().ToLowerInvariant();
|
||||
//}
|
||||
|
||||
//// override object.GetHashCode
|
||||
//public override int GetHashCode()
|
||||
//{
|
||||
// return Trigger.Trim().ToLowerInvariant().GetHashCode();
|
||||
//}
|
||||
}
|
||||
}
|
8
src/NadekoBot/Db/Models/CommandCooldown.cs
Normal file
8
src/NadekoBot/Db/Models/CommandCooldown.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class CommandCooldown : DbEntity
|
||||
{
|
||||
public int Seconds { get; set; }
|
||||
public string CommandName { get; set; }
|
||||
}
|
||||
}
|
16
src/NadekoBot/Db/Models/CurrencyTransaction.cs
Normal file
16
src/NadekoBot/Db/Models/CurrencyTransaction.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class CurrencyTransaction : DbEntity
|
||||
{
|
||||
public long Amount { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public ulong UserId { get; set; }
|
||||
|
||||
public CurrencyTransaction Clone() => new CurrencyTransaction
|
||||
{
|
||||
Amount = Amount,
|
||||
Reason = Reason,
|
||||
UserId = UserId,
|
||||
};
|
||||
}
|
||||
}
|
47
src/NadekoBot/Db/Models/CustomReaction.cs
Normal file
47
src/NadekoBot/Db/Models/CustomReaction.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class CustomReaction : DbEntity
|
||||
{
|
||||
#region Unused
|
||||
|
||||
[Obsolete]
|
||||
[NotMapped]
|
||||
public Regex Regex { get; set; }
|
||||
[Obsolete]
|
||||
public ulong UseCount { get; set; }
|
||||
[Obsolete]
|
||||
public bool IsRegex { get; set; }
|
||||
[Obsolete]
|
||||
public bool OwnerOnly { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public ulong? GuildId { get; set; }
|
||||
public string Response { get; set; }
|
||||
public string Trigger { get; set; }
|
||||
|
||||
public bool AutoDeleteTrigger { get; set; }
|
||||
public bool DmResponse { get; set; }
|
||||
public bool ContainsAnywhere { get; set; }
|
||||
public bool AllowTarget { get; set; }
|
||||
public string Reactions { get; set; }
|
||||
|
||||
public string[] GetReactions() =>
|
||||
string.IsNullOrWhiteSpace(Reactions)
|
||||
? Array.Empty<string>()
|
||||
: Reactions.Split("@@@");
|
||||
|
||||
public bool IsGlobal() => GuildId is null || GuildId == 0;
|
||||
}
|
||||
|
||||
public class ReactionResponse : DbEntity
|
||||
{
|
||||
public bool OwnerOnly { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
12
src/NadekoBot/Db/Models/DbEntity.cs
Normal file
12
src/NadekoBot/Db/Models/DbEntity.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class DbEntity
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public DateTime? DateAdded { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
}
|
19
src/NadekoBot/Db/Models/DelMsgOnCmdChannel.cs
Normal file
19
src/NadekoBot/Db/Models/DelMsgOnCmdChannel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class DelMsgOnCmdChannel : DbEntity
|
||||
{
|
||||
public ulong ChannelId { get; set; }
|
||||
public bool State { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ChannelId.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is DelMsgOnCmdChannel x
|
||||
&& x.ChannelId == ChannelId;
|
||||
}
|
||||
}
|
||||
}
|
12
src/NadekoBot/Db/Models/DiscordPemOverride.cs
Normal file
12
src/NadekoBot/Db/Models/DiscordPemOverride.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class DiscordPermOverride : DbEntity
|
||||
{
|
||||
public GuildPerm Perm { get; set; }
|
||||
|
||||
public ulong? GuildId { get; set; }
|
||||
public string Command { get; set; }
|
||||
}
|
||||
}
|
38
src/NadekoBot/Db/Models/DiscordUser.cs
Normal file
38
src/NadekoBot/Db/Models/DiscordUser.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using NadekoBot.Core.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Db.Models
|
||||
{
|
||||
public class DiscordUser : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Discriminator { get; set; }
|
||||
public string AvatarId { get; set; }
|
||||
|
||||
public ClubInfo Club { get; set; }
|
||||
public bool IsClubAdmin { get; set; }
|
||||
|
||||
public int TotalXp { get; set; }
|
||||
public DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
|
||||
public DateTime LastXpGain { get; set; } = DateTime.MinValue;
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
|
||||
public long CurrencyAmount { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is DiscordUser du
|
||||
? du.UserId == UserId
|
||||
: false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UserId.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
Username + "#" + Discriminator;
|
||||
}
|
||||
}
|
47
src/NadekoBot/Db/Models/Event.cs
Normal file
47
src/NadekoBot/Db/Models/Event.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class CurrencyEvent
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Reaction,
|
||||
GameStatus,
|
||||
//NotRaid,
|
||||
}
|
||||
|
||||
public ulong ServerId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public ulong MessageId { get; set; }
|
||||
public Type EventType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Amount of currency that the user will be rewarded.
|
||||
/// </summary>
|
||||
public long Amount { get; set; }
|
||||
/// <summary>
|
||||
/// Maximum amount of currency that can be handed out.
|
||||
/// </summary>
|
||||
public long PotSize { get; set; }
|
||||
public List<AwardedUser> AwardedUsers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used as extra data storage for events which need it.
|
||||
/// </summary>
|
||||
public ulong ExtraId { get; set; }
|
||||
/// <summary>
|
||||
/// May be used for some future event.
|
||||
/// </summary>
|
||||
public ulong ExtraId2 { get; set; }
|
||||
/// <summary>
|
||||
/// May be used for some future event.
|
||||
/// </summary>
|
||||
public string ExtraString { get; set; }
|
||||
}
|
||||
|
||||
public class AwardedUser
|
||||
{
|
||||
|
||||
}
|
||||
}
|
25
src/NadekoBot/Db/Models/FeedSub.cs
Normal file
25
src/NadekoBot/Db/Models/FeedSub.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class FeedSub : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public ulong ChannelId { get; set; }
|
||||
public string Url { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is FeedSub s
|
||||
&& s.Url.ToLower() == Url.ToLower()
|
||||
&& s.GuildConfigId == GuildConfigId;
|
||||
}
|
||||
}
|
||||
}
|
19
src/NadekoBot/Db/Models/FilterChannelId.cs
Normal file
19
src/NadekoBot/Db/Models/FilterChannelId.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class FilterChannelId : DbEntity
|
||||
{
|
||||
public ulong ChannelId { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is FilterChannelId f
|
||||
? f.ChannelId == ChannelId
|
||||
: false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ChannelId.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
19
src/NadekoBot/Db/Models/FilterLinksChannelId.cs
Normal file
19
src/NadekoBot/Db/Models/FilterLinksChannelId.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class FilterLinksChannelId : DbEntity
|
||||
{
|
||||
public ulong ChannelId { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is FilterLinksChannelId f
|
||||
? f.ChannelId == ChannelId
|
||||
: false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ChannelId.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
7
src/NadekoBot/Db/Models/FilteredWord.cs
Normal file
7
src/NadekoBot/Db/Models/FilteredWord.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class FilteredWord : DbEntity
|
||||
{
|
||||
public string Word { get; set; }
|
||||
}
|
||||
}
|
50
src/NadekoBot/Db/Models/FollowedStream.cs
Normal file
50
src/NadekoBot/Db/Models/FollowedStream.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using NadekoBot.Core.Services.Database.Models;
|
||||
using NadekoBot.Modules.Searches.Common;
|
||||
|
||||
namespace NadekoBot.Db.Models
|
||||
{
|
||||
public class FollowedStream : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public string Username { get; set; }
|
||||
public FType Type { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public enum FType
|
||||
{
|
||||
Twitch = 0,
|
||||
[Obsolete("No longer supported.")]
|
||||
Smashcast = 1,
|
||||
[Obsolete("No longer supported.")]
|
||||
Mixer = 2,
|
||||
Picarto = 3,
|
||||
Youtube = 4,
|
||||
Facebook = 5,
|
||||
}
|
||||
|
||||
protected bool Equals(FollowedStream other)
|
||||
{
|
||||
return ChannelId == other.ChannelId
|
||||
&& Username.Trim().ToUpperInvariant() == other.Username.Trim().ToUpperInvariant()
|
||||
&& Type == other.Type;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(ChannelId, Username, (int) Type);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((FollowedStream) obj);
|
||||
}
|
||||
|
||||
public StreamDataKey CreateKey() =>
|
||||
new StreamDataKey(Type, Username.ToLower());
|
||||
}
|
||||
}
|
18
src/NadekoBot/Db/Models/GCChannelId.cs
Normal file
18
src/NadekoBot/Db/Models/GCChannelId.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class GCChannelId : DbEntity
|
||||
{
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is GCChannelId gc
|
||||
? gc.ChannelId == ChannelId
|
||||
: false;
|
||||
}
|
||||
|
||||
public override int GetHashCode() =>
|
||||
this.ChannelId.GetHashCode();
|
||||
}
|
||||
}
|
11
src/NadekoBot/Db/Models/GroupName.cs
Normal file
11
src/NadekoBot/Db/Models/GroupName.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class GroupName : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public int Number { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
110
src/NadekoBot/Db/Models/GuildConfig.cs
Normal file
110
src/NadekoBot/Db/Models/GuildConfig.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using NadekoBot.Common.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class GuildConfig : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public string Prefix { get; set; } = null;
|
||||
|
||||
public bool DeleteMessageOnCommand { get; set; }
|
||||
public HashSet<DelMsgOnCmdChannel> DelMsgOnCmdChannels { get; set; } = new HashSet<DelMsgOnCmdChannel>();
|
||||
[Obsolete("Use autoassignroleids")]
|
||||
public ulong AutoAssignRoleId { get; set; }
|
||||
public string AutoAssignRoleIds { get; set; }
|
||||
//greet stuff
|
||||
public bool AutoDeleteGreetMessages { get; set; } //unused
|
||||
public bool AutoDeleteByeMessages { get; set; } // unused
|
||||
public int AutoDeleteGreetMessagesTimer { get; set; } = 30;
|
||||
public int AutoDeleteByeMessagesTimer { get; set; } = 30;
|
||||
|
||||
public ulong GreetMessageChannelId { get; set; }
|
||||
public ulong ByeMessageChannelId { get; set; }
|
||||
|
||||
public bool SendDmGreetMessage { get; set; }
|
||||
public string DmGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
||||
|
||||
public bool SendChannelGreetMessage { get; set; }
|
||||
public string ChannelGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
||||
|
||||
public bool SendChannelByeMessage { get; set; }
|
||||
public string ChannelByeMessageText { get; set; } = "%user% has left!";
|
||||
|
||||
public LogSetting LogSetting { get; set; } = new LogSetting();
|
||||
|
||||
//self assignable roles
|
||||
public bool ExclusiveSelfAssignedRoles { get; set; }
|
||||
public bool AutoDeleteSelfAssignedRoleMessages { get; set; }
|
||||
public float DefaultMusicVolume { get; set; } = 1.0f;
|
||||
public bool VoicePlusTextEnabled { get; set; }
|
||||
|
||||
//stream notifications
|
||||
public HashSet<FollowedStream> FollowedStreams { get; set; } = new HashSet<FollowedStream>();
|
||||
|
||||
//currencyGeneration
|
||||
public HashSet<GCChannelId> GenerateCurrencyChannelIds { get; set; } = new HashSet<GCChannelId>();
|
||||
|
||||
//permissions
|
||||
public Permission RootPermission { get; set; } = null;
|
||||
public List<Permissionv2> Permissions { get; set; }
|
||||
public bool VerbosePermissions { get; set; } = true;
|
||||
public string PermissionRole { get; set; } = null;
|
||||
|
||||
public HashSet<CommandCooldown> CommandCooldowns { get; set; } = new HashSet<CommandCooldown>();
|
||||
|
||||
//filtering
|
||||
public bool FilterInvites { get; set; }
|
||||
public bool FilterLinks { get; set; }
|
||||
public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new HashSet<FilterChannelId>();
|
||||
public HashSet<FilterLinksChannelId> FilterLinksChannelIds { get; set; } = new HashSet<FilterLinksChannelId>();
|
||||
|
||||
//public bool FilterLinks { get; set; }
|
||||
//public HashSet<FilterLinksChannelId> FilterLinksChannels { get; set; } = new HashSet<FilterLinksChannelId>();
|
||||
|
||||
public bool FilterWords { get; set; }
|
||||
public HashSet<FilteredWord> FilteredWords { get; set; } = new HashSet<FilteredWord>();
|
||||
public HashSet<FilterChannelId> FilterWordsChannelIds { get; set; } = new HashSet<FilterChannelId>();
|
||||
|
||||
public HashSet<MutedUserId> MutedUsers { get; set; } = new HashSet<MutedUserId>();
|
||||
|
||||
public string MuteRoleName { get; set; }
|
||||
public bool CleverbotEnabled { get; set; }
|
||||
|
||||
public AntiRaidSetting AntiRaidSetting { get; set; }
|
||||
public AntiSpamSetting AntiSpamSetting { get; set; }
|
||||
public AntiAltSetting AntiAltSetting { get; set; }
|
||||
|
||||
public string Locale { get; set; } = null;
|
||||
public string TimeZoneId { get; set; } = null;
|
||||
|
||||
public HashSet<UnmuteTimer> UnmuteTimers { get; set; } = new HashSet<UnmuteTimer>();
|
||||
public HashSet<UnbanTimer> UnbanTimer { get; set; } = new HashSet<UnbanTimer>();
|
||||
public HashSet<UnroleTimer> UnroleTimer { get; set; } = new HashSet<UnroleTimer>();
|
||||
public HashSet<VcRoleInfo> VcRoleInfos { get; set; }
|
||||
public HashSet<CommandAlias> CommandAliases { get; set; } = new HashSet<CommandAlias>();
|
||||
public List<WarningPunishment> WarnPunishments { get; set; } = new List<WarningPunishment>();
|
||||
public bool WarningsInitialized { get; set; }
|
||||
public HashSet<SlowmodeIgnoredUser> SlowmodeIgnoredUsers { get; set; }
|
||||
public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; }
|
||||
public HashSet<NsfwBlacklitedTag> NsfwBlacklistedTags { get; set; } = new HashSet<NsfwBlacklitedTag>();
|
||||
|
||||
public List<ShopEntry> ShopEntries { get; set; }
|
||||
public ulong? GameVoiceChannel { get; set; } = null;
|
||||
public bool VerboseErrors { get; set; } = false;
|
||||
|
||||
public StreamRoleSettings StreamRole { get; set; }
|
||||
|
||||
public XpSettings XpSettings { get; set; }
|
||||
public List<FeedSub> FeedSubs { get; set; } = new List<FeedSub>();
|
||||
public bool AutoDcFromVc { get; set; }
|
||||
public IndexedCollection<ReactionRoleMessage> ReactionRoleMessages { get; set; } = new IndexedCollection<ReactionRoleMessage>();
|
||||
public bool NotifyStreamOffline { get; set; }
|
||||
public List<GroupName> SelfAssignableRoleGroupNames { get; set; }
|
||||
public int WarnExpireHours { get; set; } = 0;
|
||||
public WarnExpireAction WarnExpireAction { get; set; } = WarnExpireAction.Clear;
|
||||
}
|
||||
}
|
8
src/NadekoBot/Db/Models/IgnoredLogChannel.cs
Normal file
8
src/NadekoBot/Db/Models/IgnoredLogChannel.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class IgnoredLogChannel : DbEntity
|
||||
{
|
||||
public LogSetting LogSetting { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
}
|
||||
}
|
8
src/NadekoBot/Db/Models/IgnoredVoicePresenceChannel.cs
Normal file
8
src/NadekoBot/Db/Models/IgnoredVoicePresenceChannel.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class IgnoredVoicePresenceChannel : DbEntity
|
||||
{
|
||||
public LogSetting LogSetting { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
}
|
||||
}
|
105
src/NadekoBot/Db/Models/LogSetting.cs
Normal file
105
src/NadekoBot/Db/Models/LogSetting.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
|
||||
public class LogSetting : DbEntity
|
||||
{
|
||||
public HashSet<IgnoredLogChannel> IgnoredChannels { get; set; } = new HashSet<IgnoredLogChannel>();
|
||||
public HashSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceChannelIds { get; set; } = new HashSet<IgnoredVoicePresenceChannel>();
|
||||
|
||||
public ulong? LogOtherId { get; set; } = null;
|
||||
public ulong? MessageUpdatedId { get; set; } = null;
|
||||
public ulong? MessageDeletedId { get; set; } = null;
|
||||
|
||||
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 ulong? ChannelCreatedId { get; set; } = null;
|
||||
public ulong? ChannelDestroyedId { get; set; } = null;
|
||||
public ulong? ChannelUpdatedId { get; set; } = null;
|
||||
|
||||
public ulong? UserMutedId { get; set; }
|
||||
|
||||
//userpresence
|
||||
public ulong? LogUserPresenceId { get; set; } = null;
|
||||
|
||||
//voicepresence
|
||||
|
||||
public ulong? LogVoicePresenceId { get; set; } = null;
|
||||
public ulong? LogVoicePresenceTTSId { get; set; } = null;
|
||||
|
||||
|
||||
|
||||
//-------------------DO NOT USE----------------
|
||||
// these old fields are here because sqlite doesn't support drop column operation
|
||||
// will be removed after bot moves to another database provider
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool IsLogging { get; set; }
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public ulong ChannelId { get; set; }
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool MessageUpdated { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool MessageDeleted { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool UserJoined { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool UserLeft { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool UserBanned { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool UserUnbanned { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool UserUpdated { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool ChannelCreated { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool ChannelDestroyed { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool ChannelUpdated { get; set; } = true;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool LogUserPresence { get; set; } = false;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public ulong UserPresenceChannelId { get; set; }
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public bool LogVoicePresence { get; set; } = false;
|
||||
/// <summary>
|
||||
/// DON'T USE
|
||||
/// </summary>
|
||||
public ulong VoicePresenceChannelId { get; set; }
|
||||
}
|
||||
}
|
12
src/NadekoBot/Db/Models/MusicPlaylist.cs
Normal file
12
src/NadekoBot/Db/Models/MusicPlaylist.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class MusicPlaylist : DbEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Author { get; set; }
|
||||
public ulong AuthorId { get; set; }
|
||||
public List<PlaylistSong> Songs { get; set; } = new List<PlaylistSong>();
|
||||
}
|
||||
}
|
56
src/NadekoBot/Db/Models/MusicSettings.cs
Normal file
56
src/NadekoBot/Db/Models/MusicSettings.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class MusicPlayerSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Auto generated Id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id of the guild
|
||||
/// </summary>
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Queue repeat type
|
||||
/// </summary>
|
||||
public PlayerRepeatType PlayerRepeat { get; set; } = PlayerRepeatType.Queue;
|
||||
|
||||
/// <summary>
|
||||
/// Channel id the bot will always try to send track related messages to
|
||||
/// </summary>
|
||||
public ulong? MusicChannelId { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Default volume player will be created with
|
||||
/// </summary>
|
||||
public int Volume { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the bot should auto disconnect from the voice channel once the queue is done
|
||||
/// This only has effect if
|
||||
/// </summary>
|
||||
public bool AutoDisconnect { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Selected quality preset for the music player
|
||||
/// </summary>
|
||||
public QualityPreset QualityPreset { get; set; }
|
||||
}
|
||||
|
||||
public enum QualityPreset
|
||||
{
|
||||
Highest,
|
||||
High,
|
||||
Medium,
|
||||
Low
|
||||
}
|
||||
|
||||
public enum PlayerRepeatType
|
||||
{
|
||||
None,
|
||||
Track,
|
||||
Queue
|
||||
}
|
||||
}
|
19
src/NadekoBot/Db/Models/MutedUserId.cs
Normal file
19
src/NadekoBot/Db/Models/MutedUserId.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class MutedUserId : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UserId.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is MutedUserId mui
|
||||
? mui.UserId == UserId
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
21
src/NadekoBot/Db/Models/NsfwBlacklitedTag.cs
Normal file
21
src/NadekoBot/Db/Models/NsfwBlacklitedTag.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class NsfwBlacklitedTag : DbEntity
|
||||
{
|
||||
public string Tag { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Tag.GetHashCode(StringComparison.InvariantCulture);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is NsfwBlacklitedTag x
|
||||
? x.Tag == Tag
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
85
src/NadekoBot/Db/Models/Permission.cs
Normal file
85
src/NadekoBot/Db/Models/Permission.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
[DebuggerDisplay("{global::NadekoBot.Modules.Permissions.PermissionExtensions.GetCommand(this)}", Target = typeof(Permission))]
|
||||
public class Permission : DbEntity
|
||||
{
|
||||
public Permission Previous { get; set; } = null;
|
||||
public Permission Next { get; set; } = null;
|
||||
|
||||
public PrimaryPermissionType PrimaryTarget { get; set; }
|
||||
public ulong PrimaryTargetId { get; set; }
|
||||
|
||||
public SecondaryPermissionType SecondaryTarget { get; set; }
|
||||
public string SecondaryTargetName { get; set; }
|
||||
|
||||
public bool State { get; set; }
|
||||
|
||||
public Permissionv2 Tov2() =>
|
||||
new Permissionv2()
|
||||
{
|
||||
PrimaryTarget = PrimaryTarget,
|
||||
PrimaryTargetId = PrimaryTargetId,
|
||||
SecondaryTarget = SecondaryTarget,
|
||||
SecondaryTargetName = SecondaryTargetName,
|
||||
State = State,
|
||||
};
|
||||
}
|
||||
|
||||
public interface IIndexed
|
||||
{
|
||||
int Index { get; set; }
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{PrimaryTarget}{SecondaryTarget} {SecondaryTargetName} {State} {PrimaryTargetId}")]
|
||||
public class Permissionv2 : DbEntity, IIndexed
|
||||
{
|
||||
public int? GuildConfigId { get; set; }
|
||||
public int Index { get; set; }
|
||||
|
||||
public PrimaryPermissionType PrimaryTarget { get; set; }
|
||||
public ulong PrimaryTargetId { get; set; }
|
||||
|
||||
public SecondaryPermissionType SecondaryTarget { get; set; }
|
||||
public string SecondaryTargetName { get; set; }
|
||||
|
||||
public bool IsCustomCommand { get; set; }
|
||||
|
||||
public bool State { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public static Permissionv2 AllowAllPerm => new Permissionv2()
|
||||
{
|
||||
PrimaryTarget = PrimaryPermissionType.Server,
|
||||
PrimaryTargetId = 0,
|
||||
SecondaryTarget = SecondaryPermissionType.AllModules,
|
||||
SecondaryTargetName = "*",
|
||||
State = true,
|
||||
Index = 0,
|
||||
};
|
||||
|
||||
public static List<Permissionv2> GetDefaultPermlist =>
|
||||
new List<Permissionv2>
|
||||
{
|
||||
AllowAllPerm
|
||||
};
|
||||
}
|
||||
|
||||
public enum PrimaryPermissionType
|
||||
{
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Server
|
||||
}
|
||||
|
||||
public enum SecondaryPermissionType
|
||||
{
|
||||
Module,
|
||||
Command,
|
||||
AllModules
|
||||
}
|
||||
}
|
12
src/NadekoBot/Db/Models/PlantedCurrency.cs
Normal file
12
src/NadekoBot/Db/Models/PlantedCurrency.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class PlantedCurrency : DbEntity
|
||||
{
|
||||
public long Amount { get; set; }
|
||||
public string Password { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public ulong UserId { get; set; }
|
||||
public ulong MessageId { get; set; }
|
||||
}
|
||||
}
|
19
src/NadekoBot/Db/Models/PlaylistSong.cs
Normal file
19
src/NadekoBot/Db/Models/PlaylistSong.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class PlaylistSong : DbEntity
|
||||
{
|
||||
public string Provider { get; set; }
|
||||
public MusicType ProviderType { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Uri { get; set; }
|
||||
public string Query { get; set; }
|
||||
}
|
||||
|
||||
public enum MusicType
|
||||
{
|
||||
Radio,
|
||||
YouTube,
|
||||
Local,
|
||||
Soundcloud
|
||||
}
|
||||
}
|
20
src/NadekoBot/Db/Models/Poll.cs
Normal file
20
src/NadekoBot/Db/Models/Poll.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using NadekoBot.Common.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class Poll : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public string Question { get; set; }
|
||||
public IndexedCollection<PollAnswer> Answers { get; set; }
|
||||
public HashSet<PollVote> Votes { get; set; } = new HashSet<PollVote>();
|
||||
}
|
||||
|
||||
public class PollAnswer : DbEntity, IIndexed
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
20
src/NadekoBot/Db/Models/PollVote.cs
Normal file
20
src/NadekoBot/Db/Models/PollVote.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class PollVote : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public int VoteIndex { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UserId.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is PollVote p
|
||||
? p.UserId == UserId
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
24
src/NadekoBot/Db/Models/Quote.cs
Normal file
24
src/NadekoBot/Db/Models/Quote.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class Quote : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
[Required]
|
||||
public string Keyword { get; set; }
|
||||
[Required]
|
||||
public string AuthorName { get; set; }
|
||||
public ulong AuthorId { get; set; }
|
||||
[Required]
|
||||
public string Text { get; set; }
|
||||
public ulong UseCount { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public enum OrderType
|
||||
{
|
||||
Id = -1,
|
||||
Keyword = -2
|
||||
}
|
||||
}
|
24
src/NadekoBot/Db/Models/ReactionRole.cs
Normal file
24
src/NadekoBot/Db/Models/ReactionRole.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class ReactionRoleMessage : DbEntity, IIndexed
|
||||
{
|
||||
public int Index { get; set; }
|
||||
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public ulong ChannelId { get; set; }
|
||||
public ulong MessageId { get; set; }
|
||||
|
||||
public List<ReactionRole> ReactionRoles { get; set; }
|
||||
public bool Exclusive { get; set; }
|
||||
}
|
||||
|
||||
public class ReactionRole : DbEntity
|
||||
{
|
||||
public string EmoteName { get; set; }
|
||||
public ulong RoleId { get; set; }
|
||||
}
|
||||
}
|
14
src/NadekoBot/Db/Models/Reminder.cs
Normal file
14
src/NadekoBot/Db/Models/Reminder.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class Reminder : DbEntity
|
||||
{
|
||||
public DateTime When { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public ulong ServerId { get; set; }
|
||||
public ulong UserId { get; set; }
|
||||
public string Message { get; set; }
|
||||
public bool IsPrivate { get; set; }
|
||||
}
|
||||
}
|
17
src/NadekoBot/Db/Models/Repeater.cs
Normal file
17
src/NadekoBot/Db/Models/Repeater.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class Repeater
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public ulong? LastMessageId { get; set; }
|
||||
public string Message { get; set; }
|
||||
public TimeSpan Interval { get; set; }
|
||||
public TimeSpan? StartTimeOfDay { get; set; }
|
||||
public bool NoRedundant { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
}
|
||||
}
|
12
src/NadekoBot/Db/Models/RewardedUser.cs
Normal file
12
src/NadekoBot/Db/Models/RewardedUser.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class RewardedUser : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public string PatreonUserId { get; set; }
|
||||
public int AmountRewardedThisMonth { get; set; }
|
||||
public DateTime LastReward { get; set; }
|
||||
}
|
||||
}
|
10
src/NadekoBot/Db/Models/RotatingPlayingStatus.cs
Normal file
10
src/NadekoBot/Db/Models/RotatingPlayingStatus.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class RotatingPlayingStatus : DbEntity
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public ActivityType Type { get; set; }
|
||||
}
|
||||
}
|
11
src/NadekoBot/Db/Models/SelfAssignableRole.cs
Normal file
11
src/NadekoBot/Db/Models/SelfAssignableRole.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class SelfAssignedRole : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong RoleId { get; set; }
|
||||
|
||||
public int Group { get; set; }
|
||||
public int LevelRequirement { get; set; }
|
||||
}
|
||||
}
|
46
src/NadekoBot/Db/Models/ShopEntry.cs
Normal file
46
src/NadekoBot/Db/Models/ShopEntry.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public enum ShopEntryType
|
||||
{
|
||||
Role,
|
||||
List,
|
||||
//Infinite_List,
|
||||
}
|
||||
|
||||
public class ShopEntry : DbEntity, IIndexed
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Price { get; set; }
|
||||
public string Name { get; set; }
|
||||
public ulong AuthorId { get; set; }
|
||||
|
||||
public ShopEntryType Type { get; set; }
|
||||
|
||||
//role
|
||||
public string RoleName { get; set; }
|
||||
public ulong RoleId { get; set; }
|
||||
|
||||
//list
|
||||
public HashSet<ShopEntryItem> Items { get; set; } = new HashSet<ShopEntryItem>();
|
||||
}
|
||||
|
||||
public class ShopEntryItem : DbEntity
|
||||
{
|
||||
public string Text { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ((ShopEntryItem)obj).Text == Text;
|
||||
}
|
||||
|
||||
public override int GetHashCode() =>
|
||||
Text.GetHashCode(StringComparison.InvariantCulture);
|
||||
}
|
||||
}
|
24
src/NadekoBot/Db/Models/SlowmodeIgnoredRole.cs
Normal file
24
src/NadekoBot/Db/Models/SlowmodeIgnoredRole.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class SlowmodeIgnoredRole : DbEntity
|
||||
{
|
||||
public ulong RoleId { get; set; }
|
||||
|
||||
// override object.Equals
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((SlowmodeIgnoredRole)obj).RoleId == RoleId;
|
||||
}
|
||||
|
||||
// override object.GetHashCode
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return RoleId.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
24
src/NadekoBot/Db/Models/SlowmodeIgnoredUser.cs
Normal file
24
src/NadekoBot/Db/Models/SlowmodeIgnoredUser.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class SlowmodeIgnoredUser : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
|
||||
// override object.Equals
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((SlowmodeIgnoredUser)obj).UserId == UserId;
|
||||
}
|
||||
|
||||
// override object.GetHashCode
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UserId.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
14
src/NadekoBot/Db/Models/Stake.cs
Normal file
14
src/NadekoBot/Db/Models/Stake.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set stakes for gambling games which don't reward right away -
|
||||
/// like blackjack. If the bot is restarted mid game, users will get their funds back
|
||||
/// when the bot is back up.
|
||||
/// </summary>
|
||||
public class Stake : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public long Amount { get; set; }
|
||||
public string Source { get; set; }
|
||||
}
|
||||
}
|
78
src/NadekoBot/Db/Models/StreamRoleSettings.cs
Normal file
78
src/NadekoBot/Db/Models/StreamRoleSettings.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class StreamRoleSettings : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the feature is enabled in the guild.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id of the role to give to the users in the role 'FromRole' when they start streaming
|
||||
/// </summary>
|
||||
public ulong AddRoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id of the role whose users are eligible to get the 'AddRole'
|
||||
/// </summary>
|
||||
public ulong FromRoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If set, feature will only apply to users who have this keyword in their streaming status.
|
||||
/// </summary>
|
||||
public string Keyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of whitelisted users' IDs. Whitelisted users don't require 'keyword' in
|
||||
/// order to get the stream role.
|
||||
/// </summary>
|
||||
public HashSet<StreamRoleWhitelistedUser> Whitelist { get; set; } = new HashSet<StreamRoleWhitelistedUser>();
|
||||
|
||||
/// <summary>
|
||||
/// A collection of blacklisted users' IDs. Blacklisted useres will never get the stream role.
|
||||
/// </summary>
|
||||
public HashSet<StreamRoleBlacklistedUser> Blacklist { get; set; } = new HashSet<StreamRoleBlacklistedUser>();
|
||||
}
|
||||
|
||||
public class StreamRoleBlacklistedUser : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public string Username { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is StreamRoleBlacklistedUser x))
|
||||
return false;
|
||||
|
||||
return x.UserId == UserId;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UserId.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class StreamRoleWhitelistedUser : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public string Username { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is StreamRoleWhitelistedUser x
|
||||
? x.UserId == UserId
|
||||
: false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UserId.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
20
src/NadekoBot/Db/Models/UnbanTimer.cs
Normal file
20
src/NadekoBot/Db/Models/UnbanTimer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class UnbanTimer : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public DateTime UnbanAt { get; set; }
|
||||
|
||||
public override int GetHashCode() =>
|
||||
UserId.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is UnbanTimer ut
|
||||
? ut.UserId == UserId
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
20
src/NadekoBot/Db/Models/UnmuteTimer.cs
Normal file
20
src/NadekoBot/Db/Models/UnmuteTimer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class UnmuteTimer : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public DateTime UnmuteAt { get; set; }
|
||||
|
||||
public override int GetHashCode() =>
|
||||
UserId.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is UnmuteTimer ut
|
||||
? ut.UserId == UserId
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
21
src/NadekoBot/Db/Models/UnroleTimer.cs
Normal file
21
src/NadekoBot/Db/Models/UnroleTimer.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class UnroleTimer : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public ulong RoleId { get; set; }
|
||||
public DateTime UnbanAt { get; set; }
|
||||
|
||||
public override int GetHashCode() =>
|
||||
UserId.GetHashCode() ^ RoleId.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is UnroleTimer ut
|
||||
? ut.UserId == UserId && ut.RoleId == RoleId
|
||||
: false;
|
||||
}
|
||||
}
|
||||
}
|
16
src/NadekoBot/Db/Models/UserXpStats.cs
Normal file
16
src/NadekoBot/Db/Models/UserXpStats.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class UserXpStats : DbEntity
|
||||
{
|
||||
public ulong UserId { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public int Xp { get; set; }
|
||||
public int AwardedXp { get; set; }
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
public DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public enum XpNotificationLocation { None, Dm, Channel }
|
||||
}
|
8
src/NadekoBot/Db/Models/VcRoleInfo.cs
Normal file
8
src/NadekoBot/Db/Models/VcRoleInfo.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class VcRoleInfo : DbEntity
|
||||
{
|
||||
public ulong VoiceChannelId { get; set; }
|
||||
public ulong RoleId { get; set; }
|
||||
}
|
||||
}
|
90
src/NadekoBot/Db/Models/Waifu.cs
Normal file
90
src/NadekoBot/Db/Models/Waifu.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using NadekoBot.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using NadekoBot.Modules.Gambling.Common;
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class WaifuInfo : DbEntity
|
||||
{
|
||||
public int WaifuId { get; set; }
|
||||
public DiscordUser Waifu { get; set; }
|
||||
|
||||
public int? ClaimerId { get; set; }
|
||||
public DiscordUser Claimer { get; set; }
|
||||
|
||||
public int? AffinityId { get; set; }
|
||||
public DiscordUser Affinity { get; set; }
|
||||
|
||||
public int Price { get; set; }
|
||||
public List<WaifuItem> Items { get; set; } = new List<WaifuItem>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var claimer = "no one";
|
||||
var status = "";
|
||||
|
||||
var waifuUsername = Waifu.Username.TrimTo(20);
|
||||
var claimerUsername = Claimer?.Username.TrimTo(20);
|
||||
|
||||
if (ClaimerId != null)
|
||||
{
|
||||
claimer = $"{ claimerUsername }#{Claimer.Discriminator}";
|
||||
}
|
||||
if (AffinityId == null)
|
||||
{
|
||||
status = $"... but {waifuUsername}'s heart is empty";
|
||||
}
|
||||
else if (AffinityId == ClaimerId)
|
||||
{
|
||||
status = $"... and {waifuUsername} likes {claimerUsername} too <3";
|
||||
}
|
||||
else
|
||||
{
|
||||
status = $"... but {waifuUsername}'s heart belongs to {Affinity.Username.TrimTo(20)}#{Affinity.Discriminator}";
|
||||
}
|
||||
return $"**{waifuUsername}#{Waifu.Discriminator}** - claimed by **{claimer}**\n\t{status}";
|
||||
}
|
||||
}
|
||||
|
||||
public class WaifuLbResult
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Discrim { get; set; }
|
||||
|
||||
public string Claimer { get; set; }
|
||||
public string ClaimerDiscrim { get; set; }
|
||||
|
||||
public string Affinity { get; set; }
|
||||
public string AffinityDiscrim { get; set; }
|
||||
|
||||
public int Price { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var claimer = "no one";
|
||||
var status = "";
|
||||
|
||||
var waifuUsername = Username.TrimTo(20);
|
||||
var claimerUsername = Claimer?.TrimTo(20);
|
||||
|
||||
if (Claimer != null)
|
||||
{
|
||||
claimer = $"{ claimerUsername }#{ClaimerDiscrim}";
|
||||
}
|
||||
if (Affinity == null)
|
||||
{
|
||||
status = $"... but {waifuUsername}'s heart is empty";
|
||||
}
|
||||
else if (Affinity + AffinityDiscrim == Claimer + ClaimerDiscrim)
|
||||
{
|
||||
status = $"... and {waifuUsername} likes {claimerUsername} too <3";
|
||||
}
|
||||
else
|
||||
{
|
||||
status = $"... but {waifuUsername}'s heart belongs to {Affinity.TrimTo(20)}#{AffinityDiscrim}";
|
||||
}
|
||||
return $"**{waifuUsername}#{Discrim}** - claimed by **{claimer}**\n\t{status}";
|
||||
}
|
||||
}
|
||||
}
|
17
src/NadekoBot/Db/Models/WaifuItem.cs
Normal file
17
src/NadekoBot/Db/Models/WaifuItem.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class WaifuItem : DbEntity
|
||||
{
|
||||
public int? WaifuInfoId { get; set; }
|
||||
public string ItemEmoji { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[Obsolete]
|
||||
public int Price { get; set; }
|
||||
[Obsolete]
|
||||
public int Item { get; set; }
|
||||
}
|
||||
}
|
23
src/NadekoBot/Db/Models/WaifuUpdate.cs
Normal file
23
src/NadekoBot/Db/Models/WaifuUpdate.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class WaifuUpdate : DbEntity
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public DiscordUser User { get; set; }
|
||||
public WaifuUpdateType UpdateType { get; set; }
|
||||
|
||||
public int? OldId { get; set; }
|
||||
public DiscordUser Old { get; set; }
|
||||
|
||||
public int? NewId { get; set; }
|
||||
public DiscordUser New { get; set; }
|
||||
}
|
||||
|
||||
public enum WaifuUpdateType
|
||||
{
|
||||
AffinityChanged,
|
||||
Claimed
|
||||
}
|
||||
}
|
8
src/NadekoBot/Db/Models/WarnExpireAction.cs
Normal file
8
src/NadekoBot/Db/Models/WarnExpireAction.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public enum WarnExpireAction
|
||||
{
|
||||
Clear,
|
||||
Delete
|
||||
}
|
||||
}
|
12
src/NadekoBot/Db/Models/Warning.cs
Normal file
12
src/NadekoBot/Db/Models/Warning.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class Warning : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong UserId { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public bool Forgiven { get; set; }
|
||||
public string ForgivenBy { get; set; }
|
||||
public string Moderator { get; set; }
|
||||
}
|
||||
}
|
10
src/NadekoBot/Db/Models/WarningPunishment.cs
Normal file
10
src/NadekoBot/Db/Models/WarningPunishment.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class WarningPunishment : DbEntity
|
||||
{
|
||||
public int Count { get; set; }
|
||||
public PunishmentAction Punishment { get; set; }
|
||||
public int Time { get; set; }
|
||||
public ulong? RoleId { get; set; }
|
||||
}
|
||||
}
|
78
src/NadekoBot/Db/Models/XpSettings.cs
Normal file
78
src/NadekoBot/Db/Models/XpSettings.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class XpSettings : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public HashSet<XpRoleReward> RoleRewards { get; set; } = new HashSet<XpRoleReward>();
|
||||
public HashSet<XpCurrencyReward> CurrencyRewards { get; set; } = new HashSet<XpCurrencyReward>();
|
||||
public bool XpRoleRewardExclusive { get; set; }
|
||||
public string NotifyMessage { get; set; } = "Congratulations {0}! You have reached level {1}!";
|
||||
public HashSet<ExcludedItem> ExclusionList { get; set; } = new HashSet<ExcludedItem>();
|
||||
public bool ServerExcluded { get; set; }
|
||||
}
|
||||
|
||||
public enum ExcludedItemType { Channel, Role }
|
||||
|
||||
public class XpRoleReward : DbEntity
|
||||
{
|
||||
public int XpSettingsId { get; set; }
|
||||
public XpSettings XpSettings { get; set; }
|
||||
|
||||
public int Level { get; set; }
|
||||
public ulong RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the role should be removed (true) or added (false)
|
||||
/// </summary>
|
||||
public bool Remove { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Level.GetHashCode() ^ XpSettingsId.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is XpRoleReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId;
|
||||
}
|
||||
}
|
||||
|
||||
public class XpCurrencyReward : DbEntity
|
||||
{
|
||||
public int XpSettingsId { get; set; }
|
||||
public XpSettings XpSettings { get; set; }
|
||||
|
||||
public int Level { get; set; }
|
||||
public int Amount { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Level.GetHashCode() ^ XpSettingsId.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is XpCurrencyReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId;
|
||||
}
|
||||
}
|
||||
|
||||
public class ExcludedItem : DbEntity
|
||||
{
|
||||
public ulong ItemId { get; set; }
|
||||
public ExcludedItemType ItemType { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ItemId.GetHashCode() ^ ItemType.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is ExcludedItem ei && ei.ItemId == ItemId && ei.ItemType == ItemType;
|
||||
}
|
||||
}
|
||||
}
|
9
src/NadekoBot/Db/Models/YtFollowedChannel.cs
Normal file
9
src/NadekoBot/Db/Models/YtFollowedChannel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace NadekoBot.Core.Services.Database.Models
|
||||
{
|
||||
public class YtFollowedChannel : DbEntity
|
||||
{
|
||||
public ulong ChannelId { get; set; }
|
||||
public string YtChannelId { get; set; }
|
||||
public string UploadMessage { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user