public override void RunCommand(IRCMessage message)
        {
            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);
                    Toolkit.client.SendMessage(modmsg, CommandsHandler.SendToChatroom(message));
                    modmsg = "";
                }
            }
            return;
        }
Example #2
0
 public override void RunCommand(TwitchIRCMessage message)
 {
     if (message.Message.Split(' ').Count() < 2)
     {
         return;
     }
     Purchase_Handler.ResolvePurchase(message.Viewer, message, CommandsHandler.SendToChatroom(message));
 }
Example #3
0
        public override void RunCommand(TwitchIRCMessage message)
        {
            Helper.Log("running balance command");

            Toolkit.client.SendMessage(
                $"@{message.Viewer.UsernameCap} " + Helper.ReplacePlaceholder("TwitchToolkitBalanceMessage".Translate(),
                                                                              amount: message.Viewer.Coins.ToString(), karma: message.Viewer.Karma.ToString()),
                CommandsHandler.SendToChatroom(message)
                );
        }
        public override void RunCommand(IRCMessage message)
        {
            Viewer viewer = Viewers.GetViewer(message.User);

            if (message.Message.Split(' ').Count() < 2)
            {
                return;
            }
            Purchase_Handler.ResolvePurchase(viewer, message, CommandsHandler.SendToChatroom(message));
        }
        public override void RunCommand(IRCMessage message)
        {
            Command buyCommand = DefDatabase <Command> .GetNamed("Buy");

            string minutess     = ToolkitSettings.CoinInterval > 1 ? "s" : "";
            string storeon      = buyCommand.enabled ? "TwitchToolkitOn".Translate() : "TwitchToolkitOff".Translate();
            string earningcoins = ToolkitSettings.EarningCoins ? "TwitchToolkitOn".Translate() : "TwitchToolkitOff".Translate();

            string stats_message = Helper.ReplacePlaceholder("TwitchToolkitModSettings".Translate(),
                                                             amount: ToolkitSettings.CoinAmount.ToString(),
                                                             first: ToolkitSettings.CoinInterval.ToString(),
                                                             second: storeon,
                                                             third: earningcoins,
                                                             karma: ToolkitSettings.KarmaCap.ToString()
                                                             );

            Toolkit.client.SendMessage(stats_message, CommandsHandler.SendToChatroom(message));
        }
        public override void RunCommand(IRCMessage message)
        {
            List <Command> commands = DefDatabase <Command> .AllDefs.Where(s => !s.requiresAdmin && !s.requiresMod && s.enabled).ToList();

            string output = "@" + message.User + " viewer commands: ";


            for (int i = 0; i < commands.Count; i++)
            {
                output += "!" + commands[i].command;

                if (i < commands.Count - 1)
                {
                    output += ", ";
                }
            }

            Toolkit.client.SendMessage(output, CommandsHandler.SendToChatroom(message));
        }
        protected static void SendWrappedOutputText(string text, IRCMessage message)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            string[] originalLines = text.Split(new string[] { " " },
                                                StringSplitOptions.None);

            List <string> wrappedLines = new List <string>();

            StringBuilder actualLine   = new StringBuilder();
            int           actualLength = 0;

            foreach (var item in originalLines)
            {
                if (actualLength + item.Length + 1 > TWITCH_MSG_MAX_SIZE - 5)
                {
                    actualLine.Append("(...)");
                    wrappedLines.Add(actualLine.ToString());
                    actualLine   = new StringBuilder();
                    actualLength = 0;
                }

                actualLine.Append(item + " ");
                actualLength += item.Length + 1;
            }

            if (actualLine.Length > 0)
            {
                wrappedLines.Add(actualLine.ToString());
            }

            if (wrappedLines.Count > 0)
            {
                foreach (string outputMessage in wrappedLines)
                {
                    Toolkit.client.SendMessage(outputMessage, CommandsHandler.SendToChatroom(message));
                }
            }
        }
Example #8
0
        public void SendTenResults(IRCMessage msg, string searchObject, string searchQuery, string[] results)
        {
            if (results.Count() < 1)
            {
                return;
            }

            string output = "Lookup for " + searchObject + " \"" + searchQuery + "\": ";

            for (int i = 0; i < results.Count(); i++)
            {
                output += results[i].CapitalizeFirst();
                if (i != results.Count() - 1)
                {
                    output += ", ";
                }
            }

            Toolkit.client.SendMessage(output, CommandsHandler.SendToChatroom(msg));
        }
