<commit_before>﻿using Discord.Commands;
using Discord.WebSocket;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ReminderBot
{
    class CommandHandler
    {
        private readonly DiscordSocketClient _client;
        private readonly Object _jsonLock;

        public CommandHandler(DiscordSocketClient client, Object jsonLock)
        {
            _client = client;
            _jsonLock = jsonLock;
        }

        /**<summary>Checks the command and, if meant for this, processes the request</summary>
        * <param name="msg">The message sent from discord</param>        
        * <param name="prefix">The prefix that is to be considered for commands</param>
        * <returns>Alarm that was parsed and added (if successful), otherwise null</returns>
        */
        public async Task<Alarm> HandleCommand(SocketMessage msg, string prefix)
        {
            //Ignores empty and bot messages
            if (msg == null || msg.Author.IsBot)
            {
                return null;
            }

            int id = ParseCommand(msg, prefix, out Alarm alarm);
            
            if (id > 0)
            {
                await ReportErrorToUser(msg.Channel, id);
            }
            else
            {                
                alarm.alarmId = AddAlarmEntry(alarm);<commit_msg>Bug fix<commit_after>﻿using Discord.Commands;
using Discord.WebSocket;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ReminderBot
{
    class CommandHandler
    {
        private readonly DiscordSocketClient _client;
        private readonly Object _jsonLock;

        public CommandHandler(DiscordSocketClient client, Object jsonLock)
        {
            _client = client;
            _jsonLock = jsonLock;
        }

        /**<summary>Checks the command and, if meant for this, processes the request</summary>
        * <param name="msg">The message sent from discord</param>        
        * <param name="prefix">The prefix that is to be considered for commands</param>
        * <returns>Alarm that was parsed and added (if successful), otherwise null</returns>
        */
        public async Task<Alarm> HandleCommand(SocketMessage msg, string prefix)
        {
            //Ignores empty and bot messages
            if (msg == null || msg.Author.IsBot)
            {
                return null;
            }

            int id = ParseCommand(msg, prefix, out Alarm alarm);
            
            if (id <= 0)
            {
                await ReportErrorToUser(msg.Channel, id);
            }
            else
            {                
                alarm.alarmId = AddAlarmEntry(alarm);
{'fraction_non_alphanumeric': 0.08104442183791116, 'fraction_numerical': 0.0006781959986436081, 'mean_word_length': 1.98582995951417, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3840171', 'n_tokens_mistral': 757, 'n_tokens_neox': 743, 'n_words': 224}