예제 #1
0
        public override void RunCommand(ITwitchMessage twitchMessage)
        {
            if ((DateTime.Now - Cooldowns.modsCommandCooldown).TotalSeconds <= 15)
            {
                return;
            }

            Cooldowns.modsCommandCooldown = DateTime.Now;
            string modmsg = "Version: " + Toolkit.Mod.Version + ", Mods: ";

            string[] mods = LoadedModManager.RunningMods.Select((m) => m.Name).ToArray();

            for (int i = 0; i < mods.Length; i++)
            {
                modmsg += mods[i] + ", ";

                if (i == (mods.Length - 1) || modmsg.Length > 256)
                {
                    modmsg = modmsg.Substring(0, modmsg.Length - 2);
                    TwitchWrapper.SendChatMessage(modmsg);
                    modmsg = "";
                }
            }
            return;
        }
예제 #2
0
        public override void RunCommand([NotNull] ITwitchMessage message)
        {
            string code = CommandFilter.Parse(message.Message).Skip(1).FirstOrDefault();

            if (code.NullOrEmpty())
            {
                return;
            }

            if (!Data.ColorIndex.TryGetValue(code !.ToLowerInvariant(), out Color color) && !ColorUtility.TryParseHtmlString(code, out color))
            {
                MessageHelper.ReplyToUser(message.Username, "TKUtils.NotAColor".LocalizeKeyed(code));

                return;
            }

            if (!PurchaseHelper.TryGetPawn(message.Username, out Pawn pawn))
            {
                MessageHelper.ReplyToUser(message.Username, "TKUtils.NoPawn".Localize());

                return;
            }

            pawn.story.favoriteColor = new Color(color.r, color.g, color.b, 1f);
            message.Reply("TKUtils.FavoriteColor.Complete".Localize());
        }
예제 #3
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            var worker = ArgWorker.CreateInstance(CommandFilter.Parse(twitchMessage.Message).Skip(1));

            if (!worker.TryGetNextAsInt(out int amount, 1))
            {
                return;
            }

            List <string> viewers = Viewers.ParseViewersFromJsonAndFindActiveViewers();

            if (viewers == null || viewers.Count <= 0)
            {
                return;
            }

            var count = 0;

            foreach (string username in viewers)
            {
                Viewers.GetViewer(username).GiveViewerCoins(amount);
                count++;
            }

            twitchMessage.Reply("TKUtils.GiveAll".LocalizeKeyed(amount.ToString("N0"), count.ToString("N0")));
        }
예제 #4
0
        public override void RunCommand(ITwitchMessage twitchMessage)
        {
            try
            {
                string[] command = twitchMessage.Message.Split(' ');

                if (command.Length < 2)
                {
                    return;
                }

                bool isNumeric = int.TryParse(command[1], out int amount);

                if (isNumeric)
                {
                    foreach (Viewer vwr in Viewers.All)
                    {
                        vwr.GiveViewerCoins(amount);
                    }

                    TwitchWrapper.SendChatMessage($"@{twitchMessage.Username} " + Helper.ReplacePlaceholder("TwitchToolkitGiveAllCoins".Translate(), amount: amount.ToString()));
                }
            }
            catch (InvalidCastException e)
            {
                Helper.Log("Give All Coins Syntax Error " + e.Message);
            }
        }
예제 #5
0
        public override void RunCommand(ITwitchMessage twitchMessage)
        {
            Viewer viewer = Viewers.GetViewer(twitchMessage.Username);

            GameComponentPawns pawnComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (pawnComponent.HasUserBeenNamed(twitchMessage.Username) || pawnComponent.UserInViewerQueue(twitchMessage.Username))
            {
                return;
            }

            if (ToolkitSettings.ChargeViewersForQueue)
            {
                if (viewer.GetViewerCoins() < ToolkitSettings.CostToJoinQueue)
                {
                    TwitchWrapper.SendChatMessage($"@{twitchMessage.Username} you do not have enough coins to purchase a ticket, it costs {ToolkitSettings.CostToJoinQueue} and you have {viewer.GetViewerCoins()}.");
                    return;
                }

                viewer.TakeViewerCoins(ToolkitSettings.CostToJoinQueue);
            }

            pawnComponent.AddViewerToViewerQueue(twitchMessage.Username);
            TwitchWrapper.SendChatMessage($"@{twitchMessage.Username} you have purchased a ticket and are in the queue!");
        }