Example #9
0
 public override void RunCommand(TwitchIRCMessage message)
 {
     if (ToolkitSettings.EarningCoins)
     {
         ToolkitSettings.EarningCoins = false;
         Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitEarningCoinsMessage".Translate() + " " + "TwitchToolkitOff".Translate(), CommandsHandler.SendToChatroom(message));
     }
     else
     {
         ToolkitSettings.EarningCoins = true;
         Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitEarningCoinsMessage".Translate() + " " + "TwitchToolkitOn".Translate(), CommandsHandler.SendToChatroom(message));
     }
 }
Example #10
0
        public override void RunCommand(TwitchIRCMessage message)
        {
            try
            {
                string[] command = message.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 = ViewerModel.GetViewerByTypeAndUsername(target, message.Viewer.ViewerType);
                    targeted.Karma = amount;
                    Toolkit.client.SendMessage($"@{message.User}" + Helper.ReplacePlaceholder("TwitchToolkitSetKarma".Translate(), viewer: targeted.Username, karma: amount.ToString()), CommandsHandler.SendToChatroom(message));
                }
            }
            catch (InvalidCastException e)
            {
                Helper.Log("Invalid Check User Command " + e.Message);
            }
        }
Example #11
0
        public override void RunCommand(TwitchIRCMessage message)
        {
            try
            {
                string[] command = message.Message.Split(' ');

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

                string target = command[1].Replace("@", "");

                Viewer targeted = ViewerModel.GetViewerByTypeAndUsername(target, message.Viewer.ViewerType);
                Toolkit.client.SendMessage($"@{message.User} " + Helper.ReplacePlaceholder("TwitchToolkitCheckUser".Translate(), viewer: targeted.Username, amount: targeted.Coins.ToString(), karma: targeted.Karma.ToString()), CommandsHandler.SendToChatroom(message));
            }
            catch (InvalidCastException e)
            {
                Helper.Log("Invalid Check User Command " + e.Message);
            }
        }
Example #12
0
        public override void RunCommand(IRCMessage message)
        {
            Viewer viewer = Viewers.GetViewer(message.User);

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

            if (pawnComponent.HasUserBeenNamed(message.User) || pawnComponent.UserInViewerQueue(message.User))
            {
                return;
            }

            if (ToolkitSettings.ChargeViewersForQueue)
            {
                if (viewer.GetViewerCoins() < ToolkitSettings.CostToJoinQueue)
                {
                    Toolkit.client.SendMessage($"@{message.User} you do not have enough coins to purchase a ticket, it costs {ToolkitSettings.CostToJoinQueue} and you have {viewer.GetViewerCoins()}.", CommandsHandler.SendToChatroom(message));
                    return;
                }

                viewer.TakeViewerCoins(ToolkitSettings.CostToJoinQueue);
            }

            pawnComponent.AddViewerToViewerQueue(message.User);
            Toolkit.client.SendMessage($"@{message.User} you have purchased a ticket and are in the queue!", CommandsHandler.SendToChatroom(message));
        }
Example #13
0
        public override void RunCommand(IRCMessage message)
        {
            Viewer viewer = Viewers.GetViewer(message.User);

            string[] command = message.Message.Split(' ');

            if (command.Count() < 3)
            {
                Log.Message("command not long enough");
                return;
            }

            string target = command[1].Replace("@", "");

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

            if (isNumeric && amount > 0)
            {
                Viewer giftee = Viewers.GetViewer(target);

                if (ToolkitSettings.KarmaReqsForGifting)
                {
                    if (giftee.GetViewerKarma() < ToolkitSettings.MinimumKarmaToRecieveGifts || viewer.GetViewerKarma() < ToolkitSettings.MinimumKarmaToSendGifts)
                    {
                        return;
                    }
                }

                if (viewer.GetViewerCoins() >= amount)
                {
                    viewer.TakeViewerCoins(amount);
                    giftee.GiveViewerCoins(amount);
                    Toolkit.client.SendMessage($"@{giftee.username} " + Helper.ReplacePlaceholder("TwitchToolkitGiftCoins".Translate(), amount: amount.ToString(), from: viewer.username), CommandsHandler.SendToChatroom(message));
                    Store_Logger.LogGiftCoins(viewer.username, giftee.username, amount);
                }
            }
        }
