Ejemplo n.º 1
0
 public void AddPuzzleData(PuzzleDataModel data)
 {
     using (IDbConnection connection = new SQLiteConnection(ConfigurationString))
     {
         connection.Execute("INSERT INTO PUZZLEDATA (PuzzleCode, Type, Data) " +
                            "VALUES (@PuzzleCode, @Type, @Data)",
                            data);
     }
 }
Ejemplo n.º 2
0
        public async Task AddPuzzleDataAsync(PuzzleDataModel puzzle)
        {
            if (_data.GetPuzzle(puzzle.PuzzleCode) == null)
            {
                var newPuzzle = new PuzzleModel
                {
                    Code   = puzzle.PuzzleCode,
                    Points = CalculatePuzzlePoints(0)
                };
                _data.AddOrUpdatePuzzle(newPuzzle);

                await SendMessageToChannelAsync($"Added new puzzle: <#{puzzle.PuzzleCode}>",
                                                Constants.NOTIFICATIONS_CHANNEL);
            }

            _data.AddPuzzleData(puzzle);
        }
Ejemplo n.º 3
0
        private async Task SetPuzzleDataAsync(IMessageChannel channel, string content, PuzzleDataType type)
        {
            var message = Context.Message;
            await message.DeleteAsync();

            string code = channel.Id.ToString();

            var puzzle = new PuzzleDataModel
            {
                PuzzleCode = code,
                Type       = type,
                Data       = content
            };

            await _actions.AddPuzzleDataAsync(puzzle);

            await _logger.LogAsync(new LogMessage(LogSeverity.Debug, "Bot", $"Added answer: {code} = {content}"));

            await ReplyAsync($"Added {type} to problem <#{code}>.");
        }