예제 #6
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            if (pawn !.IsCaravanMember())
            {
                twitchMessage.Reply("TKUtils.Leave.Caravan".Localize());

                return;
            }

            var component = Current.Game.GetComponent <GameComponentPawns>();

            if (CompatRegistry.Magic?.IsUndead(pawn) ?? false)
            {
                twitchMessage.Reply("TKUtils.Leave.Undead".Localize());
                component?.pawnHistory.Remove(twitchMessage.Username);

                if (pawn.Name is NameTriple name)
                {
                    pawn.Name = new NameTriple(name.First ?? "", name.Last ?? "", name.Last ?? "");
                }

                return;
            }

            ForceLeave(twitchMessage, pawn);
            component.pawnHistory.Remove(twitchMessage.Username);
        }
예제 #7
0
        public override void ParseMessage(ITwitchMessage twitchMessage)
        {
            // If it is a whisper, do not update viewer details
            if (twitchMessage.ChatMessage == null)
            {
                return;
            }

            Viewer             viewer    = Viewers.GetViewer(twitchMessage.Username);
            GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

            ToolkitSettings.ViewerColorCodes[twitchMessage.Username.ToLower()] = twitchMessage.ChatMessage.ColorHex;

            if (component.HasUserBeenNamed(twitchMessage.Username))
            {
                component.PawnAssignedToUser(twitchMessage.Username).story.hairColor = twitchMessage.ChatMessage.Color;
            }

            if (twitchMessage.ChatMessage.IsModerator && !viewer.mod)
            {
                viewer.SetAsModerator();
            }

            if (twitchMessage.ChatMessage.IsSubscriber && !viewer.IsSub)
            {
                viewer.subscriber = true;
            }

            if (twitchMessage.ChatMessage.IsVip && !viewer.IsVIP)
            {
                viewer.vip = true;
            }
        }
예제 #8
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            int totalKills     = pawn !.records.GetAsInt(RecordDefOf.Kills);
            int animalKills    = pawn.records.GetAsInt(RecordDefOf.KillsAnimals);
            int humanLikeKills = pawn.records.GetAsInt(RecordDefOf.KillsHumanlikes);
            int mechanoidKills = pawn.records.GetAsInt(RecordDefOf.KillsMechanoids);

            string container = ResponseHelper.JoinPair("TKUtils.PawnKills.Total".Localize().CapitalizeFirst(), totalKills.ToString("N0"));

            container += ResponseHelper.OuterGroupSeparator;

            container += string.Join(
                ", ",
                ResponseHelper.JoinPair("TKUtils.PawnKills.Humanlike".Localize().CapitalizeFirst(), humanLikeKills.ToString("N0")),
                ResponseHelper.JoinPair("TKUtils.PawnKills.Animals".Localize().CapitalizeFirst(), animalKills.ToString("N0")),
                ResponseHelper.JoinPair("TKUtils.PawnKills.Mechanoids".Localize().CapitalizeFirst(), mechanoidKills.ToString("N0"))
                );


            twitchMessage.Reply(container);
        }
예제 #9
0
        private static bool Prefix([CanBeNull] CommandDriver __instance, ITwitchMessage twitchMessage)
        {
            if (__instance == null)
            {
                return(true);
            }

            if (!TkSettings.StoreState)
            {
                return(false);
            }

            Viewer         viewer  = Viewers.GetViewer(twitchMessage.Username);
            ITwitchMessage message = twitchMessage;

            if (!__instance.command.defName.Equals("Buy"))
            {
                message = twitchMessage.WithMessage($"!{CommandDefOf.Buy.command} {twitchMessage.Message.Substring(1)}");
            }

            if (message !.Message.Split(' ').Length < 2)
            {
                return(false);
            }

            Purchase_Handler.ResolvePurchase(viewer, message);

            return(false);
        }