Example #14
0
 public override void RunCommand(IRCMessage message)
 {
     Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitPurchaseList".Translate() + $" {ToolkitSettings.CustomPricingSheetLink}", CommandsHandler.SendToChatroom(message));
 }
Example #15
0
        public override void RunCommand(IRCMessage message)
        {
            Viewer viewer = Viewers.GetViewer(message.User);

            Toolkit.client.SendMessage($"@{viewer.username} " + "TwitchToolkitWhatIsKarma".Translate() + $" { viewer.GetViewerKarma()}%", CommandsHandler.SendToChatroom(message));
        }
Example #16
0
 public override void RunCommand(TwitchIRCMessage message)
 {
     Toolkit.client.SendMessage($"@{message.Viewer.UsernameCap} " + "TwitchToolkitWhatIsKarma".Translate() + $" { message.Viewer.Karma}%", CommandsHandler.SendToChatroom(message));
 }
Example #17
0
        public override void RunCommand(TwitchIRCMessage message)
        {
            string[] command = message.Message.Split(' ');

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

            string target = command[1].Replace("@", "");

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

            if (isNumeric && amount > 0)
            {
                Viewer giftee = Viewers.NewViewers.GetViewerByTypeAndUsername(target, message.Viewer.ViewerType);

                if (giftee == null)
                {
                    Toolkit.client.SendMessage($"@{message.Viewer.UsernameCap} viewer not found.");
                    return;
                }

                if (ToolkitSettings.KarmaReqsForGifting)
                {
                    if (giftee.Karma < ToolkitSettings.MinimumKarmaToRecieveGifts || message.Viewer.Karma < ToolkitSettings.MinimumKarmaToSendGifts)
                    {
                        return;
                    }
                }

                if (message.Viewer.Coins >= amount)
                {
                    message.Viewer.GiveCoins(amount);
                    giftee.GiveCoins(amount);
                    Toolkit.client.SendMessage($"@{giftee.UsernameCap} " + Helper.ReplacePlaceholder("TwitchToolkitGiftCoins".Translate(), amount: amount.ToString(), from: message.Viewer.UsernameCap), CommandsHandler.SendToChatroom(message));
                }
            }
        }
Example #18
0
        public override void RunCommand(TwitchIRCMessage message)
        {
            try
            {
                string[] command = message.Message.Split(' ');

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

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

                if (isNumeric)
                {
                    foreach (Viewer vwr in ViewerModel.All)
                    {
                        vwr.GiveCoins(amount);
                    }

                    Toolkit.client.SendMessage($"@{message.User} " + Helper.ReplacePlaceholder("TwitchToolkitGiveAllCoins".Translate(), amount: amount.ToString()), CommandsHandler.SendToChatroom(message));
                }
            }
            catch (InvalidCastException e)
            {
                Helper.Log("Give All Coins Syntax Error " + e.Message);
            }
        }
Example #19
0
        public override void RunCommand(IRCMessage message)
        {
            Viewer viewer = Viewers.GetViewer(message.User);

            Toolkit.client.SendMessage($"@{viewer.username} " + Helper.ReplacePlaceholder("TwitchToolkitBalanceMessage".Translate(), amount: viewer.GetViewerCoins().ToString(), karma: viewer.GetViewerKarma().ToString()), CommandsHandler.SendToChatroom(message));
        }
        protected static Pawn GetPawnIfAllowed(IRCMessage message)
        {
            Viewer             viewer    = Viewers.GetViewer(message.User);
            GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

            if (!CommandsHandler.AllowCommand(message))
            {
                // No commands allowed in this channel
                return(null);
            }

            Log.Message($"Parsing command {message.Message} from {message.User}");

            if (!component.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you are not in the colony.", CommandsHandler.SendToChatroom(message));
                return(null);
            }

            return(component.PawnAssignedToUser(viewer.username));
        }
Example #21
0
 public override void RunCommand(IRCMessage message)
 {
     Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitModInfo".Translate() + " https://discord.gg/qrtg224 !", CommandsHandler.SendToChatroom(message));
 }
