Refaction all files into component based folders
This commit is contained in:
parent
55e152f4aa
commit
e3adf55742
102 changed files with 816 additions and 709 deletions
12
Geekbot.net/Lib/Clients/IMalClient.cs
Normal file
12
Geekbot.net/Lib/Clients/IMalClient.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System.Threading.Tasks;
|
||||
using MyAnimeListSharp.Core;
|
||||
|
||||
namespace Geekbot.net.Lib.Clients
|
||||
{
|
||||
public interface IMalClient
|
||||
{
|
||||
bool IsLoggedIn();
|
||||
Task<AnimeEntry> GetAnime(string query);
|
||||
Task<MangaEntry> GetManga(string query);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
using System.Threading.Tasks;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
using MyAnimeListSharp.Auth;
|
||||
using MyAnimeListSharp.Core;
|
||||
using MyAnimeListSharp.Facade.Async;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Clients
|
||||
{
|
||||
public class MalClient : IMalClient
|
||||
{
|
||||
|
@ -66,11 +67,4 @@ namespace Geekbot.net.Lib
|
|||
return response.Entries.Count == 0 ? null : response.Entries[0];
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMalClient
|
||||
{
|
||||
bool IsLoggedIn();
|
||||
Task<AnimeEntry> GetAnime(string query);
|
||||
Task<MangaEntry> GetManga(string query);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Converters
|
||||
{
|
||||
public class EmojiConverter : IEmojiConverter
|
||||
{
|
||||
|
@ -90,10 +90,4 @@ namespace Geekbot.net.Lib
|
|||
return returnString.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEmojiConverter
|
||||
{
|
||||
string NumberToEmoji(int number);
|
||||
string TextToEmoji(string text);
|
||||
}
|
||||
}
|
8
Geekbot.net/Lib/Converters/IEmojiConverter.cs
Normal file
8
Geekbot.net/Lib/Converters/IEmojiConverter.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace Geekbot.net.Lib.Converters
|
||||
{
|
||||
public interface IEmojiConverter
|
||||
{
|
||||
string NumberToEmoji(int number);
|
||||
string TextToEmoji(string text);
|
||||
}
|
||||
}
|
7
Geekbot.net/Lib/Converters/IMtgManaConverter.cs
Normal file
7
Geekbot.net/Lib/Converters/IMtgManaConverter.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Geekbot.net.Lib.Converters
|
||||
{
|
||||
public interface IMtgManaConverter
|
||||
{
|
||||
string ConvertMana(string mana);
|
||||
}
|
||||
}
|
33
Geekbot.net/Lib/Converters/MtgManaConverter.cs
Normal file
33
Geekbot.net/Lib/Converters/MtgManaConverter.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Utf8Json;
|
||||
|
||||
namespace Geekbot.net.Lib.Converters
|
||||
{
|
||||
public class MtgManaConverter : IMtgManaConverter
|
||||
{
|
||||
private Dictionary<string, string> _manaDict;
|
||||
|
||||
public MtgManaConverter()
|
||||
{
|
||||
// these emotes can be found at https://discord.gg/bz8HyA7
|
||||
var mtgEmojis = File.ReadAllText(Path.GetFullPath("./Lib/Converters/MtgManaEmojis.json"));
|
||||
_manaDict = JsonSerializer.Deserialize<Dictionary<string, string>>(mtgEmojis);
|
||||
}
|
||||
|
||||
public string ConvertMana(string mana)
|
||||
{
|
||||
var rgx = Regex.Matches(mana, @"(\{(.*?)\})");
|
||||
foreach (Match manaTypes in rgx)
|
||||
{
|
||||
var m = _manaDict.GetValueOrDefault(manaTypes.Value);
|
||||
if (!string.IsNullOrEmpty(m))
|
||||
{
|
||||
mana = mana.Replace(manaTypes.Value, m);
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
}
|
50
Geekbot.net/Lib/Converters/MtgManaEmojis.json
Normal file
50
Geekbot.net/Lib/Converters/MtgManaEmojis.json
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"{0}": "<:mtg_0:415216130043412482>",
|
||||
"{1}": "<:mtg_1:415216130253389835>",
|
||||
"{2}": "<:mtg_2:415216130031091713>",
|
||||
"{3}": "<:mtg_3:415216130467037194>",
|
||||
"{4}": "<:mtg_4:415216130026635295>",
|
||||
"{5}": "<:mtg_5:415216130492203008>",
|
||||
"{6}": "<:mtg_6:415216130458779658>",
|
||||
"{7}": "<:mtg_7:415216130190475265>",
|
||||
"{8}": "<:mtg_8:415216130517630986>",
|
||||
"{9}": "<:mtg_9:415216130500722689>",
|
||||
"{10": "<:mtg_10:415216130450391051>",
|
||||
"{11}": "<:mtg_11:415216130811101185>",
|
||||
"{12}": "<:mtg_12:415216130525888532>",
|
||||
"{13}": "<:mtg_13:415216130517631000>",
|
||||
"{14}": "<:mtg_14:415216130165178370>",
|
||||
"{15}": "<:mtg_15:415216130576089108>",
|
||||
"{16}": "<:mtg_16:415216130358247425>",
|
||||
"{17}": "<:mtg_17:415216130601517056>",
|
||||
"{18}": "<:mtg_18:415216130462842891>",
|
||||
"{19}": "<:mtg_19:415216130614099988>",
|
||||
"{20}": "<:mtg_20:415216130656043038>",
|
||||
"{W}": "<:mtg_white:415216131515744256>",
|
||||
"{U}": "<:mtg_blue:415216130521694209>",
|
||||
"{B}": "<:mtg_black:415216130873884683>",
|
||||
"{R}": "<:mtg_red:415216131322806272>",
|
||||
"{G}": "<:mtg_green:415216131180331009>",
|
||||
"{S}": "<:mtg_s:415216131293446144>",
|
||||
"{T}": "<:mtg_tap:415258392727257088>",
|
||||
"{C}": "<:mtg_colorless:415216130706374666>",
|
||||
"{2/W}": "<:mtg_2w:415216130446065664>",
|
||||
"{2/U}": "<:mtg_2u:415216130429550592>",
|
||||
"{2/B}": "<:mtg_2b:415216130160984065>",
|
||||
"{2/R}": "<:mtg_2r:415216130454716436>",
|
||||
"{2/G}": "<:mtg_2g:415216130420899840>",
|
||||
"{W/U}": "<:mtg_wu:415216130970484736>",
|
||||
"{W/B}": "<:mtg_wb:415216131222011914>",
|
||||
"{U/R}": "<:mtg_ur:415216130962096128>",
|
||||
"{U/B}": "<:mtg_ub:415216130865758218>",
|
||||
"{R/W}": "<:mtg_rw:415216130878210057>",
|
||||
"{G/W}": "<:mtg_gw:415216130567962646>",
|
||||
"{G/U}": "<:mtg_gu:415216130739666945>",
|
||||
"{B/R}": "<:mtg_br:415216130580283394>",
|
||||
"{B/G}": "<:mtg_bg:415216130781609994>",
|
||||
"{U/P}": "<:mtg_up:415216130861432842>",
|
||||
"{R/P}": "<:mtg_rp:415216130597322783>",
|
||||
"{G/P}": "<:mtg_gp:415216130760769546>",
|
||||
"{W/P}": "<:mtg_wp:415216131541041172>",
|
||||
"{B/P}": "<:mtg_bp:415216130664169482>"
|
||||
}
|
|
@ -2,10 +2,12 @@
|
|||
using System.Net;
|
||||
using Discord.Commands;
|
||||
using Discord.Net;
|
||||
using Geekbot.net.Lib.Localization;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
using SharpRaven;
|
||||
using SharpRaven.Data;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.ErrorHandling
|
||||
{
|
||||
public class ErrorHandler : IErrorHandler
|
||||
{
|
||||
|
@ -90,10 +92,4 @@ namespace Geekbot.net.Lib
|
|||
|
||||
|
||||
}
|
||||
|
||||
public interface IErrorHandler
|
||||
{
|
||||
void HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def");
|
||||
void HandleHttpException(HttpException e, ICommandContext context);
|
||||
}
|
||||
}
|
12
Geekbot.net/Lib/ErrorHandling/IErrorHandler.cs
Normal file
12
Geekbot.net/Lib/ErrorHandling/IErrorHandler.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using Discord.Commands;
|
||||
using Discord.Net;
|
||||
|
||||
namespace Geekbot.net.Lib.ErrorHandling
|
||||
{
|
||||
public interface IErrorHandler
|
||||
{
|
||||
void HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def");
|
||||
void HandleHttpException(HttpException e, ICommandContext context);
|
||||
}
|
||||
}
|
7
Geekbot.net/Lib/Levels/ILevelCalc.cs
Normal file
7
Geekbot.net/Lib/Levels/ILevelCalc.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Geekbot.net.Lib.Levels
|
||||
{
|
||||
public interface ILevelCalc
|
||||
{
|
||||
int GetLevel(int experience);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Levels
|
||||
{
|
||||
public class LevelCalc : ILevelCalc
|
||||
{
|
||||
|
@ -30,9 +30,4 @@ namespace Geekbot.net.Lib
|
|||
return returnVal;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ILevelCalc
|
||||
{
|
||||
int GetLevel(int experience);
|
||||
}
|
||||
}
|
14
Geekbot.net/Lib/Localization/ITranslationHandler.cs
Normal file
14
Geekbot.net/Lib/Localization/ITranslationHandler.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Lib.Localization
|
||||
{
|
||||
public interface ITranslationHandler
|
||||
{
|
||||
string GetString(ulong guildId, string command, string stringName);
|
||||
Dictionary<string, string> GetDict(ICommandContext context);
|
||||
Dictionary<string, string> GetDict(ICommandContext context, string command);
|
||||
bool SetLanguage(ulong guildId, string language);
|
||||
List<string> GetSupportedLanguages();
|
||||
}
|
||||
}
|
|
@ -4,10 +4,11 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
using StackExchange.Redis;
|
||||
using Utf8Json;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Localization
|
||||
{
|
||||
public class TranslationHandler : ITranslationHandler
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ namespace Geekbot.net.Lib
|
|||
{
|
||||
try
|
||||
{
|
||||
var translationFile = File.ReadAllText(Path.GetFullPath("./Storage/Translations.json"));
|
||||
var translationFile = File.ReadAllText(Path.GetFullPath("./Lib/Localization/Translations.json"));
|
||||
var rawTranslations = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(translationFile);
|
||||
var sortedPerLanguage = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
foreach (var command in rawTranslations)
|
||||
|
@ -152,13 +153,4 @@ namespace Geekbot.net.Lib
|
|||
return _supportedLanguages;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITranslationHandler
|
||||
{
|
||||
string GetString(ulong guildId, string command, string stringName);
|
||||
Dictionary<string, string> GetDict(ICommandContext context);
|
||||
Dictionary<string, string> GetDict(ICommandContext context, string command);
|
||||
bool SetLanguage(ulong guildId, string language);
|
||||
List<string> GetSupportedLanguages();
|
||||
}
|
||||
}
|
100
Geekbot.net/Lib/Localization/Translations.json
Normal file
100
Geekbot.net/Lib/Localization/Translations.json
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"admin": {
|
||||
"NewLanguageSet": {
|
||||
"EN": "I will reply in english from now on",
|
||||
"CHDE": "I werd ab jetzt uf schwiizerdüütsch antworte, äuuä"
|
||||
},
|
||||
"GetLanguage": {
|
||||
"EN": "I'm talking english",
|
||||
"CHDE": "I red schwiizerdüütsch"
|
||||
}
|
||||
},
|
||||
"errorHandler": {
|
||||
"SomethingWentWrong": {
|
||||
"EN": "Something went wrong :confused:",
|
||||
"CHDE": "Öppis isch schief gange :confused:"
|
||||
}
|
||||
},
|
||||
"httpErrors": {
|
||||
"403": {
|
||||
"EN": "Seems like i don't have enough permission to that :confused:",
|
||||
"CHDE": "Gseht danach us das ich nid gnueg recht han zum das mache :confused:"
|
||||
}
|
||||
},
|
||||
"choose": {
|
||||
"Choice": {
|
||||
"EN": "I Choose **{0}**",
|
||||
"CHDE": "I nimme **{0}**"
|
||||
}
|
||||
},
|
||||
"good": {
|
||||
"CannotChangeOwn": {
|
||||
"EN": "Sorry {0}, but you can't give yourself karma",
|
||||
"CHDE": "Sorry {0}, aber du chasch dr selber kei karma geh"
|
||||
},
|
||||
"WaitUntill": {
|
||||
"EN": "Sorry {0}, but you have to wait {1} before you can give karma again...",
|
||||
"CHDE": "Sorry {0}, aber du musch no {1} warte bisch d wieder karma chasch geh..."
|
||||
},
|
||||
"Increased": {
|
||||
"EN": "Karma gained",
|
||||
"CHDE": "Karma becho"
|
||||
},
|
||||
"By": {
|
||||
"EN": "By",
|
||||
"CHDE": "Vo"
|
||||
},
|
||||
"Amount": {
|
||||
"EN": "Amount",
|
||||
"CHDE": "Mengi"
|
||||
},
|
||||
"Current": {
|
||||
"EN": "Current",
|
||||
"CHDE": "Jetzt"
|
||||
}
|
||||
},
|
||||
"bad": {
|
||||
"CannotChangeOwn": {
|
||||
"EN": "Sorry {0}, but you can't lower your own karma",
|
||||
"CHDE": "Sorry {0}, aber du chasch dr din eigete karma nid weg neh"
|
||||
},
|
||||
"WaitUntill": {
|
||||
"EN": "Sorry {0}, but you have to wait {1} before you can lower karma again...",
|
||||
"CHDE": "Sorry {0}, aber du musch no {1} warte bisch d wieder karma chasch senke..."
|
||||
},
|
||||
"Decreased": {
|
||||
"EN": "Karma lowered",
|
||||
"CHDE": "Karma gsenkt"
|
||||
},
|
||||
"By": {
|
||||
"EN": "By",
|
||||
"CHDE": "Vo"
|
||||
},
|
||||
"Amount": {
|
||||
"EN": "Amount",
|
||||
"CHDE": "Mengi"
|
||||
},
|
||||
"Current": {
|
||||
"EN": "Current",
|
||||
"CHDE": "Jetzt"
|
||||
}
|
||||
},
|
||||
"roll": {
|
||||
"Rolled": {
|
||||
"EN": "{0}, you rolled {1}, your guess was {2}",
|
||||
"CHDE": "{0}, du hesch {1} grollt und hesch {2} grate"
|
||||
},
|
||||
"Gratz": {
|
||||
"EN": "Congratulations {0}, your guess was correct!",
|
||||
"CHDE": "Gratuliere {0}, du hesch richtig grate!"
|
||||
},
|
||||
"RolledNoGuess": {
|
||||
"EN": "{0}, you rolled {1}",
|
||||
"CHDE": "{0}, du hesch {1} grollt"
|
||||
},
|
||||
"NoPrevGuess": {
|
||||
"EN": ":red_circle: {0}, you can't guess the same number again",
|
||||
"CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate"
|
||||
}
|
||||
}
|
||||
}
|
42
Geekbot.net/Lib/Logger/DiscordLogger.cs
Normal file
42
Geekbot.net/Lib/Logger/DiscordLogger.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public class DiscordLogger : IDiscordLogger
|
||||
{
|
||||
private readonly GeekbotLogger _logger;
|
||||
|
||||
public DiscordLogger(GeekbotLogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Log(LogMessage message)
|
||||
{
|
||||
var logMessage = $"[{message.Source}] {message.Message}";
|
||||
switch (message.Severity)
|
||||
{
|
||||
case LogSeverity.Verbose:
|
||||
_logger.Trace(message.Source, message.Message);
|
||||
break;
|
||||
case LogSeverity.Debug:
|
||||
_logger.Debug(message.Source, message.Message);
|
||||
break;
|
||||
case LogSeverity.Info:
|
||||
_logger.Information(message.Source, message.Message);
|
||||
break;
|
||||
case LogSeverity.Critical:
|
||||
case LogSeverity.Error:
|
||||
case LogSeverity.Warning:
|
||||
if (logMessage.Contains("VOICE_STATE_UPDATE")) break;
|
||||
_logger.Error(message.Source, message.Message, message.Exception);
|
||||
break;
|
||||
default:
|
||||
_logger.Information(message.Source, $"{logMessage} --- {message.Severity}");
|
||||
break;
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public class GeekbotLogger : IGeekbotLogger
|
||||
{
|
||||
|
@ -21,6 +21,11 @@ namespace Geekbot.net.Lib
|
|||
Information("Geekbot", "Using GeekbotLogger");
|
||||
}
|
||||
|
||||
public void Trace(string source, string message, object extra = null)
|
||||
{
|
||||
_logger.Trace(CreateLogString("Debug", source, message, null, extra));
|
||||
}
|
||||
|
||||
public void Debug(string source, string message, object extra = null)
|
||||
{
|
||||
_logger.Debug(CreateLogString("Debug", source, message, null, extra));
|
||||
|
@ -63,22 +68,4 @@ namespace Geekbot.net.Lib
|
|||
return $"[{source}] - [{m.Guild.Name} - {m.Channel.Name}] {m.User.Name}: {m.Message.Content}";
|
||||
}
|
||||
}
|
||||
|
||||
public class GeekbotLoggerObject
|
||||
{
|
||||
public DateTime Timestamp { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string Message { get; set; }
|
||||
public Exception StackTrace { get; set; }
|
||||
public object Extra { get; set; }
|
||||
}
|
||||
|
||||
public interface IGeekbotLogger
|
||||
{
|
||||
void Debug(string source, string message, object extra = null);
|
||||
void Information(string source, string message, object extra = null);
|
||||
void Warning(string source, string message, Exception stackTrace = null, object extra = null);
|
||||
void Error(string source, string message, Exception stackTrace, object extra = null);
|
||||
}
|
||||
}
|
10
Geekbot.net/Lib/Logger/IDiscordLogger.cs
Normal file
10
Geekbot.net/Lib/Logger/IDiscordLogger.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public interface IDiscordLogger
|
||||
{
|
||||
Task Log(LogMessage message);
|
||||
}
|
||||
}
|
13
Geekbot.net/Lib/Logger/IGeekbotLogger.cs
Normal file
13
Geekbot.net/Lib/Logger/IGeekbotLogger.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public interface IGeekbotLogger
|
||||
{
|
||||
void Trace(string source, string message, object extra = null);
|
||||
void Debug(string source, string message, object extra = null);
|
||||
void Information(string source, string message, object extra = null);
|
||||
void Warning(string source, string message, Exception stackTrace = null, object extra = null);
|
||||
void Error(string source, string message, Exception stackTrace, object extra = null);
|
||||
}
|
||||
}
|
14
Geekbot.net/Lib/Logger/LogDto.cs
Normal file
14
Geekbot.net/Lib/Logger/LogDto.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public class GeekbotLoggerObject
|
||||
{
|
||||
public DateTime Timestamp { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string Message { get; set; }
|
||||
public Exception StackTrace { get; set; }
|
||||
public object Extra { get; set; }
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@ using NLog.Config;
|
|||
using NLog.Targets;
|
||||
using SumoLogic.Logging.NLog;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public class LoggerFactory
|
||||
{
|
||||
public static Logger CreateNLog(RunParameters runParameters, bool sumologicActive)
|
||||
public static NLog.Logger CreateNLog(RunParameters runParameters, bool sumologicActive)
|
||||
{
|
||||
var config = new LoggingConfiguration();
|
||||
|
26
Geekbot.net/Lib/Logger/MessageDto.cs
Normal file
26
Geekbot.net/Lib/Logger/MessageDto.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public class MessageDto
|
||||
{
|
||||
public MessageContent Message { get; set; }
|
||||
public IdAndName User { get; set; }
|
||||
public IdAndName Guild { get; set; }
|
||||
public IdAndName Channel { get; set; }
|
||||
|
||||
public class MessageContent
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Id { get; set; }
|
||||
public int Attachments { get; set; }
|
||||
public int ChannelMentions { get; set; }
|
||||
public int UserMentions { get; set; }
|
||||
public int RoleMentions { get; set; }
|
||||
}
|
||||
|
||||
public class IdAndName
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.Logger
|
||||
{
|
||||
public class SimpleConextConverter
|
||||
{
|
||||
|
@ -68,29 +68,4 @@ namespace Geekbot.net.Lib
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class MessageDto
|
||||
{
|
||||
public MessageContent Message { get; set; }
|
||||
public IdAndName User { get; set; }
|
||||
public IdAndName Guild { get; set; }
|
||||
public IdAndName Channel { get; set; }
|
||||
|
||||
public class MessageContent
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Id { get; set; }
|
||||
public int Attachments { get; set; }
|
||||
public int ChannelMentions { get; set; }
|
||||
public int UserMentions { get; set; }
|
||||
public int RoleMentions { get; set; }
|
||||
}
|
||||
|
||||
public class IdAndName
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
|
||||
namespace Geekbot.net.Lib.Media
|
||||
{
|
||||
|
@ -16,7 +17,7 @@ namespace Geekbot.net.Lib.Media
|
|||
var rawFortunes = File.ReadAllText(path);
|
||||
_fortuneArray = rawFortunes.Split("%");
|
||||
_totalFortunes = _fortuneArray.Length;
|
||||
logger.Debug("Geekbot", "Loaded {totalFortunes} Fortunes");
|
||||
logger.Trace("Geekbot", $"Loaded {_totalFortunes} Fortunes");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -29,9 +30,4 @@ namespace Geekbot.net.Lib.Media
|
|||
return _fortuneArray[new Random().Next(0, _totalFortunes)];
|
||||
}
|
||||
}
|
||||
|
||||
public interface IFortunesProvider
|
||||
{
|
||||
string GetRandomFortune();
|
||||
}
|
||||
}
|
7
Geekbot.net/Lib/Media/IFortunesProvider.cs
Normal file
7
Geekbot.net/Lib/Media/IFortunesProvider.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Geekbot.net.Lib.Media
|
||||
{
|
||||
public interface IFortunesProvider
|
||||
{
|
||||
string GetRandomFortune();
|
||||
}
|
||||
}
|
14
Geekbot.net/Lib/Media/IMediaProvider.cs
Normal file
14
Geekbot.net/Lib/Media/IMediaProvider.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace Geekbot.net.Lib.Media
|
||||
{
|
||||
public interface IMediaProvider
|
||||
{
|
||||
string GetCheckem();
|
||||
string GetPanda();
|
||||
string GetCrossant();
|
||||
string GetSquirrel();
|
||||
string GetPumpkin();
|
||||
string GetTurtle();
|
||||
string GetPinguin();
|
||||
string GetFox();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
|
||||
namespace Geekbot.net.Lib.Media
|
||||
{
|
||||
|
@ -37,56 +38,56 @@ namespace Geekbot.net.Lib.Media
|
|||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/checkEmPics"));
|
||||
_checkemImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_checkemImages.Length} CheckEm Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_checkemImages.Length} CheckEm Images");
|
||||
}
|
||||
|
||||
private void LoadPandas()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pandas"));
|
||||
_pandaImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_pandaImages.Length} Panda Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_pandaImages.Length} Panda Images");
|
||||
}
|
||||
|
||||
private void BakeCroissants()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/croissant"));
|
||||
_croissantImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_croissantImages.Length} Croissant Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_croissantImages.Length} Croissant Images");
|
||||
}
|
||||
|
||||
private void LoadSquirrels()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/squirrel"));
|
||||
_squirrelImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_squirrelImages.Length} Squirrel Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_squirrelImages.Length} Squirrel Images");
|
||||
}
|
||||
|
||||
private void LoadPumpkins()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pumpkin"));
|
||||
_pumpkinImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_pumpkinImages.Length} Pumpkin Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_pumpkinImages.Length} Pumpkin Images");
|
||||
}
|
||||
|
||||
private void LoadTurtles()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/turtles"));
|
||||
_turtlesImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_turtlesImages.Length} Turtle Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_turtlesImages.Length} Turtle Images");
|
||||
}
|
||||
|
||||
private void LoadPinguins()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pinguins"));
|
||||
_pinguinImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_pinguinImages.Length} Pinguin Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_pinguinImages.Length} Pinguin Images");
|
||||
}
|
||||
|
||||
private void LoadFoxes()
|
||||
{
|
||||
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/foxes"));
|
||||
_foxImages = rawLinks.Split("\n");
|
||||
_logger.Debug("Geekbot", $"Loaded {_foxImages.Length} Foxes Images");
|
||||
_logger.Trace("Geekbot", $"Loaded {_foxImages.Length} Foxes Images");
|
||||
}
|
||||
|
||||
public string GetCheckem()
|
||||
|
@ -129,16 +130,4 @@ namespace Geekbot.net.Lib.Media
|
|||
return _foxImages[_random.Next(0, _foxImages.Length)];
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMediaProvider
|
||||
{
|
||||
string GetCheckem();
|
||||
string GetPanda();
|
||||
string GetCrossant();
|
||||
string GetSquirrel();
|
||||
string GetPumpkin();
|
||||
string GetTurtle();
|
||||
string GetPinguin();
|
||||
string GetFox();
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
public class MtgManaConverter : IMtgManaConverter
|
||||
{
|
||||
private Dictionary<string, string> _manaDict;
|
||||
|
||||
public MtgManaConverter()
|
||||
{
|
||||
// these emotes can be found at https://discord.gg/bz8HyA7
|
||||
|
||||
var manaDict = new Dictionary<string, string>();
|
||||
manaDict.Add("{0}", "<:mtg_0:415216130043412482>");
|
||||
manaDict.Add("{1}", "<:mtg_1:415216130253389835>");
|
||||
manaDict.Add("{2}", "<:mtg_2:415216130031091713>");
|
||||
manaDict.Add("{3}", "<:mtg_3:415216130467037194>");
|
||||
manaDict.Add("{4}", "<:mtg_4:415216130026635295>");
|
||||
manaDict.Add("{5}", "<:mtg_5:415216130492203008>");
|
||||
manaDict.Add("{6}", "<:mtg_6:415216130458779658>");
|
||||
manaDict.Add("{7}", "<:mtg_7:415216130190475265>");
|
||||
manaDict.Add("{8}", "<:mtg_8:415216130517630986>");
|
||||
manaDict.Add("{9}", "<:mtg_9:415216130500722689>");
|
||||
manaDict.Add("{10", "<:mtg_10:415216130450391051>");
|
||||
manaDict.Add("{11}", "<:mtg_11:415216130811101185>");
|
||||
manaDict.Add("{12}", "<:mtg_12:415216130525888532>");
|
||||
manaDict.Add("{13}", "<:mtg_13:415216130517631000>");
|
||||
manaDict.Add("{14}", "<:mtg_14:415216130165178370>");
|
||||
manaDict.Add("{15}", "<:mtg_15:415216130576089108>");
|
||||
manaDict.Add("{16}", "<:mtg_16:415216130358247425>");
|
||||
manaDict.Add("{17}", "<:mtg_17:415216130601517056>");
|
||||
manaDict.Add("{18}", "<:mtg_18:415216130462842891>");
|
||||
manaDict.Add("{19}", "<:mtg_19:415216130614099988>");
|
||||
manaDict.Add("{20}", "<:mtg_20:415216130656043038>");
|
||||
manaDict.Add("{W}", "<:mtg_white:415216131515744256>");
|
||||
manaDict.Add("{U}", "<:mtg_blue:415216130521694209>");
|
||||
manaDict.Add("{B}", "<:mtg_black:415216130873884683>");
|
||||
manaDict.Add("{R}", "<:mtg_red:415216131322806272>");
|
||||
manaDict.Add("{G}", "<:mtg_green:415216131180331009>");
|
||||
manaDict.Add("{S}", "<:mtg_s:415216131293446144>");
|
||||
manaDict.Add("{T}", "<:mtg_tap:415258392727257088>");
|
||||
manaDict.Add("{C}", "<:mtg_colorless:415216130706374666>");
|
||||
manaDict.Add("{2/W}", "<:mtg_2w:415216130446065664>");
|
||||
manaDict.Add("{2/U}", "<:mtg_2u:415216130429550592>");
|
||||
manaDict.Add("{2/B}", "<:mtg_2b:415216130160984065>");
|
||||
manaDict.Add("{2/R}", "<:mtg_2r:415216130454716436>");
|
||||
manaDict.Add("{2/G}", "<:mtg_2g:415216130420899840>");
|
||||
manaDict.Add("{W/U}", "<:mtg_wu:415216130970484736>");
|
||||
manaDict.Add("{W/B}", "<:mtg_wb:415216131222011914>");
|
||||
manaDict.Add("{U/R}", "<:mtg_ur:415216130962096128>");
|
||||
manaDict.Add("{U/B}", "<:mtg_ub:415216130865758218>");
|
||||
manaDict.Add("{R/W}", "<:mtg_rw:415216130878210057>");
|
||||
manaDict.Add("{G/W}", "<:mtg_gw:415216130567962646>");
|
||||
manaDict.Add("{G/U}", "<:mtg_gu:415216130739666945>");
|
||||
manaDict.Add("{B/R}", "<:mtg_br:415216130580283394>");
|
||||
manaDict.Add("{B/G}", "<:mtg_bg:415216130781609994>");
|
||||
manaDict.Add("{U/P}", "<:mtg_up:415216130861432842>");
|
||||
manaDict.Add("{R/P}", "<:mtg_rp:415216130597322783>");
|
||||
manaDict.Add("{G/P}", "<:mtg_gp:415216130760769546>");
|
||||
manaDict.Add("{W/P}", "<:mtg_wp:415216131541041172>");
|
||||
manaDict.Add("{B/P}", "<:mtg_bp:415216130664169482>");
|
||||
|
||||
_manaDict = manaDict;
|
||||
}
|
||||
|
||||
public string ConvertMana(string mana)
|
||||
{
|
||||
var rgx = Regex.Matches(mana, @"(\{(.*?)\})");
|
||||
foreach (Match manaTypes in rgx)
|
||||
{
|
||||
var m = _manaDict.GetValueOrDefault(manaTypes.Value);
|
||||
if (!string.IsNullOrEmpty(m))
|
||||
{
|
||||
mana = mana.Replace(manaTypes.Value, m);
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMtgManaConverter
|
||||
{
|
||||
string ConvertMana(string mana);
|
||||
}
|
||||
}
|
14
Geekbot.net/Lib/ReactionListener/IReactionListener.cs
Normal file
14
Geekbot.net/Lib/ReactionListener/IReactionListener.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Geekbot.net.Lib.ReactionListener
|
||||
{
|
||||
public interface IReactionListener
|
||||
{
|
||||
bool IsListener(ulong id);
|
||||
Task AddRoleToListener(string messageId, IEmote emoji, IRole role);
|
||||
void RemoveRole(ISocketMessageChannel channel, SocketReaction reaction);
|
||||
void GiveRole(ISocketMessageChannel message, SocketReaction reaction);
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ using Discord;
|
|||
using Discord.WebSocket;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.ReactionListener
|
||||
{
|
||||
public class ReactionListener : IReactionListener
|
||||
{
|
||||
|
@ -87,12 +87,4 @@ namespace Geekbot.net.Lib
|
|||
await ((IGuildUser) reaction.User.Value).AddRoleAsync(role);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IReactionListener
|
||||
{
|
||||
bool IsListener(ulong id);
|
||||
Task AddRoleToListener(string messageId, IEmote emoji, IRole role);
|
||||
void RemoveRole(ISocketMessageChannel channel, SocketReaction reaction);
|
||||
void GiveRole(ISocketMessageChannel message, SocketReaction reaction);
|
||||
}
|
||||
}
|
13
Geekbot.net/Lib/UserRepository/IUserRepository.cs
Normal file
13
Geekbot.net/Lib/UserRepository/IUserRepository.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Geekbot.net.Lib.UserRepository
|
||||
{
|
||||
public interface IUserRepository
|
||||
{
|
||||
Task<bool> Update(SocketUser user);
|
||||
UserRepositoryUser Get(ulong userId);
|
||||
string GetUserSetting(ulong userId, string setting);
|
||||
bool SaveUserSetting(ulong userId, string setting, string value);
|
||||
}
|
||||
}
|
|
@ -2,10 +2,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib.Logger;
|
||||
using StackExchange.Redis;
|
||||
using Utf8Json;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.UserRepository
|
||||
{
|
||||
public class UserRepository : IUserRepository
|
||||
{
|
||||
|
@ -121,23 +122,4 @@ namespace Geekbot.net.Lib
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class UserRepositoryUser
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Discriminator { get; set; }
|
||||
public string AvatarUrl { get; set; }
|
||||
public bool IsBot { get; set; }
|
||||
public DateTimeOffset Joined { get; set; }
|
||||
public List<string> UsedNames { get; set; }
|
||||
}
|
||||
|
||||
public interface IUserRepository
|
||||
{
|
||||
Task<bool> Update(SocketUser user);
|
||||
UserRepositoryUser Get(ulong userId);
|
||||
string GetUserSetting(ulong userId, string setting);
|
||||
bool SaveUserSetting(ulong userId, string setting, string value);
|
||||
}
|
||||
}
|
16
Geekbot.net/Lib/UserRepository/UserRepositoryUserDto.cs
Normal file
16
Geekbot.net/Lib/UserRepository/UserRepositoryUserDto.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Geekbot.net.Lib.UserRepository
|
||||
{
|
||||
public class UserRepositoryUser
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Discriminator { get; set; }
|
||||
public string AvatarUrl { get; set; }
|
||||
public bool IsBot { get; set; }
|
||||
public DateTimeOffset Joined { get; set; }
|
||||
public List<string> UsedNames { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue