Refactor done
This commit is contained in:
19
NadekoBot/_Models/DataModels/AnnouncementModel.cs
Normal file
19
NadekoBot/_Models/DataModels/AnnouncementModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class Announcement : IDataModel
|
||||
{
|
||||
public long ServerId { get; set; } = 0;
|
||||
public bool Greet { get; set; } = false;
|
||||
public bool GreetPM { get; set; } = false;
|
||||
[JsonProperty("greetChannel")]
|
||||
public long GreetChannelId { get; set; } = 0;
|
||||
public string GreetText { get; set; } = "Welcome %user%!";
|
||||
public bool Bye { get; set; } = false;
|
||||
public bool ByePM { get; set; } = false;
|
||||
[JsonProperty("byeChannel")]
|
||||
public long ByeChannelId { get; set; } = 0;
|
||||
public string ByeText { get; set; } = "%user% has left the server.";
|
||||
}
|
||||
}
|
11
NadekoBot/_Models/DataModels/CommandModel.cs
Normal file
11
NadekoBot/_Models/DataModels/CommandModel.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Command : IDataModel {
|
||||
public long UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public long ServerId { get; set; }
|
||||
public string ServerName { get; set; }
|
||||
public long ChannelId { get; set; }
|
||||
public string ChannelName { get; set; }
|
||||
public string CommandName { get; set; }
|
||||
}
|
||||
}
|
7
NadekoBot/_Models/DataModels/CurrencyStateModel.cs
Normal file
7
NadekoBot/_Models/DataModels/CurrencyStateModel.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class CurrencyState : IDataModel {
|
||||
public long Value { get; set; }
|
||||
[SQLite.Unique]
|
||||
public long UserId { get; set; }
|
||||
}
|
||||
}
|
7
NadekoBot/_Models/DataModels/CurrencyTransactionModel.cs
Normal file
7
NadekoBot/_Models/DataModels/CurrencyTransactionModel.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class CurrencyTransaction : IDataModel {
|
||||
public string Reason { get; set; }
|
||||
public int Value { get; set; }
|
||||
public long UserId { get; set; }
|
||||
}
|
||||
}
|
7
NadekoBot/_Models/DataModels/Donator.cs
Normal file
7
NadekoBot/_Models/DataModels/Donator.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Donator : IDataModel {
|
||||
public long UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
}
|
14
NadekoBot/_Models/DataModels/IDataModel.cs
Normal file
14
NadekoBot/_Models/DataModels/IDataModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using SQLite;
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal abstract class IDataModel
|
||||
{
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int? Id { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("createdAt")]
|
||||
public DateTime DateAdded { get; set; } = DateTime.Now;
|
||||
public IDataModel() { }
|
||||
}
|
||||
}
|
9
NadekoBot/_Models/DataModels/MusicPlaylist.cs
Normal file
9
NadekoBot/_Models/DataModels/MusicPlaylist.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class MusicPlaylist : IDataModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public long CreatorId { get; set; }
|
||||
public string CreatorName { get; set; }
|
||||
}
|
||||
}
|
8
NadekoBot/_Models/DataModels/PlaylistSongInfo.cs
Normal file
8
NadekoBot/_Models/DataModels/PlaylistSongInfo.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class PlaylistSongInfo : IDataModel
|
||||
{
|
||||
public int PlaylistId { get; set; }
|
||||
public int SongInfoId { get; set; }
|
||||
}
|
||||
}
|
14
NadekoBot/_Models/DataModels/PokeTypes.cs
Normal file
14
NadekoBot/_Models/DataModels/PokeTypes.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
class UserPokeTypes : IDataModel
|
||||
{
|
||||
public long UserId { get; set; }
|
||||
public string type { get; set; }
|
||||
}
|
||||
}
|
14
NadekoBot/_Models/DataModels/Reminder.cs
Normal file
14
NadekoBot/_Models/DataModels/Reminder.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
class Reminder : IDataModel
|
||||
{
|
||||
public DateTime When { get; set; }
|
||||
public long ChannelId { get; set; }
|
||||
public long ServerId { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public string Message { get; set; }
|
||||
public bool IsPrivate { get; set; }
|
||||
}
|
||||
}
|
10
NadekoBot/_Models/DataModels/RequestModel.cs
Normal file
10
NadekoBot/_Models/DataModels/RequestModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Request : IDataModel {
|
||||
public string UserName { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public string ServerName { get; set; }
|
||||
public long ServerId { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("Request")]
|
||||
public string RequestText { get; set; }
|
||||
}
|
||||
}
|
14
NadekoBot/_Models/DataModels/SongInfo.cs
Normal file
14
NadekoBot/_Models/DataModels/SongInfo.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using SQLite;
|
||||
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class SongInfo : IDataModel
|
||||
{
|
||||
public string Provider { get; internal set; }
|
||||
public int ProviderType { get; internal set; }
|
||||
public string Title { get; internal set; }
|
||||
public string Uri { get; internal set; }
|
||||
[Unique]
|
||||
public string Query { get; internal set; }
|
||||
}
|
||||
}
|
10
NadekoBot/_Models/DataModels/StatsModel.cs
Normal file
10
NadekoBot/_Models/DataModels/StatsModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Stats : IDataModel {
|
||||
public int ConnectedServers { get; set; }
|
||||
public int OnlineUsers { get; set; }
|
||||
public TimeSpan Uptime { get; set; }
|
||||
public int RealOnlineUsers { get; set; }
|
||||
}
|
||||
}
|
5
NadekoBot/_Models/DataModels/TypingArticleModel.cs
Normal file
5
NadekoBot/_Models/DataModels/TypingArticleModel.cs
Normal file
@ -0,0 +1,5 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class TypingArticle : IDataModel {
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
7
NadekoBot/_Models/DataModels/UserQuoteModel.cs
Normal file
7
NadekoBot/_Models/DataModels/UserQuoteModel.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class UserQuote : IDataModel {
|
||||
public string UserName { get; set; }
|
||||
public string Keyword { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
20
NadekoBot/_Models/JSONModels/AnimeResult.cs
Normal file
20
NadekoBot/_Models/JSONModels/AnimeResult.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace NadekoBot.Classes.JSONModels
|
||||
{
|
||||
public class AnimeResult
|
||||
{
|
||||
public int id;
|
||||
public string airing_status;
|
||||
public string title_english;
|
||||
public int total_episodes;
|
||||
public string description;
|
||||
public string image_url_lge;
|
||||
|
||||
public override string ToString() =>
|
||||
"`Title:` **" + title_english +
|
||||
"**\n`Status:` " + airing_status +
|
||||
"\n`Episodes:` " + total_episodes +
|
||||
"\n`Link:` http://anilist.co/anime/" + id +
|
||||
"\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." +
|
||||
"\n`img:` " + image_url_lge;
|
||||
}
|
||||
}
|
137
NadekoBot/_Models/JSONModels/Configuration.cs
Normal file
137
NadekoBot/_Models/JSONModels/Configuration.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using Discord;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace NadekoBot.Classes.JSONModels
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
public bool DontJoinServers { get; set; } = false;
|
||||
public bool ForwardMessages { get; set; } = true;
|
||||
public bool IsRotatingStatus { get; set; } = false;
|
||||
|
||||
[JsonIgnore]
|
||||
public List<Quote> Quotes { get; set; } = new List<Quote>();
|
||||
|
||||
[JsonIgnore]
|
||||
public List<PokemonType> PokemonTypes { get; set; } = new List<PokemonType>();
|
||||
|
||||
|
||||
public List<string> RotatingStatuses { get; set; } = new List<string>();
|
||||
public CommandPrefixesModel CommandPrefixes { get; set; } = new CommandPrefixesModel();
|
||||
public HashSet<ulong> ServerBlacklist { get; set; } = new HashSet<ulong>();
|
||||
public HashSet<ulong> ChannelBlacklist { get; set; } = new HashSet<ulong>();
|
||||
|
||||
public HashSet<ulong> UserBlacklist { get; set; } = new HashSet<ulong>() {
|
||||
105309315895693312,
|
||||
119174277298782216,
|
||||
143515953525817344
|
||||
};
|
||||
|
||||
|
||||
public string[] _8BallResponses { get; set; } =
|
||||
{
|
||||
"Most definitely yes",
|
||||
"For sure",
|
||||
"As I see it, yes",
|
||||
"My sources say yes",
|
||||
"Yes",
|
||||
"Most likely",
|
||||
"Perhaps",
|
||||
"Maybe",
|
||||
"Not sure",
|
||||
"It is uncertain",
|
||||
"Ask me again later",
|
||||
"Don't count on it",
|
||||
"Probably not",
|
||||
"Very doubtful",
|
||||
"Most likely no",
|
||||
"Nope",
|
||||
"No",
|
||||
"My sources say no",
|
||||
"Dont even think about it",
|
||||
"Definitely no",
|
||||
"NO - It may cause disease contraction"
|
||||
};
|
||||
|
||||
public string[] DisguiseResponses { get; set; } = {
|
||||
"https://cdn.discordapp.com/attachments/140007341880901632/156721710458994690/Cc5mixjUYAADgBs.jpg",
|
||||
"https://cdn.discordapp.com/attachments/140007341880901632/156721715831898113/hqdefault.jpg",
|
||||
"https://cdn.discordapp.com/attachments/140007341880901632/156721724430352385/okawari_01_haruka_weird_mask.jpg",
|
||||
"https://cdn.discordapp.com/attachments/140007341880901632/156721728763068417/mustache-best-girl.png"
|
||||
};
|
||||
|
||||
public string[] CryResponses { get; set; } = {
|
||||
"http://i.imgur.com/Xg3i1Qy.gif",
|
||||
"http://i.imgur.com/3K8DRrU.gif",
|
||||
"http://i.imgur.com/k58BcAv.gif",
|
||||
"http://i.imgur.com/I2fLXwo.gif"
|
||||
};
|
||||
|
||||
public string[] PatResponses { get; set; } = {
|
||||
"http://i.imgur.com/IiQwK12.gif",
|
||||
"http://i.imgur.com/JCXj8yD.gif",
|
||||
"http://i.imgur.com/qqBl2bm.gif",
|
||||
"http://i.imgur.com/eOJlnwP.gif",
|
||||
"https://45.media.tumblr.com/229ec0458891c4dcd847545c81e760a5/tumblr_mpfy232F4j1rxrpjzo1_r2_500.gif",
|
||||
"https://media.giphy.com/media/KZQlfylo73AMU/giphy.gif",
|
||||
"https://media.giphy.com/media/12hvLuZ7uzvCvK/giphy.gif",
|
||||
"http://gallery1.anivide.com/_full/65030_1382582341.gif",
|
||||
"https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ",
|
||||
};
|
||||
|
||||
public string CurrencySign { get; set; } = "🌸";
|
||||
public string CurrencyName { get; set; } = "NadekoFlower";
|
||||
public string DMHelpString { get; set; } = "Type `-h` for help.";
|
||||
}
|
||||
|
||||
public class CommandPrefixesModel
|
||||
{
|
||||
public string Administration { get; set; } = ".";
|
||||
public string Searches { get; set; } = "~";
|
||||
public string NSFW { get; set; } = "~";
|
||||
public string Conversations { get; set; } = "<@{0}>";
|
||||
public string ClashOfClans { get; set; } = ",";
|
||||
public string Help { get; set; } = "-";
|
||||
public string Music { get; set; } = "!m";
|
||||
public string Trello { get; set; } = "trello";
|
||||
public string Games { get; set; } = ">";
|
||||
public string Gambling { get; set; } = "$";
|
||||
public string Permissions { get; set; } = ";";
|
||||
public string Programming { get; set; } = "%";
|
||||
public string Pokemon { get; set; } = ">";
|
||||
}
|
||||
|
||||
public static class ConfigHandler
|
||||
{
|
||||
private static readonly object configLock = new object();
|
||||
public static void SaveConfig()
|
||||
{
|
||||
lock (configLock)
|
||||
{
|
||||
File.WriteAllText("data/config.json", JsonConvert.SerializeObject(NadekoBot.Config, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBlackListed(MessageEventArgs evArgs) => IsUserBlacklisted(evArgs.User.Id) ||
|
||||
(!evArgs.Channel.IsPrivate &&
|
||||
(IsChannelBlacklisted(evArgs.Channel.Id) || IsServerBlacklisted(evArgs.Server.Id)));
|
||||
|
||||
public static bool IsServerBlacklisted(ulong id) => NadekoBot.Config.ServerBlacklist.Contains(id);
|
||||
|
||||
public static bool IsChannelBlacklisted(ulong id) => NadekoBot.Config.ChannelBlacklist.Contains(id);
|
||||
|
||||
public static bool IsUserBlacklisted(ulong id) => NadekoBot.Config.UserBlacklist.Contains(id);
|
||||
}
|
||||
|
||||
public class Quote
|
||||
{
|
||||
public string Author { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public override string ToString() =>
|
||||
$"{Text}\n\t*-{Author}*";
|
||||
}
|
||||
|
||||
}
|
50
NadekoBot/_Models/JSONModels/LocalizedStrings.cs
Normal file
50
NadekoBot/_Models/JSONModels/LocalizedStrings.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.IO;
|
||||
|
||||
namespace NadekoBot.Classes.JSONModels {
|
||||
public class LocalizedStrings {
|
||||
public string[] Insults { get; set; } = {
|
||||
" You are a poop.", " You're a jerk.",
|
||||
" I will eat you when I get my powers back."
|
||||
};
|
||||
|
||||
public string[] Praises { get; set; } = {
|
||||
" You are cool.",
|
||||
" You are nice!",
|
||||
" You did a good job.",
|
||||
" You did something nice.",
|
||||
" is awesome!",
|
||||
" Wow."
|
||||
};
|
||||
|
||||
public static string[] GetAvailableLocales() {
|
||||
Directory.CreateDirectory("data/locales");
|
||||
return Directory.GetFiles("data/locales");
|
||||
}
|
||||
|
||||
//public static void HandleLocalization() {
|
||||
// var locales = LocalizedStrings.GetAvailableLocales();
|
||||
|
||||
|
||||
// Console.WriteLine("Pick a language:\n" +
|
||||
// "1. English");
|
||||
// for (var i = 0; i < locales.Length; i++) {
|
||||
// Console.WriteLine((i + 2) + ". " + Path.GetFileNameWithoutExtension(locales[i]));
|
||||
// }
|
||||
// File.WriteAllText("data/locales/english.json", JsonConvert.SerializeObject(new LocalizedStrings(), Formatting.Indented));
|
||||
// try {
|
||||
// Console.WriteLine($"Type in a number from {1} to {locales.Length + 1}\n");
|
||||
// var input = Console.ReadLine();
|
||||
// if (input != "1")
|
||||
// Locale = LocalizedStrings.LoadLocale(locales[int.Parse(input) - 2]);
|
||||
// } catch (Exception ex) {
|
||||
// Console.ForegroundColor = ConsoleColor.Red;
|
||||
// Console.WriteLine(ex);
|
||||
// Console.ReadKey();
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
public static LocalizedStrings LoadLocale(string localeFile) =>
|
||||
Newtonsoft.Json.JsonConvert.DeserializeObject<LocalizedStrings>(File.ReadAllText(localeFile));
|
||||
}
|
||||
}
|
16
NadekoBot/_Models/JSONModels/MagicItem.cs
Normal file
16
NadekoBot/_Models/JSONModels/MagicItem.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Classes.JSONModels
|
||||
{
|
||||
class MagicItem
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public override string ToString() =>
|
||||
$"✨`{Name}`\n\t*{Description}*";
|
||||
}
|
||||
}
|
22
NadekoBot/_Models/JSONModels/MangaResult.cs
Normal file
22
NadekoBot/_Models/JSONModels/MangaResult.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace NadekoBot.Classes.JSONModels
|
||||
{
|
||||
public class MangaResult
|
||||
{
|
||||
public int id;
|
||||
public string publishing_status;
|
||||
public string image_url_lge;
|
||||
public string title_english;
|
||||
public int total_chapters;
|
||||
public int total_volumes;
|
||||
public string description;
|
||||
|
||||
public override string ToString() =>
|
||||
"`Title:` **" + title_english +
|
||||
"**\n`Status:` " + publishing_status +
|
||||
"\n`Chapters:` " + total_chapters +
|
||||
"\n`Volumes:` " + total_volumes +
|
||||
"\n`Link:` http://anilist.co/manga/" + id +
|
||||
"\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." +
|
||||
"\n`img:` " + image_url_lge;
|
||||
}
|
||||
}
|
33
NadekoBot/_Models/JSONModels/PokemonType.cs
Normal file
33
NadekoBot/_Models/JSONModels/PokemonType.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Classes.JSONModels
|
||||
{
|
||||
public class PokemonType
|
||||
{
|
||||
public PokemonType(string n, string i, string[] m, List<PokemonMultiplier> multi)
|
||||
{
|
||||
Name = n;
|
||||
Icon = i;
|
||||
Moves = m;
|
||||
Multipliers = multi;
|
||||
}
|
||||
public string Name { get; set; }
|
||||
public List<PokemonMultiplier> Multipliers { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public string[] Moves { get; set; }
|
||||
}
|
||||
public class PokemonMultiplier
|
||||
{
|
||||
public PokemonMultiplier(string t, double m)
|
||||
{
|
||||
Type = t;
|
||||
Multiplication = m;
|
||||
}
|
||||
public string Type { get; set; }
|
||||
public double Multiplication { get; set; }
|
||||
}
|
||||
}
|
18
NadekoBot/_Models/JSONModels/_JSONModels.cs
Normal file
18
NadekoBot/_Models/JSONModels/_JSONModels.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace NadekoBot.Classes.JSONModels
|
||||
{
|
||||
public class Credentials
|
||||
{
|
||||
public string Username = "myemail@email.com";
|
||||
public string Password = "xxxxxxx";
|
||||
public string Token = "";
|
||||
public ulong BotId = 1231231231231;
|
||||
public string GoogleAPIKey = "";
|
||||
public ulong[] OwnerIds = { 123123123123, 5675675679845 };
|
||||
public string TrelloAppKey = "";
|
||||
public string SoundCloudClientID = "";
|
||||
public string MashapeKey = "";
|
||||
public string LOLAPIKey = "";
|
||||
public string CarbonKey = "";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user