Example #22
0
        public override void ParseCommand(TwitchIRCMessage msg)
        {
            GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

            if (msg.Message.StartsWith("!mypawnskills") && CommandsHandler.AllowCommand(msg))
            {
                if (!component.HasUserBeenNamed(msg.Viewer.Username))
                {
                    Toolkit.client.SendMessage($"@{msg.Viewer.Username} you are not in the colony.", CommandsHandler.SendToChatroom(msg));
                    return;
                }

                Pawn   pawn   = component.PawnAssignedToUser(msg.Viewer.Username);
                string output = $"@{msg.Viewer.Username} {pawn.Name.ToStringShort.CapitalizeFirst()}'s skill levels are ";

                List <SkillRecord> skills = pawn.skills.skills;

                for (int i = 0; i < skills.Count; i++)
                {
                    if (skills[i].TotallyDisabled)
                    {
                        output += $"{skills[i].def.LabelCap}: -";
                    }
                    else
                    {
                        output += $"{skills[i].def.LabelCap}: {skills[i].levelInt}";
                    }

                    if (skills[i].passion == Passion.Minor)
                    {
                        output += "+";
                    }
                    if (skills[i].passion == Passion.Major)
                    {
                        output += "++";
                    }

                    if (i != skills.Count - 1)
                    {
                        output += ", ";
                    }
                }

                Toolkit.client.SendMessage(output, CommandsHandler.SendToChatroom(msg));
            }

            if (msg.Message.StartsWith("!mypawnstory") && CommandsHandler.AllowCommand(msg))
            {
                if (!component.HasUserBeenNamed(msg.Viewer.Username))
                {
                    Toolkit.client.SendMessage($"@{msg.Viewer.Username} you are not in the colony.", CommandsHandler.SendToChatroom(msg));
                    return;
                }

                Pawn pawn = component.PawnAssignedToUser(msg.Viewer.Username);

                string output = $"@{msg.Viewer.Username} About {pawn.Name.ToStringShort.CapitalizeFirst()}: ";

                List <Backstory> backstories = pawn.story.AllBackstories.ToList();

                for (int i = 0; i < backstories.Count; i++)
                {
                    output += backstories[i].title;
                    if (i != backstories.Count - 1)
                    {
                        output += ", ";
                    }
                }

                output += " | " + pawn.gender;

                StringBuilder stringBuilder            = new StringBuilder();
                WorkTags      combinedDisabledWorkTags = pawn.story.CombinedDisabledWorkTags;
                if (combinedDisabledWorkTags == WorkTags.None)
                {
                    stringBuilder.Append("(" + "NoneLower".Translate() + "), ");
                }
                else
                {
                    List <WorkTags> list  = WorkTagsFrom(combinedDisabledWorkTags).ToList <WorkTags>();
                    bool            flag2 = true;
                    foreach (WorkTags tags in list)
                    {
                        if (flag2)
                        {
                            stringBuilder.Append(tags.LabelTranslated().CapitalizeFirst());
                        }
                        else
                        {
                            stringBuilder.Append(tags.LabelTranslated());
                        }
                        stringBuilder.Append(", ");
                        flag2 = false;
                    }
                }
                string text = stringBuilder.ToString();
                text = text.Substring(0, text.Length - 2);

                output += " | Incapable of: " + text;

                output += " | Traits: ";

                List <Trait> traits = pawn.story.traits.allTraits;
                for (int i = 0; i < traits.Count; i++)
                {
                    output += traits[i].LabelCap;

                    if (i != traits.Count - 1)
                    {
                        output += ", ";
                    }
                }

                Toolkit.client.SendMessage(output, CommandsHandler.SendToChatroom(msg));
            }

            if (msg.Message.StartsWith("!changepawnname") && CommandsHandler.AllowCommand(msg))
            {
                string[] command = msg.Message.Split(' ');

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

                string newName = command[1];

                if (newName == null || newName == "" || newName.Length > 16)
                {
                    Toolkit.client.SendMessage($"@{msg.Viewer.Username} your name can be up to 16 characters.", CommandsHandler.SendToChatroom(msg));
                    return;
                }

                if (!component.HasUserBeenNamed(msg.Viewer.Username))
                {
                    Toolkit.client.SendMessage($"@{msg.Viewer.Username} you are not in the colony.", CommandsHandler.SendToChatroom(msg));
                    return;
                }

                if (!Purchase_Handler.CheckIfViewerHasEnoughCoins(msg.Viewer, 500, true))
                {
                    return;
                }

                msg.Viewer.TakeCoins(500);
                nameRequests.Add(msg.Viewer.Username, newName);
                Toolkit.client.SendMessage($"@{ToolkitSettings.Channel} {msg.Viewer.Username} has requested to be named {newName}, use !approvename @{msg.Viewer.Username} or !declinename @{msg.Viewer.Username}", false);
            }

            if (msg.Viewer.Mod || msg.Viewer.Username == ToolkitSettings.Channel)
            {
                if (msg.Message.StartsWith("!unstickpeople"))
                {
                    Purchase_Handler.viewerNamesDoingVariableCommands = new List <string>();
                }

                if (msg.Message.StartsWith("!approvename"))
                {
                    string[] command = msg.Message.Split(' ');

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

                    string username = command[1].Replace("@", "");

                    if (username == null || username == "" || !nameRequests.ContainsKey(username))
                    {
                        Toolkit.client.SendMessage($"@{msg.Viewer.Username} invalid username", CommandsHandler.SendToChatroom(msg));
                        return;
                    }

                    if (!component.HasUserBeenNamed(username))
                    {
                        return;
                    }

                    Pawn       pawn = component.PawnAssignedToUser(username);
                    NameTriple old  = pawn.Name as NameTriple;
                    pawn.Name = new NameTriple(old.First, nameRequests[username], old.Last);
                    Toolkit.client.SendMessage($"@{msg.Viewer.Username} approved request for name change from {old} to {pawn.Name}");
                }

                if (msg.Message.StartsWith("!declinename"))
                {
                    string[] command = msg.Message.Split(' ');

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

                    string username = command[1].Replace("@", "");

                    if (username == null || username == "" || !nameRequests.ContainsKey(username))
                    {
                        Toolkit.client.SendMessage($"@{msg.Viewer.Username} invalid username", CommandsHandler.SendToChatroom(msg));
                        return;
                    }

                    if (!component.HasUserBeenNamed(username))
                    {
                        return;
                    }

                    nameRequests.Remove(username);
                    Toolkit.client.SendMessage($"@{msg.Viewer.Username} declined name change request from {username}");
                }
            }

            Store_Logger.LogString("Parsed pawn command");
        }