예제 #10
0
        public virtual void RunCommand(ITwitchMessage twitchMessage)
        {
            Helper.Log("filtering command");

            string output = FilterTags(twitchMessage, command.outputMessage);

            Helper.Log("command filtered");



            if (!UserData.IsTypeRegistered <Functions>())
            {
                UserData.RegisterType <Functions>();
                UserData.RegisterType <Viewer>();
            }

            Helper.Log("creating script");

            Script script = new Script();

            script.DebuggerEnabled = true;
            DynValue functions = UserData.Create(new Functions());

            script.Globals.Set("functions", functions);

            Helper.Log("Parsing Script " + output);

            DynValue res = script.DoString(output);

            TwitchWrapper.SendChatMessage(res.CastToString());

            Log.Message(res.CastToString());
        }
예제 #11
0
        public override void RunCommand(ITwitchMessage twitchMessage)
        {
            try
            {
                string[] command = twitchMessage.Message.Split(' ');

                if (command.Length < 3)
                {
                    return;
                }

                string target = command[1].Replace("@", "");
                int    amount;
                bool   isNumeric = int.TryParse(command[2], out amount);
                if (isNumeric)
                {
                    Viewer targeted = Viewers.GetViewer(target);
                    targeted.SetViewerKarma(amount);
                    TwitchWrapper.SendChatMessage($"@{twitchMessage.Username}" + Helper.ReplacePlaceholder("TwitchToolkitSetKarma".Translate(), viewer: targeted.username, karma: amount.ToString()));
                }
            }
            catch (InvalidCastException e)
            {
                Helper.Log("Invalid Check User Command " + e.Message);
            }
        }
예제 #12
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            var    worker   = ArgWorker.CreateInstance(CommandFilter.Parse(twitchMessage.Message).Skip(1));
            string argument = worker.GetNext();

            switch (argument.ToLowerInvariant())
            {
            case "accept":
                ProcessAccept(twitchMessage.Username, worker.GetNextAsViewer());

                return;

            case "decline":
                ProcessDecline(twitchMessage.Username, worker.GetNextAsViewer());

                return;

            default:
                Viewer viewer = Viewers.All.Find(v => string.Equals(v.username, argument, StringComparison.InvariantCultureIgnoreCase));

                if (viewer != null)
                {
                    ProcessRequest(twitchMessage.Username, viewer);
                }
                else
                {
                    MessageHelper.ReplyToUser(twitchMessage.Username, "TKUtils.InvalidViewerQuery".LocalizeKeyed(worker.GetLast()));
                }

                return;
            }
        }
예제 #13
0
        private static bool Prefix([CanBeNull] ITwitchMessage twitchMessage)
        {
            if (twitchMessage?.ChatMessage == null)
            {
                return(false);
            }

            Viewer viewer    = Viewers.GetViewer(twitchMessage.Username);
            var    component = Current.Game.GetComponent <GameComponentPawns>();

            ToolkitSettings.ViewerColorCodes[twitchMessage.Username.ToLowerInvariant()] = twitchMessage.ChatMessage.ColorHex;

            if (TkSettings.HairColor && component.HasUserBeenNamed(twitchMessage.Username) &&
                ColorUtility.TryParseHtmlString(twitchMessage.ChatMessage.ColorHex, out Color hairColor))
            {
                Pawn pawn = component.PawnAssignedToUser(twitchMessage.Username);

                if (pawn?.story != null)
                {
                    pawn.story.hairColor = hairColor;
                }
            }

            viewer.mod        = twitchMessage.HasBadges("moderator", "broadcaster", "global_mod", "staff");
            viewer.subscriber = twitchMessage.HasBadges("subscriber", "founder");
            viewer.vip        = twitchMessage.HasBadges("vip");

            return(false);
        }
