public async Task <bool> HandleCallbackAsync(SocketReaction reaction)
        {
            var emote = reaction.Emote;

            if (emote.Equals(_options.HitEmote))
            {
                _userClicked = true;
                await Message.DeleteAsync();

                Interactive.RemoveReactionCallback(Message);
                await Task.Run(async() =>
                {
                    await DisplayAsync();
                });


                //BlackJackService.RemovePlayerFromMatch(Context.User.Id);
                PrettyConsole.Log(LogSeverity.Info, "Callback", "User clicked HitEmote");
            }
            if (emote.Equals(_options.StandEmote))
            {
                _userClicked = true;
                //BlackJackService.RemovePlayerFromMatch(Context.User.Id);
                PrettyConsole.Log(LogSeverity.Info, "Callback", "User clicked StandEmote");
            }
            await Message.RemoveReactionAsync(reaction.Emote, reaction.User.Value);

            //await RenderAsync().ConfigureAwait(false);
            return(false);
        }
示例#2
0
        public void Initialize()
        {
            var dbName = DbConfig.DatabaseName;

            if (Process.GetProcesses().FirstOrDefault(x => x.ProcessName == "Raven.Server") == null)
            {
                PrettyConsole.Log(LogSeverity.Error, "Database", "Please make sure RavenDB is running.");
                Console.ReadLine();
                Environment.Exit(0);
            }


            _store = new Lazy <IDocumentStore>(
                () => new DocumentStore {
                Database = DbConfig.DatabaseName, Urls = new[] { DbConfig.DatabaseUrl }
            }
                .Initialize(),
                true).Value;
            if (_store == null)
            {
                PrettyConsole.Log(LogSeverity.Error, "Database", "Failed to build document store.");
            }


            if (_store.Maintenance.Server.Send(new GetDatabaseNamesOperation(0, 5)).All(x => x != dbName))
            {
                _store.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(dbName)));
            }

            _store.AggressivelyCacheFor(TimeSpan.FromMinutes(30));


            using (var session = _store.OpenSession())
            {
                if (session.Advanced.Exists("Config"))
                {
                    return;
                }
                PrettyConsole.Log(LogSeverity.Info, "Arcade's Bot", "Enter Bot's Token:");
                var token = Console.ReadLine();
                PrettyConsole.Log(LogSeverity.Info, "Arcade's Bot", "Enter Bot's Prefix:");
                var prefix = Console.ReadLine();
                var model  = new ConfigModel
                {
                    Prefix     = prefix.Trim(),
                    Blacklist  = new List <ulong>(),
                    Namespaces = new List <string>(),
                    ApiKeys    = new Dictionary <string, string>
                    {
                        { "Giphy", "dc6zaTOxFJmzC" },
                        { "Google", "" },
                        { "Discord", token.Trim() },
                        { "Imgur", "" },
                        { "Cleverbot", "" }
                    }
                };
                var id = "Config";
                Create <ConfigModel>(ref id, model);
            }
        }
        public void CompleteMatch(ref ChessMatchModel chessMatch)
        {
            var statId = _statsHandler.AddStat(chessMatch);

            chessMatch.IdOfStat = statId;
            PrettyConsole.Log(LogSeverity.Info, "Complete ChessMatch",
                              $"Completed Chess Match With Id: {chessMatch.Id}");
        }
示例#4
0
        public void Update <T>(object id, object data)
        {
            using (var session = _store.OpenSession())
            {
                session.Store((T)data, $"{id}");
                session.SaveChanges();
            }

            PrettyConsole.Log(LogSeverity.Info, "Database", $"Updated {typeof(T).Name} with {id} id.");
        }
示例#5
0
        public void Delete <T>(object id)
        {
            using (var session = _store.OpenSession(_store.Database))
            {
                PrettyConsole.Log(LogSeverity.Info, "Database", $"Removed {typeof(T).Name} with {id} id.");
                session.Delete(session.Load <T>($"{id}"));

                session.SaveChanges();
                session.Dispose();
            }
        }