Example #23
0
        public override void RunCommand(TwitchIRCMessage message)
        {
            try
            {
                string[] command = message.Message.Split(' ');

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

                string receiver = command[1].Replace("@", "");

                if (message.User.ToLower() != ToolkitSettings.Channel.ToLower() && receiver.ToLower() == message.User.ToLower())
                {
                    Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitModCannotGiveCoins".Translate());
                    return;
                }

                int  amount;
                bool isNumeric = int.TryParse(command[2], out amount);
                if (isNumeric)
                {
                    Viewer giftee = ViewerModel.GetViewerByTypeAndUsername(receiver, message.Viewer.ViewerType);

                    Helper.Log($"Giving viewer {giftee.Username} {amount} coins");
                    giftee.GiveCoins(amount);
                    Toolkit.client.SendMessage($"@{message.User} " + Helper.ReplacePlaceholder("TwitchToolkitGivingCoins".Translate(), viewer: giftee.Username, amount: amount.ToString(), newbalance: giftee.Coins.ToString()), CommandsHandler.SendToChatroom(message));
                    Store_Logger.LogGiveCoins(message.User, giftee.Username, amount);
                }
            }
            catch (InvalidCastException e)
            {
                Helper.Log("Invalid Give Viewer Coins Command " + e.Message);
            }
        }
Example #24
0
        public override void RunCommand(IRCMessage message)
        {
            Command allCommandsCommand = DefDatabase <Command> .GetNamed("AvailableCommands");

            Toolkit.client.SendMessage($"@{message.User} the toolkit is a mod where you earn coins while you watch. Check out the bit.ly/toolkit-guide  or use !" + allCommandsCommand.command + " for a short list. " + ToolkitSettings.Channel.CapitalizeFirst() + " has a list of items/events to purchase at " + ToolkitSettings.CustomPricingSheetLink, CommandsHandler.SendToChatroom(message));
        }