Initial split of the modules

This commit is contained in:
Master Kwoth
2017-09-30 00:46:33 +02:00
parent cdc2c43913
commit 599245b1ca
499 changed files with 469 additions and 256 deletions

View File

@ -0,0 +1,51 @@
using System.Collections.Generic;
namespace NadekoBot.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; }
}
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 HashSet<AntiSpamIgnore> IgnoredChannels { get; set; } = new HashSet<AntiSpamIgnore>();
}
public enum PunishmentAction
{
Mute,
Kick,
Ban,
Softban
}
public class AntiSpamIgnore : DbEntity
{
public ulong ChannelId { get; set; }
public override int GetHashCode() => ChannelId.GetHashCode();
public override bool Equals(object obj)
{
var inst = obj as AntiSpamIgnore;
if (inst == null)
return false;
return inst.ChannelId == ChannelId;
}
}
}

View File

@ -0,0 +1,177 @@
using System.Collections.Generic;
namespace NadekoBot.Services.Database.Models
{
public class BotConfig : DbEntity
{
public HashSet<BlacklistItem> Blacklist { get; set; }
public ulong BufferSize { get; set; } = 4000000;
public bool ForwardMessages { get; set; } = true;
public bool ForwardToAllOwners { get; set; } = true;
public float CurrencyGenerationChance { get; set; } = 0.02f;
public int CurrencyGenerationCooldown { get; set; } = 10;
public HashSet<ModulePrefix> ModulePrefixes { get; set; } = new HashSet<ModulePrefix>();
public List<PlayingStatus> RotatingStatusMessages { get; set; } = new List<PlayingStatus>();
public bool RotatingStatuses { get; set; } = false;
public string RemindMessageFormat { get; set; } = "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗";
//currency
public string CurrencySign { get; set; } = "🌸";
public string CurrencyName { get; set; } = "Nadeko Flower";
public string CurrencyPluralName { get; set; } = "Nadeko Flowers";
public int TriviaCurrencyReward { get; set; } = 0;
public int MinimumBetAmount { get; set; } = 2;
public float BetflipMultiplier { get; set; } = 1.95f;
public int CurrencyDropAmount { get; set; } = 1;
public int? CurrencyDropAmountMax { get; set; } = null;
public float Betroll67Multiplier { get; set; } = 2;
public float Betroll91Multiplier { get; set; } = 4;
public float Betroll100Multiplier { get; set; } = 10;
//public HashSet<CommandCost> CommandCosts { get; set; } = new HashSet<CommandCost>();
/// <summary>
/// I messed up, don't use
/// </summary>
public HashSet<CommandPrice> CommandPrices { get; set; } = new HashSet<CommandPrice>();
public HashSet<EightBallResponse> EightBallResponses { get; set; } = new HashSet<EightBallResponse>();
public HashSet<RaceAnimal> RaceAnimals { get; set; } = new HashSet<RaceAnimal>();
public string DMHelpString { get; set; } = "Type `.h` for help.";
public string HelpString { get; set; } = @"To add me to your server, use this link -> <https://discordapp.com/oauth2/authorize?client_id={0}&scope=bot&permissions=66186303>
You can use `{1}modules` command to see a list of all modules.
You can use `{1}commands ModuleName`
(for example `{1}commands Administration`) to see a list of all of the commands in that module.
For a specific command help, use `{1}h CommandName` (for example {1}h {1}q)
**LIST OF COMMANDS CAN BE FOUND ON THIS LINK**
<http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
Nadeko Support Server: https://discord.gg/nadekobot";
public int MigrationVersion { get; set; }
public string OkColor { get; set; } = "71cd40";
public string ErrorColor { get; set; } = "ee281f";
public string Locale { get; set; } = null;
public List<StartupCommand> StartupCommands { get; set; }
public HashSet<BlockedCmdOrMdl> BlockedCommands { get; set; }
public HashSet<BlockedCmdOrMdl> BlockedModules { get; set; }
public int PermissionVersion { get; set; }
public string DefaultPrefix { get; set; } = ".";
public bool CustomReactionsStartWith { get; set; } = false;
public int XpPerMessage { get; set; } = 3;
public int XpMinutesTimeout { get; set; } = 5;
}
public class BlockedCmdOrMdl : DbEntity
{
public string Name { get; set; }
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
return ((BlockedCmdOrMdl)obj).Name.ToLowerInvariant() == Name.ToLowerInvariant();
}
public override int GetHashCode() => Name.GetHashCode();
}
public class StartupCommand : DbEntity, IIndexed
{
public int Index { get; set; }
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 class PlayingStatus :DbEntity
{
public string Status { get; set; }
}
public class BlacklistItem : DbEntity
{
public ulong ItemId { get; set; }
public BlacklistType Type { get; set; }
}
public enum BlacklistType
{
Server,
Channel,
User
}
public class EightBallResponse : DbEntity
{
public string Text { get; set; }
public override int GetHashCode()
{
return Text.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is EightBallResponse))
return base.Equals(obj);
return ((EightBallResponse)obj).Text == Text;
}
}
public class RaceAnimal : DbEntity
{
public string Icon { get; set; }
public string Name { get; set; }
public override int GetHashCode()
{
return Icon.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is RaceAnimal))
return base.Equals(obj);
return ((RaceAnimal)obj).Icon == Icon;
}
}
public class ModulePrefix : DbEntity
{
public string ModuleName { get; set; }
public string Prefix { get; set; }
public override int GetHashCode()
{
return ModuleName.GetHashCode();
}
public override bool Equals(object obj)
{
if(!(obj is ModulePrefix))
return base.Equals(obj);
return ((ModulePrefix)obj).ModuleName == ModuleName;
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace NadekoBot.Services.Database.Models
{
public class ClashCaller : DbEntity
{
public int? SequenceNumber { get; set; } = null;
public string CallUser { get; set; }
public DateTime TimeAdded { get; set; }
public bool BaseDestroyed { get; set; }
public int Stars { get; set; } = 3;
public int ClashWarId { get; set; }
[ForeignKey(nameof(ClashWarId))]
public ClashWar ClashWar { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using Discord;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace NadekoBot.Services.Database.Models
{
public class ClashWar : DbEntity
{
public string EnemyClan { get; set; }
public int Size { get; set; }
public StateOfWar WarState { get; set; } = StateOfWar.Created;
public DateTime StartedAt { get; set; }
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
[NotMapped]
public ITextChannel Channel { get; set; }
public List<ClashCaller> Bases { get; set; } = new List<ClashCaller>();
}
public enum DestroyStars
{
One, Two, Three
}
public enum StateOfWar
{
Started, Ended, Created
}
}

View File

@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace NadekoBot.Services.Database.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 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; }
}
}

View File

@ -0,0 +1,8 @@
namespace NadekoBot.Services.Database.Models
{
public class CommandCooldown : DbEntity
{
public int Seconds { get; set; }
public string CommandName { get; set; }
}
}

View File

@ -0,0 +1,21 @@
namespace NadekoBot.Services.Database.Models
{
public class CommandCost : DbEntity
{
public int Cost { get; set; }
public string CommandName { get; set; }
public override int GetHashCode() =>
CommandName.GetHashCode();
public override bool Equals(object obj)
{
var instance = obj as CommandCost;
if (instance == null)
return false;
return instance.CommandName == CommandName;
}
}
}

View File

@ -0,0 +1,9 @@
namespace NadekoBot.Services.Database.Models
{
public class CommandPrice : DbEntity
{
public int Price { get; set; }
//this is unique
public string CommandName { get; set; }
}
}

View File

@ -0,0 +1,47 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
namespace NadekoBot.Services.Database.Models
{
public class ConvertUnit : DbEntity
{
public ConvertUnit() { }
[NotMapped]
private string[] _triggersValue;
[NotMapped]
public string[] Triggers
{
get
{
return _triggersValue ?? (_triggersValue = InternalTrigger.Split('|'));
}
set
{
_triggersValue = value;
InternalTrigger = string.Join("|", _triggersValue);
}
}
//protected or private?
/// <summary>
/// DO NOT CALL THIS
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public string InternalTrigger { get; set; }
public string UnitType { get; set; }
public decimal Modifier { get; set; }
public override bool Equals(object obj)
{
var cu = obj as ConvertUnit;
if (cu == null)
return false;
return cu.UnitType == this.UnitType;
}
public override int GetHashCode()
{
return this.UnitType.GetHashCode();
}
}
}

View File

@ -0,0 +1,8 @@
namespace NadekoBot.Services.Database.Models
{
public class Currency : DbEntity
{
public ulong UserId { get; set; }
public long Amount { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace NadekoBot.Services.Database.Models
{
public class CurrencyTransaction : DbEntity
{
public long Amount { get; set; }
public string Reason { get; set; }
public ulong UserId { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.RegularExpressions;
namespace NadekoBot.Services.Database.Models
{
public class CustomReaction : DbEntity
{
public ulong? GuildId { get; set; }
[NotMapped]
[JsonIgnore]
public Regex Regex { get; set; }
public string Response { get; set; }
public string Trigger { get; set; }
public bool IsRegex { get; set; }
public bool OwnerOnly { get; set; }
public bool AutoDeleteTrigger { get; set; }
public bool DmResponse { get; set; }
[JsonIgnore]
public bool IsGlobal => !GuildId.HasValue;
public bool ContainsAnywhere { get; set; }
}
public class ReactionResponse : DbEntity
{
public bool OwnerOnly { get; set; }
public string Text { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace NadekoBot.Services.Database.Models
{
public class DbEntity
{
[Key]
public int Id { get; set; }
public DateTime? DateAdded { get; set; } = DateTime.UtcNow;
}
}

View File

@ -0,0 +1,35 @@
using System;
namespace NadekoBot.Services.Database.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 XpNotificationType NotifyOnLevelUp { 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;
}
}

View File

@ -0,0 +1,9 @@
namespace NadekoBot.Services.Database.Models
{
public class Donator : DbEntity
{
public ulong UserId { get; set; }
public string Name { get; set; }
public int Amount { get; set; } = 0;
}
}

View File

@ -0,0 +1,23 @@
namespace NadekoBot.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() ^ GuildConfigId.GetHashCode();
}
public override bool Equals(object obj)
{
return obj is FeedSub s
? s.Url == Url && s.GuildConfigId == GuildConfigId
: false;
}
}
}

View File

@ -0,0 +1,31 @@
namespace NadekoBot.Services.Database.Models
{
public class FollowedStream : DbEntity
{
public ulong ChannelId { get; set; }
public string Username { get; set; }
public FollowedStreamType Type { get; set; }
public ulong GuildId { get; set; }
public enum FollowedStreamType
{
Twitch, Smashcast, Mixer
}
public override int GetHashCode() =>
ChannelId.GetHashCode() ^
Username.GetHashCode() ^
Type.GetHashCode();
public override bool Equals(object obj)
{
var fs = obj as FollowedStream;
if (fs == null)
return false;
return fs.ChannelId == ChannelId &&
fs.Username.ToLowerInvariant().Trim() == Username.ToLowerInvariant().Trim() &&
fs.Type == Type;
}
}
}

View File

@ -0,0 +1,254 @@
using System;
using System.Collections.Generic;
namespace NadekoBot.Services.Database.Models
{
public class GuildConfig : DbEntity
{
public ulong GuildId { get; set; }
public string Prefix { get; set; } = null;
public bool DeleteMessageOnCommand { get; set; }
public ulong AutoAssignRoleId { 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; } = "Nadeko";
public HashSet<CommandCooldown> CommandCooldowns { get; set; } = new HashSet<CommandCooldown>();
//filtering
public bool FilterInvites { get; set; }
public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new HashSet<FilterChannelId>();
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 HashSet<GuildRepeater> GuildRepeaters { get; set; } = new HashSet<GuildRepeater>();
public AntiRaidSetting AntiRaidSetting { get; set; }
public AntiSpamSetting AntiSpamSetting { 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<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 List<ProtectionIgnoredChannel> ProtectionIgnoredChannels { get; set; } = new List<ProtectionIgnoredChannel>();
}
public class NsfwBlacklitedTag : DbEntity
{
public string Tag { get; set; }
public override int GetHashCode()
{
return Tag.GetHashCode();
}
public override bool Equals(object obj)
{
return obj is NsfwBlacklitedTag x
? x.Tag == Tag
: false;
}
}
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();
}
}
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();
}
}
public class WarningPunishment : DbEntity
{
public int Count { get; set; }
public PunishmentAction Punishment { get; set; }
public int Time { get; set; }
}
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();
//}
}
public class VcRoleInfo : DbEntity
{
public ulong VoiceChannelId { get; set; }
public ulong RoleId { get; set; }
}
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)
{
var ut = obj as UnmuteTimer;
if (ut == null)
return false;
return ut.UserId == UserId;
}
}
public class FilterChannelId : DbEntity
{
public ulong ChannelId { get; set; }
}
public class FilteredWord : DbEntity
{
public string Word { get; set; }
}
public class MutedUserId : DbEntity
{
public ulong UserId { get; set; }
public override int GetHashCode()
{
return UserId.GetHashCode();
}
public override bool Equals(object obj)
{
var mui = obj as MutedUserId;
if (mui == null)
return false;
return mui.UserId == this.UserId;
}
}
public class GCChannelId : DbEntity
{
public ulong ChannelId { get; set; }
public override bool Equals(object obj)
{
var gc = obj as GCChannelId;
if (gc == null)
return false;
return gc.ChannelId == this.ChannelId;
}
public override int GetHashCode() =>
this.ChannelId.GetHashCode();
}
}

View File

@ -0,0 +1,8 @@
namespace NadekoBot.Services.Database.Models
{
public class IgnoredLogChannel : DbEntity
{
public LogSetting LogSetting { get; set; }
public ulong ChannelId { get; set; }
}
}

View File

@ -0,0 +1,105 @@
using System.Collections.Generic;
namespace NadekoBot.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; }
}
}