示例#6
0
        public async Task InitializeAsync(DiscordSocketClient c, CommandService service)
        {
            PrettyConsole.Log(LogSeverity.Info, "Commands", $"Loading SQLite commands");
            _client  = c;
            _service = service;

            await _service.AddModulesAsync(Assembly.GetEntryAssembly());

            _client.MessageReceived += HandleCommandAsync;
            PrettyConsole.Log(LogSeverity.Info, "Commands", $"Ready, loaded {_service.Commands.Count()} commands");
        }
示例#7
0
 public DiscordWebhookClient WebhookClient(ulong id, string token)
 {
     try
     {
         return(new DiscordWebhookClient(id, token));
     }
     catch
     {
         PrettyConsole.Log(LogSeverity.Error, "Webhook", $"Webhook {id} Failed.");
         return(null);
     }
 }
示例#8
0
        public async Task StartAsync()
        {
            await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _provider);

            _discord.MessageReceived += CommandHandlerAsync;
            _discord.LeftGuild       += LeftGuild;
            _discord.GuildAvailable  += GuildAvailable;
            _discord.UserJoined      += UserJoinedAsync;
            _discord.UserLeft        += UserLeftAsync;
            _discord.MessageDeleted  += DiscordOnMessageDeleted;

            PrettyConsole.Log(LogSeverity.Info, "Commands", $"Loaded {_commands.Modules.Count()} modules with {_commands.Commands.Count()} commands");
        }
示例#9
0
        public Task WebhookFallbackAsync(DiscordWebhookClient client, ITextChannel channel, WebhookOptions options)
        {
            if (client == null && channel != null)
            {
                PrettyConsole.Log(LogSeverity.Error, "WebhookFallback", $"Falling back to Channel: {channel.Name}");
                return(channel.SendMessageAsync(options.Message, embed: options.Embed));
            }

            return(client.SendMessageAsync(options.Message,
                                           embeds: options.Embed == null ? null : new List <Embed> {
                options.Embed
            }));
        }
示例#10
0
        public SwindleService(
            DiscordSocketClient discord,
            IConfigurationRoot config,
            SwindleManager manager,
            Tokens twitter,
            Random random)
        {
            _discord = discord;
            _config  = config;
            _manager = manager;
            _twitter = twitter;
            _random  = random;

            _postEvery = TimeSpan.FromMinutes(int.Parse(_config["post_every"]));
            _messages  = new List <SocketUserMessage>();

            _discord.Ready           += OnReadyAsync;
            _discord.MessageReceived += OnMessageReceivedAsync;
            _discord.MessageUpdated  += OnMessageUpdatedAsync;
            _discord.MessageDeleted  += OnMessageDeletedAsync;
            PrettyConsole.Log(LogSeverity.Info, "Services", "Enabled SwindleService");
        }
示例#11
0
        public static void EnsureExists()
        {
            string file = Path.Combine(AppContext.BaseDirectory, FileName);

            if (!File.Exists(file))
            {
                string path = Path.GetDirectoryName(file);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                var config = new Configuration();

                PrettyConsole.Log(LogSeverity.Warning, "Doggo", "Please enter discord token: ");
                string token = Console.ReadLine();

                config.Token.Discord = token;
                config.SaveJson();
            }
            PrettyConsole.Log(LogSeverity.Info, "Doggo", "Configuration Loaded");
        }
示例#12
0
        public T Create <T>(ref string id, object data)
        {
            var returnValue = (T)data;

            using (var session = _store.OpenSession(_store.Database))
            {
                if (session.Advanced.Exists($"{id}") && ulong.TryParse(id, out _))
                {
                    return(returnValue);
                }
                while (session.Advanced.Exists($"{id}"))
                {
                    id = Guid.NewGuid().ToString();
                }
                session.Store((T)data, $"{id}");
                PrettyConsole.Log(LogSeverity.Info, "Database", $"Added {typeof(T).Name} with {id} id.");

                session.SaveChanges();
                session.Dispose();
            }

            return(returnValue);
        }