예제 #14
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            var parts = new List <string>();
            List <SkillRecord> skills = pawn !.skills.skills;

            foreach (SkillRecord skill in skills)
            {
                var container = "";

                container += ResponseHelper.JoinPair(skill.def.LabelCap, skill.TotallyDisabled ? ResponseHelper.ForbiddenGlyph.AltText("-") : skill.levelInt.ToString());

                container += !Interests.Active
                    ? string.Concat(Enumerable.Repeat(ResponseHelper.FireGlyph.AltText("+"), (int)skill.passion))
                    : Interests.GetIconForPassion(skill);

                parts.Add(container);
            }

            twitchMessage.Reply(parts.SectionJoin().WithHeader("StatsReport_Skills".Localize()));
        }
예제 #15
0
        public override void ParseMessage(ITwitchMessage twitchMessage)
        {
            if (twitchMessage.Message.StartsWith("!lookup"))
            {
                string[] command = twitchMessage.Message.Split(' ');
                if (command.Length < 2)
                {
                    return;
                }

                string searchObject = command[1].ToLower();

                if (searchObject == null || searchObject == "")
                {
                    return;
                }

                string searchQuery = null;

                if (command.Length > 2)
                {
                    searchQuery = command[2].ToLower();
                }

                if (searchQuery == null)
                {
                    searchQuery = "";
                }

                FindLookup(twitchMessage, searchObject, searchQuery);
            }

            Store_Logger.LogString("Finished lookup parse");
        }
예제 #16
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            List <string> queries = CommandFilter.Parse(twitchMessage.Message).Skip(1).Select(PurchaseHelper.ToToolkit).ToList();

            if (queries.Count <= 0)
            {
                queries.AddRange(DefaultStats);
            }

            List <StatDef> container = queries.Select(FindStat).Where(s => s != null).ToList();

            if (container.Count <= 0)
            {
                return;
            }

            CommandRouter.MainThreadCommands.Enqueue(
                () =>
            {
                MessageHelper.ReplyToUser(twitchMessage.Username, container.Select(s => FormatStat(pawn, s)).SectionJoin());
            }
                );
        }
        public static void ResolvePurchase(Viewer viewer, ITwitchMessage twitchMessage, bool separateChannel = false)
        {
            List <string> command = twitchMessage.Message.Split(' ').ToList();

            if (command.Count < 2)
            {
                return;
            }

            if (command[0] == "!levelskill")
            {
                command[0] = "levelskill";
                command.Insert(0, "!buy");
            }

            string productKey       = command[1].ToLower();
            string formattedMessage = string.Join(" ", command.ToArray());

            StoreIncidentSimple incident = allStoreIncidentsSimple.Find(s => productKey.ToLower() == s.abbreviation);

            if (incident != null)
            {
                ResolvePurchaseSimple(viewer, twitchMessage, incident, formattedMessage);
                return;
            }

            StoreIncidentVariables incidentVariables = allStoreIncidentsVariables.Find(s => productKey.ToLower() == s.abbreviation);

            if (incidentVariables != null)
            {
                ResolvePurchaseVariables(viewer, twitchMessage, incidentVariables, formattedMessage);
                return;
            }

            Item item = StoreInventory.items.Find(s => s.abr == productKey);

            Helper.Log($"abr: {productKey} ");

            if (item != null)
            {
                List <String> commandSplit = twitchMessage.Message.Split(' ').ToList();
                commandSplit.Insert(1, "item");

                if (commandSplit.Count < 4)
                {
                    commandSplit.Add("1");
                }

                if (!int.TryParse(commandSplit[3], out int quantity))
                {
                    commandSplit.Insert(3, "1");
                }

                formattedMessage = string.Join(" ", commandSplit.ToArray());

                ResolvePurchaseVariables(viewer, twitchMessage, StoreIncidentDefOf.Item, formattedMessage);
            }

            return;
        }
예제 #18
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            int stuck = Purchase_Handler.viewerNamesDoingVariableCommands.Count;

            Purchase_Handler.viewerNamesDoingVariableCommands = new List <string>();

            twitchMessage.Reply("TKUtils.Unstick".LocalizeKeyed(stuck.ToString()));
        }
예제 #19
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            TkSettings.StoreState = !TkSettings.StoreState;

            string response = TkSettings.StoreState ? "Enabled" : "Disabled";

            twitchMessage.Reply($"TKUtils.ToggleStore.{response}".Localize());
        }