View File

@ -0,0 +1,12 @@
using System.Collections.Generic;
namespace NadekoBot.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>();
}
}

View File

@ -0,0 +1,130 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
namespace NadekoBot.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,
};
//[NotMapped]
//private static Permission AllowAllPerm => new Permission()
//{
// PrimaryTarget = PrimaryPermissionType.Server,
// PrimaryTargetId = 0,
// SecondaryTarget = SecondaryPermissionType.AllModules,
// SecondaryTargetName = "*",
// State = true,
//};
//[NotMapped]
//private static Permission BlockNsfwPerm => new Permission()
//{
// PrimaryTarget = PrimaryPermissionType.Server,
// PrimaryTargetId = 0,
// SecondaryTarget = SecondaryPermissionType.Module,
// SecondaryTargetName = "nsfw",
// State = false,
//};
//public Permission Clone() => new Permission()
//{
// PrimaryTarget = PrimaryTarget,
// SecondaryTarget = SecondaryTarget,
// PrimaryTargetId = PrimaryTargetId,
// 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 State { get; set; }
[NotMapped]
public static Permissionv2 AllowAllPerm => new Permissionv2()
{
PrimaryTarget = PrimaryPermissionType.Server,
PrimaryTargetId = 0,
SecondaryTarget = SecondaryPermissionType.AllModules,
SecondaryTargetName = "*",
State = true,
Index = 0,
};
[NotMapped]
private static Permissionv2 BlockNsfwPerm => new Permissionv2()
{
PrimaryTarget = PrimaryPermissionType.Server,
PrimaryTargetId = 0,
SecondaryTarget = SecondaryPermissionType.Module,
SecondaryTargetName = "nsfw",
State = false,
Index = 1
};
public static List<Permissionv2> GetDefaultPermlist =>
new List<Permissionv2>
{
BlockNsfwPerm,
AllowAllPerm
};
//public Permission Clone() => new Permission()
//{
// PrimaryTarget = PrimaryTarget,
// SecondaryTarget = SecondaryTarget,
// PrimaryTargetId = PrimaryTargetId,
// SecondaryTargetName = SecondaryTargetName,
// State = State,
//};
}
public enum PrimaryPermissionType
{
User,
Channel,
Role,
Server
}
public enum SecondaryPermissionType
{
Module,
Command,
AllModules
}
}

