<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TwitchLib;
using System.Text.RegularExpressions;
using Discord;
using TwitchLib.Models.Client;

namespace JefBot.Commands
{
    internal class MigoPluginCommand : IPluginCommand
    {
        public string PluginName => "Migo";
        public string Command => "migo";
        public string Help => "Gets a random quote from the stream";
        public IEnumerable<string> Aliases => new[] { "m" };
        public bool Loaded { get; set; } = true;



        List<Quote> quotes = new List<Quote>();
        string quotefile = @"./RemoteQuotes.dat";
        Random rng = new Random();
        DateTime timestamp;
        int minutedelay = 1;
        static string DatePattern = @"((\d{2}.\d{2}.\d{4}) (\d{2}.\d{2}.\d{2}))";
        static string SubmitterPattern = @"(?:submitted by )([a-zA-Z0-9_-]+)";
        Regex dateregex = new Regex(DatePattern, RegexOptions.IgnoreCase);
        Regex submitterregex = new Regex(SubmitterPattern, RegexOptions.IgnoreCase);
        public MigoPluginCommand()
        {
            timestamp = DateTime.UtcNow;
        }
        public void Execute(ChatCommand command, TwitchClient client)
        {
            if (command.ChatMessage.Channel == "jefmajor")
            {
                if (timestamp.AddMinutes(minutedelay) < DateTime.UtcNow || command.ChatMessage.IsModerator || command.ChatMessage.IsBroadcaster)
                {
                    timestamp = DateTime.UtcNow;
                    client.SendMessage(command.ChatMessage.Channel, migo());
                }
            }
        }

        public void Discord(MessageEventArgs arg)
        {
            arg.Channel.SendMessage(migo());
        }



        public string migo()
        {
            if (File.Exists(quotefile))
            {
                using (StreamReader r = new StreamReader(quotefile))
                {
                    string line;
                    while ((line = r.ReadLine()) != null)
                    {
                        string[] split = line.Split('|'); //Split the quotes
                        string date = "";
                        string submitter = "";

                        try
                        {
                            date = dateregex.Match(split[1]).Value;
                            submitter = submitterregex.Match(split[1]).Groups[1].Value;
                        }
                        catch (Exception e)<commit_msg>god dammit endy<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TwitchLib;
using System.Text.RegularExpressions;
using Discord;
using TwitchLib.Models.Client;

namespace JefBot.Commands
{
    internal class MigoPluginCommand : IPluginCommand
    {
        public string PluginName => "Migo";
        public string Command => "migo";
        public string Help => "Gets a random quote from the stream";
        public IEnumerable<string> Aliases => new[] { "m" };
        public bool Loaded { get; set; } = true;



        List<Quote> quotes = new List<Quote>();
        string quotefile = @"./RemoteQuotes.dat";
        Random rng = new Random();

        DateTime timestampTwitch;
        DateTime timestampDiscord;

        int minutedelay = 1;
        static string DatePattern = @"((\d{2}.\d{2}.\d{4}) (\d{2}.\d{2}.\d{2}))";
        static string SubmitterPattern = @"(?:submitted by )([a-zA-Z0-9_-]+)";
        Regex dateregex = new Regex(DatePattern, RegexOptions.IgnoreCase);
        Regex submitterregex = new Regex(SubmitterPattern, RegexOptions.IgnoreCase);
        public MigoPluginCommand()
        {
            timestampDiscord = DateTime.UtcNow;
            timestampTwitch = DateTime.UtcNow;
        }
        public void Execute(ChatCommand command, TwitchClient client)
        {
            if (command.ChatMessage.Channel == "jefmajor")
            {
                if (timestampTwitch.AddMinutes(minutedelay) < DateTime.UtcNow || command.ChatMessage.IsModerator || command.ChatMessage.IsBroadcaster)
                {
                    timestampTwitch = DateTime.UtcNow;
                    client.SendMessage(command.ChatMessage.Channel, migo());
                }
            }
        }

        public void Discord(MessageEventArgs arg)
        {
            if (timestampDiscord.AddMinutes(minutedelay) < DateTime.UtcNow || arg.User.ServerPermissions.Administrator)
            {
                timestampDiscord = DateTime.UtcNow;
                arg.Channel.SendMessage(migo());
            }
        }



        public string migo()
        {
            if (File.Exists(quotefile))
            {
                using (StreamReader r = new StreamReader(quotefile))
                {
                    string line;
                    while ((line = r.ReadLine()) != null)
                    {
                        string[] split = line.Split('|'); //Split the quotes
                        string date = "";
                        string submitter = "";

                        try
                        {
                            date = dateregex.Match(split[1]).Value;
                            submitter = submitterregex.Match(split[1]).Groups[1].Value;
                        }
                        catch (Exception e)
{'fraction_non_alphanumeric': 0.10633526443655392, 'fraction_numerical': 0.004485142963931975, 'mean_word_length': 1.6495049504950494, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 17, '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': '506684', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1359, 'n_words': 309}