<commit_before><commit_msg>Created SentTells function. Closes #20<commit_after>﻿
using System.Collections.Generic;
using System.Text.RegularExpressions;

using CwIRC;
using MBFunctionInterface;
using MBUtilities;

namespace Utility
{
    public class SentTells : Function
    {
        public SentTells()
        {
            Help = "s(ent)tells - Tells you all of the messages you have sent that have yet to be received.";
            Type = Types.Command;
            AccessLevel = AccessLevels.Anyone;
        }

        public override List<IRCResponse> GetResponse(BotMessage message)
        {
            if (Regex.IsMatch(message.Command, "^((outstanding|s(ent)?)tells)$", RegexOptions.IgnoreCase))
            {
                List<IRCResponse> responses = new List<IRCResponse>();

                foreach (KeyValuePair<string, List<Tell.TellMessage>> kvp in Tell.MessageMap)
                {
                    bool fromUser = false;
                    foreach (Tell.TellMessage msg in kvp.Value)
                    {
                        if (msg.From == message.User.Name)
                        {
                            if (!fromUser)
                            {
                                fromUser = true;
                                responses.Add(new IRCResponse(ResponseType.Say, "To " + kvp.Key, message.ReplyTo));
                            }
                            responses.Add(new IRCResponse(ResponseType.Say, " > " + msg.Message, message.ReplyTo));
                        }
                    }
                }

                if (responses.Count == 0)
                {
                    responses.Add(new IRCResponse(ResponseType.Say, "There are no messages from you that have not already been received.", message.ReplyTo));
                }
                
                return responses;
            }

            return null;
        }
    }
}
{'fraction_non_alphanumeric': 0.08563968668407311, 'fraction_numerical': 0.001566579634464752, 'mean_word_length': 1.3365853658536586, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '6701794', 'n_tokens_mistral': 493, 'n_tokens_neox': 466, 'n_words': 109}