View File

@ -0,0 +1,19 @@
namespace NadekoBot.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
}
}

View File

@ -0,0 +1,8 @@
namespace NadekoBot.Services.Database.Models
{
public class UserPokeTypes : DbEntity
{
public ulong UserId { get; set; }
public string type { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace NadekoBot.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; }
}
}

View File

@ -0,0 +1,14 @@
using System;
namespace NadekoBot.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; }
}
}

View File

@ -0,0 +1,18 @@
using System;
namespace NadekoBot.Services.Database.Models
{
public class Repeater : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public string Message { get; set; }
public TimeSpan Interval { get; set; }
public TimeSpan? StartTimeOfDay { get; set; }
}
public class GuildRepeater : Repeater
{
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace NadekoBot.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; }
}
}

View File

@ -0,0 +1,8 @@
namespace NadekoBot.Services.Database.Models
{
public class SelfAssignedRole : DbEntity
{
public ulong GuildId { get; set; }
public ulong RoleId { get; set; }
}
}

View File

@ -0,0 +1,45 @@
using System.Collections.Generic;
namespace NadekoBot.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();
}
}

View File

@ -0,0 +1,83 @@
using System.Collections.Generic;
namespace NadekoBot.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)
{
var x = obj as StreamRoleBlacklistedUser;
if (x == null)
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)
{
var x = obj as StreamRoleWhitelistedUser;
if (x == null)
return false;
return x.UserId == UserId;
}
public override int GetHashCode()
{
return UserId.GetHashCode();
}
}
}