예제 #20
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            List <string> factions = Current.Game.World.factionManager.AllFactionsVisibleInViewOrder.Where(f => !f.IsPlayer)
                                     .Select(f => ResponseHelper.JoinPair(f.GetCallLabel(), f.PlayerGoodwill.ToStringWithSign()))
                                     .ToList();

            twitchMessage.Reply((factions.Count <= 0 ? "TKUtils.Factions.None".Localize() : factions.SectionJoin()).WithHeader("WorldFactionsTab".Localize()));
        }
예제 #21
0
        public override void ParseMessage(ITwitchMessage twitchMessage)
        {
            if (twitchMessage.ChatMessage != null && twitchMessage.ChatMessage.Bits > 0)
            {
                currentBitCounter += twitchMessage.ChatMessage.Bits;

                CheckIfCanRaid();
            }
        }
예제 #22
0
        public override void RunCommand(ITwitchMessage twitchMessage)
        {
            if (Current.Game?.CurrentMap == null)
            {
                return;
            }

            twitchMessage.Reply(ResponseHelper.JoinPair("ThisMapColonyWealthTotal".Localize(), Current.Game.CurrentMap.wealthWatcher.WealthTotal.ToString("N0")));
        }
예제 #23
0
        public override void RunCommand(ITwitchMessage twitchMessage)
        {
            Viewer viewer = Viewers.GetViewer(twitchMessage.Username);

            if (twitchMessage.Message.Split(' ').Count() < 2)
            {
                return;
            }
            Purchase_Handler.ResolvePurchase(viewer, twitchMessage);
        }
예제 #24
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            List <Pawn> colonists = Find.ColonistBar?.GetColonistsInOrder();

            twitchMessage.Reply(
                colonists == null || colonists.Count <= 0
                    ? "TKUtils.ColonistCount.None".Localize()
                    : "TKUtils.ColonistCount.Any".LocalizeKeyed(colonists.Count.ToString("N0"))
                );
        }
예제 #25
0
        internal static ITwitchMessage WithMessage([NotNull] this ITwitchMessage m, string message)
        {
            if (m.WhisperMessage != null)
            {
                return(new WhisperMessage(
                           m.WhisperMessage.Badges,
                           m.WhisperMessage.ColorHex,
                           m.WhisperMessage.Color,
                           m.WhisperMessage.Username,
                           m.WhisperMessage.DisplayName,
                           m.WhisperMessage.EmoteSet,
                           m.WhisperMessage.ThreadId,
                           m.WhisperMessage.MessageId,
                           m.WhisperMessage.UserId,
                           m.WhisperMessage.IsTurbo,
                           m.WhisperMessage.BotUsername,
                           message,
                           m.WhisperMessage.UserType
                           ));
            }

            if (m.ChatMessage != null)
            {
                return(new ChatMessage(
                           m.ChatMessage.BotUsername,
                           m.ChatMessage.UserId,
                           m.ChatMessage.Username,
                           m.ChatMessage.DisplayName,
                           m.ChatMessage.ColorHex,
                           m.ChatMessage.Color,
                           m.ChatMessage.EmoteSet,
                           message,
                           m.ChatMessage.UserType,
                           m.ChatMessage.Channel,
                           m.ChatMessage.Id,
                           m.ChatMessage.IsSubscriber,
                           m.ChatMessage.SubscribedMonthCount,
                           m.ChatMessage.RoomId,
                           m.ChatMessage.IsTurbo,
                           m.ChatMessage.IsModerator,
                           m.ChatMessage.IsMe,
                           m.ChatMessage.IsBroadcaster,
                           m.ChatMessage.Noisy,
                           m.ChatMessage.RawIrcMessage,
                           m.ChatMessage.EmoteReplacedMessage,
                           m.ChatMessage.Badges,
                           m.ChatMessage.CheerBadge,
                           m.ChatMessage.Bits,
                           m.ChatMessage.BitsInDollars
                           ));
            }

            return(null);
        }
예제 #26
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize().WithHeader("TabGear".Localize()));

                return;
            }

            twitchMessage.Reply(GetPawnGear(pawn).WithHeader("TabGear".Localize()));
        }