示例#13
0
        private bool ContainsBlacklistedWord(string content)
        {
            var template = _config["regex"];
            var words    = _config.GetSection("blacklist").GetChildren().Select(x => x.Value);

            foreach (var word in words)
            {
                string pattern = null;
                for (int i = 0; i < word.Length - 1; i++)
                {
                    pattern += word[i] + template;
                }

                var match = new Regex(pattern, RegexOptions.IgnoreCase).IsMatch(content);

                if (match)
                {
                    PrettyConsole.Log(LogSeverity.Info, "SwindleService", $"Skipped `{content}` for containing a blacklisted word.");
                    return(true);
                }
            }

            return(false);
        }
示例#14
0
        internal async Task CommandHandlerAsync(SocketMessage message)
        {
            if (!(message is SocketUserMessage msg))
            {
                return;
            }
            var argPos = 0;

            var context = new CustomCommandContext(_discord, msg, _provider);

            if (context.Config.Blacklist.Contains(msg.Author.Id) || _guildhelper.GetProfile(context.Guild.Id, context.User.Id).IsBlacklisted ||
                msg.Author.IsBot || context.Server.BlackListedChannels.Contains(context.Channel.Id))
            {
                return;
            }


            if (!(msg.HasStringPrefix(context.Server.Prefix, ref argPos) || msg.HasMentionPrefix(context.Client.CurrentUser, ref argPos)) ||
                msg.Source != MessageSource.User)
            {
                return;
            }
            if (msg.Content == context.Server.Prefix)
            {
                await _commands.ExecuteAsync(context, "?", _provider);

                return;
            }
            var result = await _commands.ExecuteAsync(context, argPos, _provider, MultiMatchHandling.Best);

            var search  = _commands.Search(context, argPos);
            var command = search.IsSuccess ? search.Commands.FirstOrDefault().Command : null;

            switch (result.Error)
            {
            case CommandError.Exception:
                PrettyConsole.Log(LogSeverity.Error, "Exception", result.ErrorReason);
                break;

            case CommandError.UnmetPrecondition:
                if (!result.ErrorReason.Contains("SendMessages"))
                {
                    await context.Channel.SendMessageAsync(embed : new EmbedBuilder().WithErrorColor()
                                                           .WithDescription(result.ErrorReason).Build());
                }
                break;

            case CommandError.UnknownCommand:
                break;

            case CommandError.ParseFailed:
                break;

            case CommandError.BadArgCount:
                break;

            case CommandError.ObjectNotFound:
                await context.Channel.SendMessageAsync(embed : new EmbedBuilder().WithErrorColor()
                                                       .WithDescription(result.ErrorReason).Build());

                break;

            case CommandError.MultipleMatches:
                break;

            case CommandError.Unsuccessful:
                break;
            }
            await Task.Run(() => RecordCommand(command, context));
        }
示例#15
0
 private Task OnLogAsync(LogMessage msg)
 {
     PrettyConsole.Log(msg.Severity, msg.Source, msg.Exception?.ToString() ?? msg.Message);
     return(Task.CompletedTask);
 }