View File

@ -0,0 +1,16 @@
using System;
namespace NadekoBot.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 XpNotificationType NotifyOnLevelUp { get; set; }
public DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
}
public enum XpNotificationType { None, Dm, Channel }
}

View File

@ -0,0 +1,8 @@
namespace NadekoBot.Services.Database.Models
{
public class IgnoredVoicePresenceChannel : DbEntity
{
public LogSetting LogSetting { get; set; }
public ulong ChannelId { get; set; }
}
}

View File

@ -0,0 +1,46 @@
using NadekoBot.Extensions;
using System.Collections.Generic;
namespace NadekoBot.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 (Claimer != 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}";
}
}
}

View File

@ -0,0 +1,87 @@
using System;
namespace NadekoBot.Services.Database.Models
{
public class WaifuItem : DbEntity
{
public string ItemEmoji { get; set; }
public int Price { get; set; }
public ItemName Item { get; set; }
public enum ItemName
{
Cookie,
Rose,
LoveLetter,
Chocolate,
Rice,
MovieTicket,
Book,
Lipstick,
Laptop,
Violin,
Ring,
Helicopter,
}
public WaifuItem()
{
}
public WaifuItem(string itemEmoji, int price, ItemName item)
{
ItemEmoji = itemEmoji;
Price = price;
Item = item;
}
public static WaifuItem GetItem(ItemName itemName)
{
switch (itemName)
{
case ItemName.Cookie:
return new WaifuItem("🍪", 10, itemName);
case ItemName.Rose:
return new WaifuItem("🌹", 50, itemName);
case ItemName.LoveLetter:
return new WaifuItem("💌", 100, itemName);
case ItemName.Chocolate:
return new WaifuItem("🍫", 200, itemName);
case ItemName.Rice:
return new WaifuItem("🍚", 400, itemName);
case ItemName.MovieTicket:
return new WaifuItem("🎟", 800, itemName);
case ItemName.Book:
return new WaifuItem("📔", 1500, itemName);
case ItemName.Lipstick:
return new WaifuItem("💄", 3000, itemName);
case ItemName.Laptop:
return new WaifuItem("💻", 5000, itemName);
case ItemName.Violin:
return new WaifuItem("🎻", 7500, itemName);
case ItemName.Ring:
return new WaifuItem("💍", 10000, itemName);
case ItemName.Helicopter:
return new WaifuItem("🚁", 20000, itemName);
default:
throw new ArgumentException(nameof(itemName));
}
}
}
}
/*
🍪 Cookie 10
🌹 Rose 50
💌 Love Letter 100
🍫 Chocolate 200
🍚 Rice 400
🎟 Movie Ticket 800
📔 Book 1.5k
💄 Lipstick 3k
💻 Laptop 5k
🎻 Violin 7.5k
💍 Ring 10k
*/

View File

@ -0,0 +1,21 @@
namespace NadekoBot.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
}
}

View File

@ -0,0 +1,12 @@
namespace NadekoBot.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; }
}
}

View File

@ -0,0 +1,53 @@
using System.Collections.Generic;
namespace NadekoBot.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 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; }
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 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;
}
}
}