예제 #27
0
        public void RunCommand(ITwitchMessage twitchMessage)
        {
            if (command == null)
            {
                throw new Exception("Command is null");
            }

            CommandDriver driver = (CommandDriver)Activator.CreateInstance(commandDriver);

            driver.command = this;
            driver.RunCommand(twitchMessage);
        }
예제 #28
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            string             query = CommandFilter.Parse(twitchMessage.Message).Skip(1).FirstOrDefault();
            ResearchProjectDef project;

            if (query.NullOrEmpty())
            {
                project = Current.Game.researchManager.currentProj;
            }
            else
            {
                project = DefDatabase <ResearchProjectDef> .AllDefs.FirstOrDefault(
                    p => p.defName.EqualsIgnoreCase(query) || p.label.ToToolkit().EqualsIgnoreCase(query !.ToToolkit())
                    );


                if (project == null)
                {
                    ThingDef thing = DefDatabase <ThingDef> .AllDefs.FirstOrDefault(
                        t => t.defName.EqualsIgnoreCase(query) || t.label?.ToToolkit()?.EqualsIgnoreCase(query !.ToToolkit()) == true
                        );

                    project = thing?.recipeMaker?.researchPrerequisite;
                    project ??= thing?.recipeMaker?.researchPrerequisites?.FirstOrDefault(p => !p.IsFinished);
                }
            }

            if (project == null)
            {
                twitchMessage.Reply(
                    (!query.NullOrEmpty() ? "TKUtils.Research.InvalidQuery".LocalizeKeyed(query) : "TKUtils.Research.None".Localize()).WithHeader("Research".Localize())
                    );

                return;
            }

            var segments = new List <string> {
                ResponseHelper.JoinPair(project.LabelCap, project.ProgressPercent.ToStringPercent())
            };

            if (project.prerequisites != null && !project.PrerequisitesCompleted)
            {
                List <ResearchProjectDef> prerequisites = project.prerequisites;

                string[] container = prerequisites.Where(prerequisite => !prerequisite.IsFinished)
                                     .Select(prerequisite => ResponseHelper.JoinPair(prerequisite.LabelCap, prerequisite.ProgressPercent.ToStringPercent()))
                                     .ToArray();

                segments.Add(ResponseHelper.JoinPair("ResearchPrerequisites".Localize(), container.SectionJoin()));
            }

            twitchMessage.Reply(segments.GroupedJoin().WithHeader("Research".Localize()));
        }
예제 #29
0
        public override void ParseMessage(ITwitchMessage twitchMessage)
        {
            if (twitchMessage.ChatMessage == null)
            {
                return;
            }

            if (twitchMessage.ChatMessage.Bits > 0)
            {
                TriggerController.CheckForBitEvents(twitchMessage.ChatMessage.Bits, twitchMessage.ChatMessage.DisplayName);
            }
        }
예제 #30
0
        public static void CheckCommand(ITwitchMessage twitchMessage)
        {
            Log.Message($"Checking command - {twitchMessage.Message}");

            if (twitchMessage == null)
            {
                return;
            }

            if (twitchMessage.Message == null)
            {
                return;
            }

            string message = twitchMessage.Message;
            string user    = twitchMessage.Username;

            Viewer viewer = Viewers.GetViewer(user);

            viewer.last_seen = DateTime.Now;

            if (viewer.IsBanned)
            {
                return;
            }

            Command commandDef = DefDatabase <Command> .AllDefs.ToList().Find(s => twitchMessage.Message.StartsWith("!" + s.command));

            if (commandDef != null)
            {
                bool runCommand = true;

                if (commandDef.requiresMod && (!viewer.mod && viewer.username.ToLower() != ToolkitSettings.Channel.ToLower()))
                {
                    runCommand = false;
                }

                if (commandDef.requiresAdmin && twitchMessage.Username.ToLower() != ToolkitSettings.Channel.ToLower())
                {
                    runCommand = false;
                }

                if (!commandDef.enabled)
                {
                    runCommand = false;
                }

                if (runCommand)
                {
                    commandDef.RunCommand(twitchMessage);
                }
            }
        }