示例#16
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }

            PrettyConsole.NewLine(msg.Content);



            var Context = new SocketCommandContext(_client, msg);

            PrettyConsole.NewLine((await GuildRepository.FetchGuildAsync(Context.Guild.Id)).Prefix);

            if (Context.User.IsBot)
            {
                return;
            }

            if (!(Context.Channel is SocketTextChannel))
            {
                return;
            }

            if (!(Context.Guild.CurrentUser as IGuildUser).GetPermissions(Context.Channel as SocketTextChannel).SendMessages)
            {
                return;
            }

            int    argPos = 0;
            string prefix = (await GuildRepository.FetchGuildAsync(Context.Guild.Id)).Prefix;

            if (msg.HasStringPrefix(prefix, ref argPos) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                PrettyConsole.Log(LogSeverity.Debug, $"Guild: {Context.Guild.Name}, User: {Context.User}", msg.Content);
                var result = await _service.ExecuteAsync(Context, argPos, _map);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    var cmd = _service.Search(Context, argPos).Commands.First().Command;
                    if (result.ErrorReason.Length == 0)
                    {
                        return;
                    }
                    switch (result.Error)
                    {
                    case CommandError.BadArgCount:
                        await msg.Channel.SendMessageAsync($"{Context.User.Mention}, You are incorrectly using this command. Usage: `{prefix}{cmd.Remarks}`");

                        break;

                    case CommandError.ParseFailed:
                        await msg.Channel.SendMessageAsync($"{Context.User.Mention}, Invalid number.");

                        break;

                    default:
                        await msg.Channel.SendMessageAsync($"{Context.User.Mention}, {result.ErrorReason}");

                        break;
                    }
                }
            }
            else if (msg.ToString().Length >= Config.MIN_CHAR_LENGTH && !msg.ToString().StartsWith(":"))
            {
                var user = await UserRepository.FetchUserAsync(Context);

                var rate = Config.TEMP_MULTIPLIER_RATE;
                if (DateTimeOffset.Now.Subtract(user.Message).TotalMilliseconds > user.MessageCooldown.TotalMilliseconds)
                {
                    await UserRepository.ModifyAsync(x => {
                        x.Cash += user.TemporaryMultiplier *user.InvestmentMultiplier;
                        x.TemporaryMultiplier = user.TemporaryMultiplier + rate;
                        x.Message             = DateTimeOffset.Now;
                        return(Task.CompletedTask);
                    }, Context);

                    await RankHandler.Handle(Context.Guild, Context.User.Id);
                }
            }
        }
示例#17
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }

            var Context = new SocketCommandContext(_client, msg);

            if (Context.User.IsBot)
            {
                return;
            }

            if (!(Context.Channel is SocketTextChannel))
            {
                return;
            }

            if (!(Context.Guild.CurrentUser as IGuildUser).GetPermissions(Context.Channel as SocketTextChannel).SendMessages)
            {
                return;
            }

            int argPos = 0;

            var guild = GuildRepository.FetchGuild(Context.Guild.Id);

            string prefix = guild.Prefix;

            if (msg.HasStringPrefix(prefix, ref argPos) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                PrettyConsole.Log(LogSeverity.Debug, $"Guild: {Context.Guild.Name}, User: {Context.User}", msg.Content);
                var result = await _service.ExecuteAsync(Context, argPos, _map);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    var cmd = _service.Search(Context, argPos).Commands.First().Command;
                    if (result.ErrorReason.Length == 0)
                    {
                        return;
                    }
                    switch (result.Error)
                    {
                    case CommandError.BadArgCount:
                        await msg.Channel.SendMessageAsync($"{Context.User.Mention}, You are incorrectly using this command. Usage: `{prefix}{cmd.Remarks}`");

                        break;

                    case CommandError.ParseFailed:
                        await msg.Channel.SendMessageAsync($"{Context.User.Mention}, Invalid number.");

                        break;

                    default:
                        await msg.Channel.SendMessageAsync($"{Context.User.Mention}, {result.ErrorReason}");

                        break;
                    }
                }
            }
            else if (msg.ToString().Length >= Config.MIN_CHAR_LENGTH && !msg.ToString().StartsWith(":"))
            {
                var user = UserRepository.FetchUser(Context);

                if (DateTime.UtcNow.Subtract(user.Message).TotalMilliseconds > user.MessageCooldown)
                {
                    UserRepository.Modify(DEABot.UserUpdateBuilder.Combine(
                                              DEABot.UserUpdateBuilder.Set(x => x.Cash, guild.GlobalChattingMultiplier * user.TemporaryMultiplier * user.InvestmentMultiplier + user.Cash),
                                              DEABot.UserUpdateBuilder.Set(x => x.TemporaryMultiplier, user.TemporaryMultiplier + guild.TempMultiplierIncreaseRate),
                                              DEABot.UserUpdateBuilder.Set(x => x.Message, DateTime.UtcNow)), Context);
                    await RankHandler.Handle(Context.Guild, Context.User.Id);
                }
            }
        }
示例#18
0
        private async Task <ImageLinkModel> DrawBoard(ChessMatchModel match)
        {
            await Task.Run(async() =>
            {
                var board = Image.Load(_assetService.GetImagePath("Chess", "board.png"));

                var httpClient      = new HttpClient();
                var turnIndicator   = Image.Load(_assetService.GetImagePath("Chess", "turn_indicator.png"));
                var whiteAvatarData = Image.Load(await httpClient.GetByteArrayAsync(match.WhiteAvatarUrl));
                var blackAvatarData = Image.Load(await httpClient.GetByteArrayAsync(match.BlackAvatarUrl));
                httpClient.Dispose();

                var moves = match.HistoryList.Select(x => x.Move).ToList();

                var game = moves.Count != 0 ? new ChessGame(moves, true) : new ChessGame();

                var boardPieces = game.GetBoard();

                var lastMove     = match.HistoryList.OrderByDescending(x => x.MoveDate).FirstOrDefault();
                var rankToRowMap = new Dictionary <int, int>
                {
                    { 1, 7 },
                    { 2, 6 },
                    { 3, 5 },
                    { 4, 4 },
                    { 5, 3 },
                    { 6, 2 },
                    { 7, 1 },
                    { 8, 0 }
                };
                var turnIndicatorPoint = game.WhoseTurn != Player.Black ? new Point(538, 367) : new Point(40, 15);
                board.Mutate(processor =>
                {
                    #region Mutating the board

                    for (var x = 0; x < boardPieces.Length; ++x)
                    {
                        for (var y = 0; y < boardPieces[x].Length; ++y)
                        {
                            if (lastMove != null && (lastMove.Move.OriginalPosition.File == (File)x &&
                                                     rankToRowMap[lastMove.Move.OriginalPosition.Rank] == y ||
                                                     lastMove.Move.NewPosition.File == (File)x &&
                                                     rankToRowMap[lastMove.Move.NewPosition.Rank] == y))
                            {
                                DrawImage(processor, "yellow_square", x, y);
                            }
                            var piece = boardPieces[y][x];
                            if (piece == null)
                            {
                                continue;
                            }
                            if (piece.GetFenCharacter().ToString().ToUpper() == "K" && game.IsInCheck(piece.Owner))
                            {
                                DrawImage(processor, "red_square", x, y);
                            }
                            var str = "white";
                            if (new[] { 'r', 'n', 'b', 'q', 'k', 'p' }.Contains(piece.GetFenCharacter()))
                            {
                                str = "black";
                            }
                            DrawImage(processor, string.Format("{0}_{1}", str, piece.GetFenCharacter()), x, y);
                        }
                    }

                    var blackPawnCount = game.PiecesOnBoard.Count(x =>
                                                                  x.GetFenCharacter() == 'p' && x.Owner == Player.Black && !x.IsPromotionResult);
                    var whitePawnCount = game.PiecesOnBoard.Count(x =>
                                                                  x.GetFenCharacter() == 'P' && x.Owner == Player.White && !x.IsPromotionResult);
                    var blackRookCount = game.PiecesOnBoard.Count(x =>
                                                                  x.GetFenCharacter() == 'r' && x.Owner == Player.Black && !x.IsPromotionResult);
                    var whiteRookCount = game.PiecesOnBoard.Count(x =>
                                                                  x.GetFenCharacter() == 'R' && x.Owner == Player.White && !x.IsPromotionResult);
                    var blackKnightCount = game.PiecesOnBoard.Count(x =>
                                                                    x.GetFenCharacter() == 'n' && x.Owner == Player.Black && !x.IsPromotionResult);
                    var whiteKnightCount = game.PiecesOnBoard.Count(x =>
                                                                    x.GetFenCharacter() == 'N' && x.Owner == Player.White && !x.IsPromotionResult);
                    var blackBishopCount = game.PiecesOnBoard.Count(x =>
                                                                    x.GetFenCharacter() == 'b' && x.Owner == Player.Black && !x.IsPromotionResult);
                    var whiteBishopCount = game.PiecesOnBoard.Count(x =>
                                                                    x.GetFenCharacter() == 'B' && x.Owner == Player.White && !x.IsPromotionResult);
                    var blackQueenCount = game.PiecesOnBoard.Count(x =>
                                                                   x.GetFenCharacter() == 'q' && x.Owner == Player.Black && !x.IsPromotionResult);
                    var whiteQueenCount = game.PiecesOnBoard.Count(x =>
                                                                   x.GetFenCharacter() == 'Q' && x.Owner == Player.White && !x.IsPromotionResult);
                    var row = 1;

                    var blackPawn = Image.Load(_assetService.GetImagePath("Chess", "black_p.png"));

                    for (var index = 8; index > blackPawnCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(blackPawn, new Size(30, 30), new Point(533, 16 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(blackPawn, new Size(30, 30), new Point(566, 16 + row * 30),
                                                new GraphicsOptions());
                            ++row;
                        }
                    }

                    row = 8;

                    var image2 = Image.Load(_assetService.GetImagePath("Chess", "white_P.png"));
                    for (var index = 8; index > whitePawnCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(image2, new Size(30, 30), new Point(20, 125 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(image2, new Size(30, 30), new Point(53, 125 + row * 30),
                                                new GraphicsOptions());
                            --row;
                        }
                    }

                    row = 5;

                    var image3 = Image.Load(_assetService.GetImagePath("Chess", "black_r.png"));
                    for (var index = 2; index > blackRookCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(image3, new Size(30, 30), new Point(533, 16 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(image3, new Size(30, 30), new Point(566, 16 + row * 30),
                                                new GraphicsOptions());
                            ++row;
                        }
                    }

                    row = 4;

                    var whiteRook = Image.Load(_assetService.GetImagePath("Chess", "white_R.png"));
                    for (var index = 2; index > whiteRookCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(whiteRook, new Size(30, 30), new Point(20, 125 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(whiteRook, new Size(30, 30), new Point(53, 125 + row * 30),
                                                new GraphicsOptions());
                            --row;
                        }
                    }

                    row = 6;

                    var blackKnight = Image.Load(_assetService.GetImagePath("Chess", "black_n.png"));
                    for (var index = 2; index > blackKnightCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(blackKnight, new Size(30, 30), new Point(533, 16 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(blackKnight, new Size(30, 30), new Point(566, 16 + row * 30),
                                                new GraphicsOptions());
                            ++row;
                        }
                    }

                    row = 3;

                    var whiteKnight = Image.Load(_assetService.GetImagePath("Chess", "white_N.png"));
                    for (var i = 2; i > whiteKnightCount; --i)
                    {
                        if (i % 2 == 0)
                        {
                            processor.DrawImage(whiteKnight, new Size(30, 30), new Point(20, 125 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(whiteKnight, new Size(30, 30), new Point(53, 125 + row * 30),
                                                new GraphicsOptions());
                            --row;
                        }
                    }

                    row = 7;

                    var blackBishop = Image.Load(_assetService.GetImagePath("Chess", "black_b.png"));
                    for (var index = 2; index > blackBishopCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(blackBishop, new Size(30, 30), new Point(533, 16 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(blackBishop, new Size(30, 30), new Point(566, 16 + row * 30),
                                                new GraphicsOptions());
                            ++row;
                        }
                    }

                    row = 2;

                    var whiteBishop = Image.Load(_assetService.GetImagePath("Chess", "white_B.png"));
                    for (var index = 2; index > whiteBishopCount; --index)
                    {
                        if (index % 2 == 0)
                        {
                            processor.DrawImage(whiteBishop, new Size(30, 30), new Point(20, 125 + row * 30),
                                                new GraphicsOptions());
                        }
                        else
                        {
                            processor.DrawImage(whiteBishop, new Size(30, 30), new Point(53, 125 + row * 30),
                                                new GraphicsOptions());
                            --row;
                        }
                    }

                    row = 8;

                    var blackQueen = Image.Load(_assetService.GetImagePath("Chess", "black_q.png"));
                    if (blackQueenCount == 0)
                    {
                        processor.DrawImage(blackQueen, new Size(30, 30), new Point(533, 16 + row * 30),
                                            new GraphicsOptions());
                    }
                    row = 1;

                    var whiteQueen = Image.Load(_assetService.GetImagePath("Chess", "white_Q.png"));
                    if (whiteQueenCount == 0)
                    {
                        processor.DrawImage(whiteQueen, new Size(30, 30), new Point(20, 125 + row * 30),
                                            new GraphicsOptions());
                    }

                    processor.DrawImage(turnIndicator, new Size(56, 56), turnIndicatorPoint, new GraphicsOptions());
                    processor.DrawImage(whiteAvatarData, new Size(50, 50), new Point(541, 370), new GraphicsOptions());
                    processor.DrawImage(blackAvatarData, new Size(50, 50), new Point(43, 18), new GraphicsOptions());

                    var table = Image.Load(_assetService.GetImagePath("Chess", "table.png"));
                    processor.DrawImage(table, new Size(108, 148), new Point(596, 18), new GraphicsOptions());

                    if (!SystemFonts.TryFind("Arial", out var font))
                    {
                        PrettyConsole.Log(LogSeverity.Critical, "Image drawing", "Cannot find font 'Arial' install Arial as a font and try again");
                        Console.ReadLine();
                        Environment.Exit(0);
                    }

                    processor.DrawText("Last 5 moves", font.CreateFont(12, FontStyle.Bold), Rgba32.Black, new PointF(616, 19));
                    processor.DrawText("White", font.CreateFont(12, FontStyle.Bold), Rgba32.Black, new PointF(606, 42));
                    processor.DrawText("Black", font.CreateFont(12, FontStyle.Bold), Rgba32.Black, new PointF(660, 42));
                    var blackMoves = match.HistoryList.OrderByDescending(x => x.MoveDate).Where(x => x.Player == Player.Black).ToList();
                    var whiteMoves = match.HistoryList.OrderByDescending(x => x.MoveDate).Where(x => x.Player == Player.White).ToList();

                    for (var i = 0; i < blackMoves.Count && i < 5; i++)
                    {
                        var safeguard = i;
                        var player    = blackMoves[i].Player.ToString().ToLower();
                        var file      = blackMoves[i].Move.NewPosition.File;
                        var rank      = blackMoves[i].Move.NewPosition.Rank;
                        var fenChar   = blackMoves[i].MovedfenChar;
                        var image     = Image.Load(_assetService.GetImagePath("Chess", $"{player}_{fenChar}.png"));
                        if (blackMoves.Count != whiteMoves.Count)
                        {
                            safeguard++;
                        }
                        if (whiteMoves.Count > 5 && safeguard == 5)
                        {
                            continue;
                        }
                        processor.DrawImage(image, new Size(12, 12), new Point(660, 65 + safeguard * 21), new GraphicsOptions());

                        processor.DrawText($"{file.ToString() + rank}", font.CreateFont(12, FontStyle.Bold), Rgba32.Black, new PointF(672, 63 + safeguard * 21));
                    }
                    for (var i = 0; i < whiteMoves.Count && i < 5; i++)
                    {
                        var player  = whiteMoves[i].Player.ToString().ToLower();
                        var file    = whiteMoves[i].Move.NewPosition.File;
                        var rank    = whiteMoves[i].Move.NewPosition.Rank;
                        var fenChar = whiteMoves[i].MovedfenChar;
                        var image   = Image.Load(_assetService.GetImagePath("Chess", $"{player}_{fenChar}.png"));
                        processor.DrawImage(image, new Size(12, 12), new Point(606, 65 + i * 21), new GraphicsOptions());

                        processor.DrawText($"{file.ToString() + rank}", font.CreateFont(12, FontStyle.Bold), Rgba32.Black, new PointF(618, 63 + i * 21));
                    }

                    #endregion
                });
                board.Save($"{Directory.GetCurrentDirectory()}\\Chessboards\\board{match.Id}-{match.HistoryList.Count}.png");
            });

            var nextPlayer = WhoseTurn(new ChessMatchStatusModel
            {
                Match = new ChessMatchModel
                {
                    HistoryList  = match.HistoryList,
                    ChallengeeId = match.ChallengeeId,
                    ChallengerId = match.ChallengerId
                }
            });

            return(new ImageLinkModel
            {
                ImageLink = $"attachment://board{match.Id}-{match.HistoryList.Count}.png",
                NextPlayer = nextPlayer
            });
        }