示例#1
0
 protected void HandleTimeMessage(IRCMessage message)
 {
     Bot.SendChannelMessage(
         message.Channel,
         String.Format("The time is now {0}.", DateTime.Now.ToShortTimeString())
     );
 }
        public void HandlesJustOrigin()
        {
            var parsed = new IRCMessage(":[email protected]");

            Assert.AreEqual(parsed.Command, null, "Somehow parsed a command");
            Assert.AreEqual(parsed.Arguments.Length, 0, "Somehow parsed an argument");
        }
        public void MessageToString()
        {
            string message = ":[email protected] PRIVMSG ###cards :!card 4 2";
            var parsed = new IRCMessage(message);
            var tostring = parsed.ToString();

            Assert.AreEqual(message, tostring);
        }
        public void ParsesArguments()
        {
            string message = ":[email protected] PRIVMSG ###cards :!card 4 2";
            var parsed = new IRCMessage(message);

            Assert.AreEqual(2, parsed.Arguments.Length, "Invalid argument count");

            Assert.AreEqual("###cards", parsed.Arguments[0], "Parsed first argument incorrectly");
            Assert.AreEqual("!card 4 2", parsed.Arguments[1], "Parsed second argument incorrectly");
        }
示例#5
0
        protected void HandleMessageList(IRCMessage message)
        {
            IEnumerable<string> pluginList = GetAllClasses("IRCBot.Plugins");

            string answer = pluginList.Aggregate(
                "Following plugins are currently loaded:",
                (current, pluginName) => current + (", '" + pluginName + "'")
            ) + ".";

            Bot.SendChannelMessage(message.Channel, answer);
        }
        public void HandlesEmptyStrings()
        {
            var parsed = new IRCMessage("");

            Assert.AreEqual(parsed.Command, null, "Somehow parsed a command");
            Assert.AreEqual(parsed.Arguments.Length, 0, "Somehow parsed an argument");

            Assert.AreEqual(parsed.Origin.Host, null, "Somehow parsed a host");
            Assert.AreEqual(parsed.Origin.User, null, "Somehow parsed a user");
            Assert.AreEqual(parsed.Origin.Nick, null, "Somehow parsed a nick");
        }
示例#7
0
        protected void HandleMessageList(IRCMessage message)
        {
            List<string> pluginList = MetaPlugin.GetAllClasses("IRCBot.Plugins");

            string answer = "Following plugins are currently loaded:";

            foreach(string pluginName in pluginList)
                answer += ", '"+pluginName+"'";

            answer += ".";

            Bot.SendChannelMessage(message.Channel, answer);
        }
示例#8
0
        protected void HandleCalculation(IRCMessage message)
        {
            string expression = message.Message.Substring(1);

            try
            {
                var value = MathInterpreter.InterpretSingle(expression);

                Bot.SendChannelMessage(
                    message.Channel,
                    String.Format("Result: {0}", value)
                );
            }
            catch (Exception ex)
            {
                Bot.SendChannelMessage(
                    message.Channel,
                    "Error: " + ex.Message
                );
            }
        }
示例#9
0
        protected void ShortenUrl(IRCMessage message)
        {
            var match = UrlRegex.Match(message.Message);
            var uri = new Uri(message.Message.Substring(match.Index, match.Length));

            // Skip shortened urls
            if (Array.IndexOf(UrlShorteners, uri.Host) >= 0)
                return;

            // Skip short urls
            if (match.Value.Length <= 20)
                return;

            // Create new json
            var table = new Hashtable { { "longUrl", match.Value } };
            string json = JsonWriter.Write(table);

            // Post the data to the google url api
            _poster.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            _poster.UploadStringAsync(ApiUrl, null, json, message);
        }
示例#10
0
        protected void ShortenUrl(IRCMessage message)
        {
            if (message.Message.StartsWith("!"))
                return;

            Match match = Regex.Match(message.Message, UrlRegex);

            // Skip shortened urls
            if (match.Value.Contains("goo.gl"))
                return;

            // Skip short urls
            if (match.Value.Length <= 20)
                return;

            // Create new json
            Hashtable table = new Hashtable();
            table.Add("longUrl", match.Value);
            string json = JsonWriter.Write(table);

            // Post the data to the google url api
            poster.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            poster.UploadStringAsync(ApiUrl, null, json, message);
        }
示例#11
0
        protected void HandleMessage(IRCMessage message)
        {
            string [] splittedString = message.Message.Split(' ');

            if(splittedString.GetLength(0) > 1)
            {
                switch (splittedString[1]) {
                    case "list":
                        HandleMessageList(message);
                        break;
                    case "help":
                        Bot.SendChannelMessage(message.Channel, "Help for !plugin that still needs to be written.");
                        Bot.SendChannelMessage(message.Channel, "!plugin help - Shows help (this message)");
                        Bot.SendChannelMessage(message.Channel, "!plugin list - Shows list of loaded plugins");
                        break;
                    default:
                        Bot.SendChannelMessage(message.Channel, "Unknown command, use !plugin help to see the help.");
                        break;
                }
            }	else
            {
                Bot.SendChannelMessage(message.Channel, "Please provide a command, use !plugin help to see the help.");
            }
        }
示例#12
0
        public override void ParseCommand(IRCMessage msg)
        {
            Viewer viewer = Viewers.GetViewer(msg.User);

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

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

                Pawn   pawn   = component.PawnAssignedToUser(viewer.username);
                string output = $"@{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(viewer.username))
                {
                    Toolkit.client.SendMessage($"@{viewer.username} you are not in the colony.", CommandsHandler.SendToChatroom(msg));
                    return;
                }

                Pawn pawn = component.PawnAssignedToUser(viewer.username);

                string output = $"@{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($"@{viewer.username} your name can be up to 16 characters.", CommandsHandler.SendToChatroom(msg));
                    return;
                }

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

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

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

            if (Viewer.IsModerator(viewer.username) || 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($"@{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($"@{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($"@{viewer.username} invalid username", CommandsHandler.SendToChatroom(msg));
                        return;
                    }

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

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

            Store_Logger.LogString("Parsed pawn command");
        }
示例#13
0
            public static IRCMessage Parse(string message)
            {
                var result = new IRCMessage();

                var parts = message.Split(' ');
                if (parts[0].StartsWith(":"))
                {
                    result.Source = parts[0].Substring(1);
                    result.Type = parts[1];
                    result.Body = message.Substring(parts[0].Length + 1 + parts[1].Length + 1);
                }
                else
                {
                    result.Type = parts[0];
                    result.Body = message.Substring(parts[0].Length + 1);
                }

                return result;
            }
示例#14
0
        public static void ResolvePurchaseSimple(Viewer viewer, IRCMessage message, StoreIncidentSimple incident, bool separateChannel = false)
        {
            int cost = incident.cost;

            if (cost < 1)
            {
                return;
            }

            if (CheckIfViewerIsInVariableCommandList(viewer.username, separateChannel))
            {
                return;
            }

            if (!CheckIfViewerHasEnoughCoins(viewer, cost, separateChannel))
            {
                return;
            }

            if (CheckIfKarmaTypeIsMaxed(incident, viewer.username, separateChannel))
            {
                return;
            }

            if (CheckIfIncidentIsOnCooldown(incident, viewer.username, separateChannel))
            {
                return;
            }

            IncidentHelper helper = StoreIncidentMaker.MakeIncident(incident);

            if (helper == null)
            {
                Helper.Log("Missing helper for incident " + incident.defName);
                return;
            }

            if (!helper.IsPossible())
            {
                Toolkit.client.SendMessage($"@{viewer.username} " + "TwitchToolkitEventNotPossible".Translate(), separateChannel);
                return;
            }

            if (!ToolkitSettings.UnlimitedCoins)
            {
                viewer.TakeViewerCoins(cost);
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            helper.Viewer  = viewer;
            helper.message = message.Message;

            Ticker.IncidentHelpers.Enqueue(helper);
            Store_Logger.LogPurchase(viewer.username, message.Message);
            component.LogIncident(incident);
            viewer.CalculateNewKarma(incident.karmaType, cost);

            if (ToolkitSettings.PurchaseConfirmations)
            {
                Toolkit.client.SendMessage(
                    Helper.ReplacePlaceholder(
                        "TwitchToolkitEventPurchaseConfirm".Translate(),
                        first: incident.label.CapitalizeFirst(),
                        viewer: viewer.username
                        ),
                    separateChannel
                    );
            }
        }
示例#15
0
 protected bool UserNickChangeHandler(IRCMessage Msg)
 {
     int pos = usersLoggedIn.BinarySearch(Msg.SenderNick);
     if (pos >= 0) {
         usersLoggedIn.RemoveAt(pos);
         String newNick = Msg[0];
         pos = ~usersLoggedIn.BinarySearch(newNick);
         usersLoggedIn.Insert(pos, newNick);
     }
     return true;
 }
示例#16
0
        protected void HandleMode(IRCMessage sIRCMessage)
        {
            if (!IsAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.Operator))
            {
                return;
            }

            var text = sLManager.GetCommandTexts("mode", sIRCMessage.Channel, sIRCMessage.ServerName);

            if (text.Length < 9)
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                return;
            }

            if (!Rfc2812Util.IsValidChannelName(sIRCMessage.Channel))
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ThisIsNotAChannelDoNotWriteInPM", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            if (sIRCMessage.Info.Length < 5)
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoRank", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            string rank = sIRCMessage.Info[4].ToLower();

            if (rank.Length > 5)
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                return;
            }

            if (rank.Split('+').Length == 1 && rank.Split('-').Length == 1)
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                return;
            }

            if (!ModeRegex.IsMatch(rank.Substring(1)))
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[3]);
                return;
            }

            foreach (var c in rank.Substring(1).ToCharArray())
            {
                if (Rfc2812Util.CharToChannelMode(c).ToString().IsNumber())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[4]);
                    return;
                }
            }

            if (sIRCMessage.Info.Length == 5)
            {
                sSender.Mode(sIRCMessage.Channel, sIRCMessage.Info[4].ToLower());
                return;
            }

            if (sIRCMessage.Info.Length < 6)
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            bool   StringEmpty = false;
            string name        = string.Empty;
            string error       = string.Empty;
            string rank2       = string.Empty;
            string status      = string.Empty;

            if (sIRCMessage.Info.Length >= 10)
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[5]);
                return;
            }

            if (rank.Length - 1 > sIRCMessage.Info.Length - 5)
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[6]);
                return;
            }

            if (rank.Length - 1 < sIRCMessage.Info.Length - 5)
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[7]);
                return;
            }

            if (rank.Contains(Rfc2812Util.ModeActionToChar(ModeAction.Remove).ToString()))
            {
                status = Rfc2812Util.ModeActionToChar(ModeAction.Remove).ToString();
            }
            else if (rank.Contains(Rfc2812Util.ModeActionToChar(ModeAction.Add).ToString()))
            {
                status = Rfc2812Util.ModeActionToChar(ModeAction.Add).ToString();
            }

            if (sIRCMessage.Info.Length >= 6 && Rfc2812Util.IsValidNick(sIRCMessage.Info[5]) && sIRCMessage.Info[5].ToLower() != sMyNickInfo.NickStorage.ToLower() && rank.Length > 1 && sChannelList.IsChannelRank(rank.Substring(1, 1)))
            {
                if (status == Rfc2812Util.ModeActionToChar(ModeAction.Remove).ToString())
                {
                    rank2 += rank.Substring(1, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[5];
                }
                else if (status == Rfc2812Util.ModeActionToChar(ModeAction.Add).ToString())
                {
                    rank2 += rank.Substring(1, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[5];
                }
            }
            else if (sIRCMessage.Info.Length >= 6 && !Rfc2812Util.IsValidNick(sIRCMessage.Info[5]) && sIRCMessage.Info[5].ToLower() != sMyNickInfo.NickStorage.ToLower())
            {
                if (!sIRCMessage.Info[5].IsNullOrEmpty())
                {
                    error += ", " + sIRCMessage.Info[5];
                }
                else
                {
                    StringEmpty = true;
                }
            }
            else if (sIRCMessage.Info.Length >= 6 && Rfc2812Util.IsValidNick(sIRCMessage.Info[5]) && sIRCMessage.Info[5].ToLower() == sMyNickInfo.NickStorage.ToLower())
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[0]);
            }

            if (sIRCMessage.Info.Length >= 7 && Rfc2812Util.IsValidNick(sIRCMessage.Info[6]) && sIRCMessage.Info[6].ToLower() != sMyNickInfo.NickStorage.ToLower() && rank.Length > 2 && sChannelList.IsChannelRank(rank.Substring(2).Substring(0, 1)))
            {
                if (status == Rfc2812Util.ModeActionToChar(ModeAction.Remove).ToString())
                {
                    rank2 += rank.Substring(2).Substring(0, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[6];
                }
                else if (status == Rfc2812Util.ModeActionToChar(ModeAction.Add).ToString())
                {
                    rank2 += rank.Substring(2).Substring(0, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[6];
                }
            }
            else if (sIRCMessage.Info.Length >= 7 && !Rfc2812Util.IsValidNick(sIRCMessage.Info[6]) && sIRCMessage.Info[6].ToLower() != sMyNickInfo.NickStorage.ToLower())
            {
                if (!sIRCMessage.Info[6].IsNullOrEmpty())
                {
                    error += ", " + sIRCMessage.Info[6];
                }
                else
                {
                    StringEmpty = true;
                }
            }
            else if (sIRCMessage.Info.Length >= 7 && Rfc2812Util.IsValidNick(sIRCMessage.Info[6]) && sIRCMessage.Info[6].ToLower() == sMyNickInfo.NickStorage.ToLower())
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[0]);
            }

            if (sIRCMessage.Info.Length >= 8 && Rfc2812Util.IsValidNick(sIRCMessage.Info[7]) && sIRCMessage.Info[7].ToLower() != sMyNickInfo.NickStorage.ToLower() && rank.Length > 3 && sChannelList.IsChannelRank(rank.Substring(3).Substring(0, 1)))
            {
                if (status == Rfc2812Util.ModeActionToChar(ModeAction.Remove).ToString())
                {
                    rank2 += rank.Substring(3).Substring(0, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[7];
                }
                else if (status == Rfc2812Util.ModeActionToChar(ModeAction.Add).ToString())
                {
                    rank2 += rank.Substring(3).Substring(0, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[7];
                }
            }
            else if (sIRCMessage.Info.Length >= 8 && !Rfc2812Util.IsValidNick(sIRCMessage.Info[7]) && sIRCMessage.Info[7].ToLower() != sMyNickInfo.NickStorage.ToLower())
            {
                if (!sIRCMessage.Info[7].IsNullOrEmpty())
                {
                    error += ", " + sIRCMessage.Info[7];
                }
                else
                {
                    StringEmpty = true;
                }
            }
            else if (sIRCMessage.Info.Length >= 8 && Rfc2812Util.IsValidNick(sIRCMessage.Info[7]) && sIRCMessage.Info[7].ToLower() == sMyNickInfo.NickStorage.ToLower())
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[0]);
            }

            if (sIRCMessage.Info.Length >= 9 && Rfc2812Util.IsValidNick(sIRCMessage.Info[8]) && sIRCMessage.Info[8].ToLower() != sMyNickInfo.NickStorage.ToLower() && rank.Length > 4 && sChannelList.IsChannelRank(rank.Substring(4).Substring(0, 1)))
            {
                if (status == Rfc2812Util.ModeActionToChar(ModeAction.Remove).ToString())
                {
                    rank2 += rank.Substring(4).Substring(0, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[8];
                }
                else if (status == Rfc2812Util.ModeActionToChar(ModeAction.Add).ToString())
                {
                    rank2 += rank.Substring(4).Substring(0, 1);
                    name  += SchumixBase.Space + sIRCMessage.Info[8];
                }
            }
            else if (sIRCMessage.Info.Length >= 9 && !Rfc2812Util.IsValidNick(sIRCMessage.Info[8]) && sIRCMessage.Info[8].ToLower() != sMyNickInfo.NickStorage.ToLower())
            {
                if (!sIRCMessage.Info[8].IsNullOrEmpty())
                {
                    error += ", " + sIRCMessage.Info[8];
                }
                else
                {
                    StringEmpty = true;
                }
            }
            else if (sIRCMessage.Info.Length >= 9 && Rfc2812Util.IsValidNick(sIRCMessage.Info[8]) && sIRCMessage.Info[8].ToLower() == sMyNickInfo.NickStorage.ToLower())
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[0]);
            }

            error = error.Remove(0, 2, ", ");

            if (!error.IsNullOrEmpty())
            {
                sSendMessage.SendChatMessage(sIRCMessage, error + SchumixBase.Colon + SchumixBase.Space + sLManager.GetWarningText("NotaNickNameHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
            }

            if (StringEmpty)
            {
                sSendMessage.SendChatMessage(sIRCMessage, text[8]);
            }

            ModePrivmsg = sIRCMessage.Channel;
            sSender.Mode(sIRCMessage.Channel, status + rank2, name.Remove(0, 1, SchumixBase.Space));

            // Clean
            Thread.Sleep(5 * 1000);

            if (sIRCMessage.Channel.ToLower() == ModePrivmsg.ToLower() || !ModePrivmsg.IsNullOrEmpty())
            {
                ModePrivmsg = string.Empty;
            }
        }
示例#17
0
        public static void ResolvePurchaseVariables(Viewer viewer, IRCMessage message, StoreIncidentVariables incident, bool separateChannel = false)
        {
            int cost = incident.cost;

            if (cost < 1 && incident.defName != "Item")
            {
                return;
            }

            if (CheckIfViewerIsInVariableCommandList(viewer.username, separateChannel))
            {
                return;
            }

            if (!CheckIfViewerHasEnoughCoins(viewer, cost, separateChannel))
            {
                return;
            }

            if (incident != DefDatabase <StoreIncidentVariables> .GetNamed("Item"))
            {
                if (CheckIfKarmaTypeIsMaxed(incident, viewer.username, separateChannel))
                {
                    return;
                }
            }
            else
            {
                if (CheckIfCarePackageIsOnCooldown(viewer.username, separateChannel))
                {
                    return;
                }
            }

            if (CheckIfIncidentIsOnCooldown(incident, viewer.username, separateChannel))
            {
                return;
            }

            viewerNamesDoingVariableCommands.Add(viewer.username);

            IncidentHelperVariables helper = StoreIncidentMaker.MakeIncidentVariables(incident);

            if (helper == null)
            {
                Helper.Log("Missing helper for incident " + incident.defName);
                return;
            }

            if (!helper.IsPossible(message.Message, viewer, separateChannel))
            {
                if (viewerNamesDoingVariableCommands.Contains(viewer.username))
                {
                    viewerNamesDoingVariableCommands.Remove(viewer.username);
                }
                return;
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            helper.Viewer  = viewer;
            helper.message = message.Message;

            Ticker.IncidentHelperVariables.Enqueue(helper);
            Store_Logger.LogPurchase(viewer.username, message.Message);
            component.LogIncident(incident);
        }
示例#18
0
        public static void CheckCommand(IRCMessage msg)
        {
            if (msg == null)
            {
                return;
            }

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

            string message = msg.Message;
            string user    = msg.User;

            if (message.Split(' ')[0] == "/w")
            {
                List <string> messagewhisper = message.Split(' ').ToList();
                messagewhisper.RemoveAt(0);
                message = string.Join(" ", messagewhisper.ToArray());
                Helper.Log(message);
            }

            Viewer viewer = Viewers.GetViewer(user);

            viewer.last_seen = DateTime.Now;

            if (viewer.IsBanned)
            {
                return;
            }

            //admin commands
            if (user.ToLower() == ToolkitSettings.Channel.ToLower())
            {
                if (message.StartsWith("!resetviewers"))
                {
                    if (ToolkitSettings.SyncStreamLabs)
                    {
                        WarningWindow window = new WarningWindow
                        {
                            warning = "You must reset viewers in Streamlabs chatbot and then restart the game."
                        };
                        Find.WindowStack.Add(window);
                    }
                    else if (resetWarning == 0)
                    {
                        _client.SendMessage($"@{user} " + "TwitchToolkitResetViewersWarningOne".Translate(), SendToChatroom(msg));
                        resetWarning = 1;
                    }
                    else if (resetWarning == 1)
                    {
                        _client.SendMessage($"@{user} " + "TwitchToolkitResetViewersWarningTwo".Translate(), SendToChatroom(msg));
                        resetWarning = 2;
                    }
                    else if (resetWarning == 2)
                    {
                        _client.SendMessage($"@{user} " + "TwitchToolkitResetViewersWarningThree".Translate(), SendToChatroom(msg));
                        Viewers.ResetViewers();
                        resetWarning = 0;
                    }
                }

                if (message.StartsWith("!addtoolkitmod"))
                {
                    string[] command = message.Split(' ');

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

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

                    if (Viewer.IsModerator(mod))
                    {
                        _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitAlreadyMod".Translate(), mod: mod), SendToChatroom(msg));
                        return;
                    }

                    Viewer modviewer = Viewers.GetViewer(mod);

                    modviewer.SetAsModerator();
                    _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitAddedMod".Translate(), mod: mod), SendToChatroom(msg));
                }

                if (message.StartsWith("!removetoolkitmod"))
                {
                    string[] command = message.Split(' ');

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

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

                    if (!Viewer.IsModerator(mod))
                    {
                        return;
                    }

                    Viewer modviewer = Viewers.GetViewer(mod);

                    modviewer.RemoveAsModerator();
                    _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitRemovedMod".Translate(), mod: mod), SendToChatroom(msg));
                }
            }

            //moderator commands
            if (user.ToLower() == ToolkitSettings.Channel.ToLower() || Viewer.IsModerator(user))
            {
                if (message.StartsWith("!refreshviewers"))
                {
                    TwitchToolkitDev.WebRequest_BeginGetResponse.Main("https://tmi.twitch.tv/group/user/" + ToolkitSettings.Channel.ToLower() + "/chatters", new Func <TwitchToolkitDev.RequestState, bool>(Viewers.SaveUsernamesFromJsonResponse));
                }

                if (message.StartsWith("!karmaround"))
                {
                    Viewers.AwardViewersCoins();
                }

                if (message.StartsWith("!giveallcoins"))
                {
                    try
                    {
                        string[] command = 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);
                            }
                            _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitGiveAllCoins".Translate(), amount: amount.ToString()), SendToChatroom(msg));
                        }
                    }
                    catch (InvalidCastException e)
                    {
                        Helper.Log("Give All Coins Syntax Error " + e.Message);
                    }
                }

                if (message.StartsWith("!givecoins"))
                {
                    try
                    {
                        string[] command = message.Split(' ');

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

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

                        if (user.ToLower() != ToolkitSettings.Channel.ToLower() && receiver.ToLower() == user.ToLower())
                        {
                            _client.SendMessage($"@{user} " + "TwitchToolkitModCannotGiveCoins".Translate());
                            return;
                        }

                        int  amount;
                        bool isNumeric = int.TryParse(command[2], out amount);
                        if (isNumeric)
                        {
                            Viewer giftee = Viewers.GetViewer(receiver);

                            Helper.Log($"Giving viewer {giftee.username} {amount} coins");
                            giftee.GiveViewerCoins(amount);
                            _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitGivingCoins".Translate(), viewer: giftee.username, amount: amount.ToString(), newbalance: giftee.coins.ToString()), SendToChatroom(msg));
                            Store_Logger.LogGiveCoins(user, giftee.username, amount);
                        }
                    }
                    catch (InvalidCastException e)
                    {
                        Helper.Log("Invalid Give Viewer Coins Command " + e.Message);
                    }
                }

                if (message.StartsWith("!checkuser"))
                {
                    try
                    {
                        string[] command = message.Split(' ');

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

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

                        Viewer targeted = Viewers.GetViewer(target);
                        _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitCheckUser".Translate(), viewer: targeted.username, amount: targeted.coins.ToString(), karma: targeted.GetViewerKarma().ToString()), SendToChatroom(msg));
                    }
                    catch (InvalidCastException e)
                    {
                        Helper.Log("Invalid Check User Command " + e.Message);
                    }
                }

                if (message.StartsWith("!setkarma"))
                {
                    try
                    {
                        string[] command = 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);
                            _client.SendMessage($"@{user}" + Helper.ReplacePlaceholder("TwitchToolkitSetKarma".Translate(), viewer: targeted.username, karma: amount.ToString()), SendToChatroom(msg));
                        }
                    }
                    catch (InvalidCastException e)
                    {
                        Helper.Log("Invalid Check User Command " + e.Message);
                    }
                }

                if (message.StartsWith("!togglecoins"))
                {
                    if (ToolkitSettings.EarningCoins)
                    {
                        ToolkitSettings.EarningCoins = false;
                        _client.SendMessage($"@{user} " + "TwitchToolkitEarningCoinsMessage".Translate() + " " + "TwitchToolkitOff".Translate(), SendToChatroom(msg));
                    }
                    else
                    {
                        ToolkitSettings.EarningCoins = true;
                        _client.SendMessage($"@{user} " + "TwitchToolkitEarningCoinsMessage".Translate() + " " + "TwitchToolkitOn".Translate(), SendToChatroom(msg));
                    }
                }

                if (message.StartsWith("!togglestore"))
                {
                    if (ToolkitSettings.StoreOpen)
                    {
                        ToolkitSettings.StoreOpen = false;
                        _client.SendMessage($"@{user} " + "TwitchToolkitStorePurchasesMessage".Translate() + " " + "TwitchToolkitOn".Translate(), SendToChatroom(msg));
                    }
                    else
                    {
                        ToolkitSettings.StoreOpen = true;
                        _client.SendMessage($"@{user} " + "TwitchToolkitStorePurchasesMessage".Translate() + " " + "TwitchToolkitOn".Translate(), SendToChatroom(msg));
                    }
                }
            }

            // commands are suppressed when not earning coins
            if (ToolkitSettings.EarningCoins)
            {
                if (message.StartsWith(ToolkitSettings.BalanceCmd) && AllowCommand(msg))
                {
                    _client.SendMessage($"@{viewer.username} " + Helper.ReplacePlaceholder("TwitchToolkitBalanceMessage".Translate(), amount: viewer.GetViewerCoins().ToString(), karma: viewer.GetViewerKarma().ToString()), SendToChatroom(msg));
                }

                if (message.StartsWith(ToolkitSettings.KarmaCmd) && !message.Contains("!karmaround"))
                {
                    _client.SendMessage($"@{viewer.username} " + "TwitchToolkitWhatIsKarma".Translate() + $" { viewer.GetViewerKarma()}%", SendToChatroom(msg));
                }

                if (message.StartsWith(ToolkitSettings.InstructionsCmd))
                {
                    _client.SendMessage($"@{user} " + Helper.ReplacePlaceholder("TwitchToolkitInstructions".Translate(), first: ToolkitSettings.BuyeventCmd, second: ToolkitSettings.BuyitemCmd, third: ToolkitSettings.CustomPricingSheetLink), SendToChatroom(msg));
                }

                if (message.StartsWith(ToolkitSettings.PurchaselistCmd))
                {
                    _client.SendMessage($"@{user} " + "TwitchToolkitPurchaseList".Translate() + $" {ToolkitSettings.CustomPricingSheetLink}", SendToChatroom(msg));
                }

                if (message.StartsWith(ToolkitSettings.GiftCmd) && ToolkitSettings.GiftingCoins && AllowCommand(msg))
                {
                    string[] command = 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.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);
                            _client.SendMessage($"@{giftee.username} " + Helper.ReplacePlaceholder("TwitchToolkitGiftCoins".Translate(), amount: amount.ToString(), from: viewer.username), SendToChatroom(msg));
                            Store_Logger.LogGiftCoins(viewer.username, giftee.username, amount);
                        }
                    }
                }

                if (message.StartsWith("!buy ticket") && ToolkitSettings.EnableViewerQueue && AllowCommand(msg))
                {
                    GameComponentPawns pawnComponent = Current.Game.GetComponent <GameComponentPawns>();

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

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

                        viewer.TakeViewerCoins(ToolkitSettings.CostToJoinQueue);
                    }

                    pawnComponent.AddViewerToViewerQueue(user);
                    _client.SendMessage($"@{user} you have purchased a ticket and are in the queue!", SendToChatroom(msg));
                }
            }

            if (message.StartsWith(ToolkitSettings.ModinfoCmd))
            {
                _client.SendMessage($"@{user} " + "TwitchToolkitModInfo".Translate() + " https://discord.gg/qrtg224 !", SendToChatroom(msg));
            }

            if (ToolkitSettings.StoreOpen)
            {
                if ((message.StartsWith("!buy") || message.StartsWith("!gambleskill")) && AllowCommand(msg))
                {
                    if (message.Split(' ').Count() < 2)
                    {
                        return;
                    }
                    Purchase_Handler.ResolvePurchase(viewer, msg, SendToChatroom(msg));
                }
            }

            if (message.StartsWith(ToolkitSettings.ModsettingsCmd))
            {
                string minutess     = ToolkitSettings.CoinInterval > 1 ? "s" : "";
                string storeon      = ToolkitSettings.StoreOpen ? "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()
                                                                 );

                _client.SendMessage(stats_message, SendToChatroom(msg));
            }

            if (message.StartsWith(ToolkitSettings.CommandHelpCmd))
            {
                string commands = " " +
                                  ToolkitSettings.BalanceCmd + ", " +
                                  ToolkitSettings.BuyeventCmd + ", " +
                                  ToolkitSettings.BuyitemCmd + ", " +
                                  ToolkitSettings.InstructionsCmd + ", " +
                                  ToolkitSettings.PurchaselistCmd + ", " +
                                  ToolkitSettings.ModinfoCmd + ", " +
                                  ToolkitSettings.ModsettingsCmd + ", " +
                                  ToolkitSettings.KarmaCmd;

                if (ToolkitSettings.GiftingCoins)
                {
                    commands += ", " + ToolkitSettings.GiftCmd;
                }

                _client.SendMessage("TwitchToolkitUserCommands".Translate() + commands, SendToChatroom(msg));
            }


            if (ToolkitSettings.CommandsModsEnabled && message.StartsWith("!installedmods") && (DateTime.Now - modsCommandCooldown).TotalSeconds >= 10)
            {
                modsCommandCooldown = DateTime.Now;
                string   modmsg = "Version: " + _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, SendToChatroom(msg));
                        modmsg = "";
                    }
                }
                return;
            }

            List <TwitchInterfaceBase> modExtensions = Current.Game.components.OfType <TwitchInterfaceBase>().ToList();

            if (modExtensions == null)
            {
                return;
            }

            foreach (TwitchInterfaceBase parser in modExtensions)
            {
                parser.ParseCommand(msg);
            }
        }
示例#19
0
        public int CompilerCommand(IRCMessage sIRCMessage, bool command)
        {
            try
            {
                var sSendMessage = sIrcBase.Networks[sIRCMessage.ServerName].sSendMessage;
                var text         = sLManager.GetCommandTexts("compiler", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 5)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return(1);
                }

                string data = string.Empty, template = string.Empty;

                if (!command && regex.IsMatch(sIRCMessage.Args.TrimEnd()))
                {
                    data = regex.Match(sIRCMessage.Args.TrimEnd()).Groups["code"].ToString();
                }
                else if (command)
                {
                    data = sIRCMessage.Args.Trim();
                }

                if (Ban(data, sIRCMessage))
                {
                    return(1);
                }

                if (!IsEntry(data) && !IsEntryAndAbstractRegex(data))
                {
                    if (!IsSchumix(data) && !IsSchumixAndOverride(data))
                    {
                        template = CompilerConfig.Referenced + " class " + CompilerConfig.MainClass + " : Schumix.Compiler.Abstract { public override void " + CompilerConfig.MainConstructor + "() { " + CleanText(data) + " } }";
                    }
                    else if (IsSchumix(data) && !IsSchumixAndOverride(data))
                    {
                        template = CompilerConfig.Referenced + " class " + CompilerConfig.MainClass + " : Schumix.Compiler.Abstract { " + Regex.Replace(CleanText(data), SchumixRegex.ToString(), @"public override void " + CompilerConfig.MainConstructor + @"() {") + " }";
                    }
                    else if (!IsSchumix(data) && IsSchumixAndOverride(data))
                    {
                        template = CompilerConfig.Referenced + " class " + CompilerConfig.MainClass + " : Schumix.Compiler.Abstract { " + CleanText(data) + " }";
                    }
                }
                else if (IsEntry(data) && !IsEntryAndAbstractRegex(data))
                {
                    if (!IsSchumix(data) && !IsSchumixAndOverride(data))
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                        return(1);
                    }

                    if (IsSchumix(data) && !IsSchumixAndOverride(data))
                    {
                        data = Regex.Replace(data, SchumixRegex.ToString(), @"public override void " + CompilerConfig.MainConstructor + @"() {");
                    }

                    template = CompilerConfig.Referenced + SchumixBase.Space + Regex.Replace(CleanText(data), EntryRegex.ToString(), @"class " + CompilerConfig.MainClass + @" : Schumix.Compiler.Abstract {");
                }
                else if (!IsEntry(data) && IsEntryAndAbstractRegex(data))
                {
                    if (!IsSchumix(data) && !IsSchumixAndOverride(data))
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                        return(1);
                    }

                    if (IsSchumix(data) && !IsSchumixAndOverride(data))
                    {
                        data = Regex.Replace(data, SchumixRegex.ToString(), @"public override void " + CompilerConfig.MainConstructor + @"() {");
                    }

                    template = CompilerConfig.Referenced + SchumixBase.Space + CleanText(data);
                }

                var s = new Sandbox(CompilerConfig.ReferencedAssemblies, CompilerConfig.CompilerOptions, CompilerConfig.WarningLevel, CompilerConfig.TreatWarningsAsErrors);
                //s.TestIsFullyTrusted(); // Test Sandbox

                string errormessage = string.Empty;
                var    asm          = s.CompileCode(template, ref errormessage);
                errormessage = errormessage.Remove(0, 2, ". ");

                if (!errormessage.IsNullOrEmpty())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("compiler/code", sIRCMessage.Channel, sIRCMessage.ServerName), errormessage.TrimMessage(1000));
                }

                if (asm.IsNull())
                {
                    return(1);
                }

                AppDomain appdomain = null;
                s = Sandbox.CreateInstance(ref appdomain);
                //s.TestIsFullyTrusted(); // Test Sandbox

                object o = asm.CreateInstance(CompilerConfig.MainClass);
                if (o.IsNull())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    return(1);
                }

                var writer = new StringWriter();
                Console.SetOut(writer);

                int ReturnCode = 0;
                int errorcode  = -1;
                var thread     = new Thread(() =>
                {
                    try
                    {
                        errormessage = string.Empty;
                        ReturnCode   = s.StartCode(data, CompilerConfig.MainConstructor, (Abstract)o, ref errormessage, ref errorcode);
                    }
                    catch (Exception e)
                    {
                        ReturnCode = -1;
                        ConsoleOpenStandardOutput();
                        Log.Debug("CompilerThread", sLConsole.GetString("Failure details: {0}"), e.Message);
                    }
                });

                thread.Start();
                thread.Join(3000);
                thread.Abort();
                AppDomain.Unload(appdomain);

                switch (errorcode)
                {
                case 0:
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("compiler/code", sIRCMessage.Channel, sIRCMessage.ServerName), errormessage.TrimMessage(1000));
                    break;

                default:
                    break;
                }

                switch (ReturnCode)
                {
                case -1:
                    return(1);

                case 0:
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("compiler/kill", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return(1);

                default:
                    break;
                }

                string _write = writer.ToString();
                sSendMessage.SendChatMessage(sIRCMessage, string.Empty);

                if (_write.Length == 0)
                {
                    return(2);
                }

                var length = _write.Length;
                var lines  = CleanIrcText(_write).Split(SchumixBase.NewLine);

                if (length > 1000 && lines.Length == 1)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                    return(1);
                }
                else if (length <= 1000 && lines.Length == 1)
                {
                    byte i = 0, x = 0;

                    foreach (var line in lines)
                    {
                        i++;

                        if (line.IsNullOrEmpty())
                        {
                            x++;
                        }
                        else
                        {
                            sSendMessage.SendChatMessage(sIRCMessage, line);
                        }
                    }

                    if (i == x)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[3]);
                    }

                    return(1);
                }
                else if (lines.Length == 2)
                {
                    foreach (var line in lines)
                    {
                        if (line.IsNullOrEmpty())
                        {
                            continue;
                        }
                        else
                        {
                            sSendMessage.SendChatMessage(sIRCMessage, line);
                        }
                    }

                    return(1);
                }
                else if (lines.Length > 2)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, lines[0]);
                    sSendMessage.SendChatMessage(sIRCMessage, text[4], lines.Length - 1);
                    return(1);
                }

                return(1);
            }
            catch (Exception e)
            {
                ConsoleOpenStandardOutput();
                Log.Debug("CompilerCommand", sLConsole.GetString("Failure details: {0}"), e.Message);
                return(-1);
            }
        }
示例#20
0
        protected void HandleAdmin(IRCMessage sIRCMessage)
        {
            if (!IsAdmin(sIRCMessage.Nick))
            {
                return;
            }

            bool status = true;

            if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "access")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoPassword", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var text = sLManager.GetCommandTexts("admin/access", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 4)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                string name = sIRCMessage.Nick.ToLower();
                var    db   = SchumixBase.DManager.QueryFirstRow("SELECT Password FROM admins WHERE Name = '{0}' And ServerName = '{1}'", name, sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    if (db["Password"].ToString() == sUtilities.Sha1(sIRCMessage.Info[5]))
                    {
                        SchumixBase.DManager.Update("admins", string.Format("Vhost = '{0}'", sIRCMessage.Host), string.Format("Name = '{0}' And ServerName = '{1}'", name, sIRCMessage.ServerName));
                        UpdateLCDB("UPDATE admins SET {0} WHERE {1}", string.Format("Vhost = '{0}'", sIRCMessage.Host), string.Format("Name = '{0}' And ServerName = '{1}'", name, sIRCMessage.ServerName));
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    }
                }

                if (!sChannelList.IsChannelList(name))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                    sSendMessage.SendChatMessage(sIRCMessage, text[3]);
                    sChannelList.NewThread(sIRCMessage.ServerName, name);
                }

                status = false;
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "newpassword")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoOldPassword", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 7)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoNewPassword", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var text = sLManager.GetCommandTexts("admin/newpassword", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 2)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                string name = sIRCMessage.Nick.ToLower();
                var    db   = SchumixBase.DManager.QueryFirstRow("SELECT Password FROM admins WHERE Name = '{0}' And ServerName = '{1}'", name, sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    if (db["Password"].ToString() == sUtilities.Sha1(sIRCMessage.Info[5]))
                    {
                        SchumixBase.DManager.Update("admins", string.Format("Password = '******'", sUtilities.Sha1(sIRCMessage.Info[6])), string.Format("Name = '{0}' And ServerName = '{1}'", name, sIRCMessage.ServerName));
                        UpdateLCDB("UPDATE admins SET {0} WHERE {1}", string.Format("Password = '******'", sUtilities.Sha1(sIRCMessage.Info[6])), string.Format("Name = '{0}' And ServerName = '{1}'", name, sIRCMessage.ServerName));
                        sSendMessage.SendChatMessage(sIRCMessage, text[0], sIRCMessage.Info[6]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    }
                }

                status = false;
            }

            if (!IsAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.HalfOperator))
            {
                return;
            }

            if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "info")
            {
                var text = sLManager.GetCommandTexts("admin/info", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 3)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                string name = sIRCMessage.Nick;

                if (sIRCMessage.Info.Length >= 6)
                {
                    name = sIRCMessage.Info[5];
                }

                if (!Rfc2812Util.IsValidNick(name))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaNickNameHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var db   = SchumixBase.DManager.QueryFirstRow("SELECT Flag FROM admins WHERE Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName);
                int flag = !db.IsNull() ? db["Flag"].ToInt32() : -1;

                if ((AdminFlag)flag == AdminFlag.HalfOperator)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                }
                else if ((AdminFlag)flag == AdminFlag.Operator)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                }
                else if ((AdminFlag)flag == AdminFlag.Administrator)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                }
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "list")
            {
                var db = SchumixBase.DManager.Query("SELECT Name FROM admins WHERE ServerName = '{0}'", sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    string admins = string.Empty;

                    foreach (DataRow row in db.Rows)
                    {
                        string name = row["Name"].ToString();
                        admins += ", " + name;
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("admin/list", sIRCMessage.Channel, sIRCMessage.ServerName), admins.Remove(0, 2, ", "));
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "add")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var text = sLManager.GetCommandTexts("admin/add", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 5)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                string name = sIRCMessage.Info[5];
                if (!Rfc2812Util.IsValidNick(name))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaNickNameHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM admins WHERE Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    return;
                }

                string pass = sUtilities.GetRandomString();
                SchumixBase.DManager.Insert("`admins`(ServerId, ServerName, Name, Password)", sIRCMessage.ServerId, sIRCMessage.ServerName, sUtilities.SqlEscape(name.ToLower()), sUtilities.Sha1(pass));
                UpdateLCDB("INSERT INTO `admins`(ServerId, ServerName, Name, Password) VALUES ('{0}', '{1}', '{2}', '{3}')", sIRCMessage.ServerId, sIRCMessage.ServerName, sUtilities.SqlEscape(name.ToLower()), sUtilities.Sha1(pass));

                if (SchumixBase.DManager.IsCreatedTable("hlmessage"))
                {
                    SchumixBase.DManager.Insert("`hlmessage`(ServerId, ServerName, Name, Enabled)", sIRCMessage.ServerId, sIRCMessage.ServerName, sUtilities.SqlEscape(name.ToLower()), "off");
                }

                sSendMessage.SendChatMessage(sIRCMessage, text[1], name);
                sSendMessage.SendChatMessage(sIRCMessage.MessageType, name, text[2], pass);
                sSendMessage.SendChatMessage(sIRCMessage.MessageType, name, text[3], IRCConfig.List[sIRCMessage.ServerName].CommandPrefix);
                sSendMessage.SendChatMessage(sIRCMessage.MessageType, name, text[4], IRCConfig.List[sIRCMessage.ServerName].CommandPrefix);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "remove")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var text = sLManager.GetCommandTexts("admin/remove", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 2)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                string name = sIRCMessage.Info[5];
                if (!Rfc2812Util.IsValidNick(name))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaNickNameHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM admins WHERE Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName);
                if (db.IsNull())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator) && IsAdmin(name, AdminFlag.Operator))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoOperator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator) && IsAdmin(name, AdminFlag.Administrator))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoAdministrator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.Operator) && IsAdmin(name, AdminFlag.Administrator))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoAdministrator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                SchumixBase.DManager.Delete("admins", string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName));
                UpdateLCDB("DELETE FROM admins WHERE {0}", string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName));

                if (SchumixBase.DManager.IsCreatedTable("hlmessage"))
                {
                    SchumixBase.DManager.Delete("hlmessage", string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName));
                }

                if (SchumixBase.DManager.IsCreatedTable("birthday"))
                {
                    var db1 = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM birthday WHERE Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName);
                    if (!db1.IsNull())
                    {
                        SchumixBase.DManager.Delete("birthday", string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name.ToLower()), sIRCMessage.ServerName));
                    }
                }

                sSendMessage.SendChatMessage(sIRCMessage, text[1], name);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "rank")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 7)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoRank", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var text = sLManager.GetCommandTexts("admin/rank", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 2)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                string name = sIRCMessage.Info[5].ToLower();
                if (!Rfc2812Util.IsValidNick(name))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaNickNameHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator) && IsAdmin(name, AdminFlag.Operator))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoOperator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator) && IsAdmin(name, AdminFlag.Administrator))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoAdministrator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.Operator) && IsAdmin(name, AdminFlag.Administrator))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoAdministrator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                int rank = sIRCMessage.Info[6].ToInt32();

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator) && IsAdmin(name, AdminFlag.HalfOperator) && (AdminFlag)rank == AdminFlag.Operator)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoOperator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator) && IsAdmin(name, AdminFlag.HalfOperator) && (AdminFlag)rank == AdminFlag.Administrator)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoAdministrator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.Operator) && IsAdmin(name, AdminFlag.Operator) && (AdminFlag)rank == AdminFlag.Administrator)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoAdministrator", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if ((AdminFlag)rank == AdminFlag.Administrator || (AdminFlag)rank == AdminFlag.Operator || (AdminFlag)rank == AdminFlag.HalfOperator)
                {
                    SchumixBase.DManager.Update("admins", string.Format("Flag = '{0}'", rank), string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name), sIRCMessage.ServerName));
                    UpdateLCDB("UPDATE admins SET {0} WHERE {1}", string.Format("Flag = '{0}'", rank), string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(name), sIRCMessage.ServerName));
                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                }
            }
            else
            {
                if (!status)
                {
                    return;
                }

                var text = sLManager.GetCommandTexts("admin", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                if (IsAdmin(sIRCMessage.Nick, AdminFlag.HalfOperator))
                {
                    string commands = string.Empty;

                    foreach (var command in sIrcBase.Networks[sIRCMessage.ServerName].CommandMethodMap)
                    {
                        if (command.Value.Permission != CommandPermission.HalfOperator)
                        {
                            continue;
                        }

                        if (command.Key == "admin")
                        {
                            continue;
                        }

                        if (sIgnoreCommand.IsIgnore(command.Key))
                        {
                            continue;
                        }

                        commands += " | " + IRCConfig.List[sIRCMessage.ServerName].CommandPrefix + command.Key;
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    sSendMessage.SendChatMessage(sIRCMessage, text[1], commands.Remove(0, 3, " | "));
                }
                else if (IsAdmin(sIRCMessage.Nick, AdminFlag.Operator))
                {
                    string commands = string.Empty;

                    foreach (var command in sIrcBase.Networks[sIRCMessage.ServerName].CommandMethodMap)
                    {
                        if (command.Value.Permission == CommandPermission.Normal ||
                            command.Value.Permission == CommandPermission.Administrator)
                        {
                            continue;
                        }

                        if (command.Key == "admin")
                        {
                            continue;
                        }

                        if (sIgnoreCommand.IsIgnore(command.Key))
                        {
                            continue;
                        }

                        commands += " | " + IRCConfig.List[sIRCMessage.ServerName].CommandPrefix + command.Key;
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                    sSendMessage.SendChatMessage(sIRCMessage, text[3], commands.Remove(0, 3, " | "));
                }
                else if (IsAdmin(sIRCMessage.Nick, AdminFlag.Administrator))
                {
                    string commands = string.Empty;

                    foreach (var command in sIrcBase.Networks[sIRCMessage.ServerName].CommandMethodMap)
                    {
                        if (command.Value.Permission == CommandPermission.Normal)
                        {
                            continue;
                        }

                        if (command.Key == "admin")
                        {
                            continue;
                        }

                        if (sIgnoreCommand.IsIgnore(command.Key))
                        {
                            continue;
                        }

                        commands += " | " + IRCConfig.List[sIRCMessage.ServerName].CommandPrefix + command.Key;
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, text[4]);
                    sSendMessage.SendChatMessage(sIRCMessage, text[5], commands.Remove(0, 3, " | "));
                }
            }
        }
示例#21
0
 public static void SetMessageType(this IRCMessage sIRCMessage)
 {
     sIRCMessage.SetMessageType(IRCConfig.List[sIRCMessage.ServerName].MessageType.ToLower());
 }
示例#22
0
        protected void HandleKick(IRCMessage sIRCMessage)
        {
            if (!IsAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.Operator))
            {
                return;
            }

            if (!Rfc2812Util.IsValidChannelName(sIRCMessage.Channel))
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ThisIsNotAChannelDoNotWriteInPM", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            if (sIRCMessage.Info.Length < 5)
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            bool   iskick = false;
            string kick   = sIRCMessage.Info[4].ToLower();

            if (!Rfc2812Util.IsValidNick(kick))
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaNickNameHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            if (sIRCMessage.Info.Length == 5)
            {
                if (kick == sMyNickInfo.NickStorage.ToLower())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("kick", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
                else
                {
                    iskick      = true;
                    KickPrivmsg = sIRCMessage.Channel;
                    sSender.Kick(sIRCMessage.Channel, kick);
                }
            }
            else if (sIRCMessage.Info.Length >= 6)
            {
                if (kick == sMyNickInfo.NickStorage.ToLower())
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("kick", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
                else
                {
                    iskick      = true;
                    KickPrivmsg = sIRCMessage.Channel;
                    sSender.Kick(sIRCMessage.Channel, kick, sIRCMessage.Info.SplitToString(5, SchumixBase.Space));
                }
            }

            if (iskick)
            {
                // Clean
                Thread.Sleep(5 * 1000);

                if (sIRCMessage.Channel.ToLower() == KickPrivmsg.ToLower() || !KickPrivmsg.IsNullOrEmpty())
                {
                    KickPrivmsg = string.Empty;
                }
            }
        }
示例#23
0
        public void HandleGit(IRCMessage sIRCMessage)
        {
            if (!IsAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.Operator))
            {
                return;
            }

            var sSendMessage = sIrcBase.Networks[sIRCMessage.ServerName].sSendMessage;

            if (sIRCMessage.Info.Length < 5)
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoValue", sIRCMessage.Channel, sIRCMessage.ServerName));
                return;
            }

            if (sIRCMessage.Info[4].ToLower() == "info")
            {
                var db = SchumixBase.DManager.Query("SELECT Name, Type, Channel FROM gitinfo WHERE ServerName = '{0}'", sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    foreach (DataRow row in db.Rows)
                    {
                        string   name    = row["Name"].ToString();
                        string   type    = row["Type"].ToString();
                        string[] channel = row["Channel"].ToString().Split(SchumixBase.Comma);
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("git/info", sIRCMessage.Channel, sIRCMessage.ServerName), name, type, channel.SplitToString(SchumixBase.Space));
                    }
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
            }
            else if (sIRCMessage.Info[4].ToLower() == "list")
            {
                var db = SchumixBase.DManager.Query("SELECT Name, Type FROM gitinfo WHERE ServerName = '{0}'", sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    string list = string.Empty;

                    foreach (DataRow row in db.Rows)
                    {
                        list += string.Format(", 3{0}15/7{1}", row["Name"].ToString(), row["Type"].ToString());
                    }

                    if (list.IsNullOrEmpty())
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("git/list", sIRCMessage.Channel, sIRCMessage.ServerName), SchumixBase.Space + sLConsole.Other("Nothing"));
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("git/list", sIRCMessage.Channel, sIRCMessage.ServerName), list.Remove(0, 1, SchumixBase.Comma));
                    }
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
            }
            else if (sIRCMessage.Info[4].ToLower() == "start")
            {
                var text = sLManager.GetCommandTexts("git/start", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 3)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 7)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                foreach (var list in RssList)
                {
                    if (sIRCMessage.Info[5].ToLower() == list.Name.ToLower() && sIRCMessage.Info[6].ToLower() == list.Type.ToLower())
                    {
                        if (list.Started)
                        {
                            sSendMessage.SendChatMessage(sIRCMessage, text[0], list.Name, list.Type);
                            return;
                        }

                        list.Start();
                        sSendMessage.SendChatMessage(sIRCMessage, text[1], list.Name, list.Type);
                        return;
                    }
                }

                sSendMessage.SendChatMessage(sIRCMessage, text[2], sIRCMessage.Info[5], sIRCMessage.Info[6]);
            }
            else if (sIRCMessage.Info[4].ToLower() == "stop")
            {
                var text = sLManager.GetCommandTexts("git/stop", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 3)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 7)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                foreach (var list in RssList)
                {
                    if (sIRCMessage.Info[5].ToLower() == list.Name.ToLower() && sIRCMessage.Info[6].ToLower() == list.Type.ToLower())
                    {
                        if (!list.Started)
                        {
                            sSendMessage.SendChatMessage(sIRCMessage, text[0], list.Name, list.Type);
                            return;
                        }

                        list.Stop();
                        sSendMessage.SendChatMessage(sIRCMessage, text[1], list.Name, list.Type);
                        return;
                    }
                }

                sSendMessage.SendChatMessage(sIRCMessage, text[2], sIRCMessage.Info[5], sIRCMessage.Info[6]);
            }
            else if (sIRCMessage.Info[4].ToLower() == "reload")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("No1Value", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info[5].ToLower() == "all")
                {
                    foreach (var list in RssList)
                    {
                        list.Reload();
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("git/reload/all", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
                else
                {
                    var text = sLManager.GetCommandTexts("git/reload", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 2)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 6)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    foreach (var list in RssList)
                    {
                        if (sIRCMessage.Info[5].ToLower() == list.Name.ToLower() && sIRCMessage.Info[6].ToLower() == list.Type.ToLower())
                        {
                            list.Reload();
                            sSendMessage.SendChatMessage(sIRCMessage, text[0], list.Name, list.Type);
                            return;
                        }
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, text[1], sIRCMessage.Info[5], sIRCMessage.Info[6]);
                }
            }
            else if (sIRCMessage.Info[4].ToLower() == "channel")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoCommand", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info[5].ToLower() == "add")
                {
                    var text = sLManager.GetCommandTexts("git/channel/add", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 3)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 8)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 9)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoChannelName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (!Rfc2812Util.IsValidChannelName(sIRCMessage.Info[8]))
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaChannelHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    var db = SchumixBase.DManager.QueryFirstRow("SELECT Channel FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName);
                    if (!db.IsNull())
                    {
                        string[] channel = db["Channel"].ToString().Split(SchumixBase.Comma);
                        string   data    = channel.SplitToString(SchumixBase.Comma);

                        if (channel.ToList().Contains(sIRCMessage.Info[8].ToLower()))
                        {
                            sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                            return;
                        }

                        if (channel.Length == 1 && data.IsNullOrEmpty())
                        {
                            data += sIRCMessage.Info[8].ToLower();
                        }
                        else
                        {
                            data += SchumixBase.Comma + sIRCMessage.Info[8].ToLower();
                        }

                        SchumixBase.DManager.Update("gitinfo", string.Format("Channel = '{0}'", data), string.Format("LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName));
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    }
                }
                else if (sIRCMessage.Info[5].ToLower() == "remove")
                {
                    var text = sLManager.GetCommandTexts("git/channel/remove", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 3)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 8)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 9)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoChannelName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (!Rfc2812Util.IsValidChannelName(sIRCMessage.Info[8]))
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaChannelHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    var db = SchumixBase.DManager.QueryFirstRow("SELECT Channel FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName);
                    if (!db.IsNull())
                    {
                        string[] channel = db["Channel"].ToString().Split(SchumixBase.Comma);
                        string   data    = string.Empty;

                        if (!channel.ToList().Contains(sIRCMessage.Info[8].ToLower()))
                        {
                            sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                            return;
                        }

                        for (int x = 0; x < channel.Length; x++)
                        {
                            if (channel[x] == sIRCMessage.Info[8].ToLower())
                            {
                                continue;
                            }

                            data += SchumixBase.Comma + channel[x];
                        }

                        SchumixBase.DManager.Update("gitinfo", string.Format("Channel = '{0}'", data.Remove(0, 1, SchumixBase.Comma)), string.Format("LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName));
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    }
                }
            }
            else if (sIRCMessage.Info[4].ToLower() == "add")
            {
                var text = sLManager.GetCommandTexts("git/add", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 2)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 7)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 8)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("UrlMissing", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 9)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("WebsiteNameMissing", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[5].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[6]), sIRCMessage.ServerName);
                if (db.IsNull())
                {
                    bool started = false;

                    foreach (var list in RssList)
                    {
                        if (sIRCMessage.Info[5].ToLower() == list.Name.ToLower() && sIRCMessage.Info[6].ToLower() == list.Type.ToLower())
                        {
                            if (list.Started)
                            {
                                started = true;
                                continue;
                            }

                            list.Start();
                            started = true;
                        }
                    }

                    if (!started)
                    {
                        var rss = new GitRss(sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[5]), sUtilities.SqlEscape(sIRCMessage.Info[6]), sUtilities.SqlEscape(sIRCMessage.Info[7]), sUtilities.SqlEscape(sIRCMessage.Info[8].ToLower()));
                        RssList.Add(rss);
                        rss.Start();
                    }

                    SchumixBase.DManager.Insert("`gitinfo`(ServerId, ServerName, Name, Type, Link, Website)", sIRCMessage.ServerId, sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[5]), sUtilities.SqlEscape(sIRCMessage.Info[6]), sUtilities.SqlEscape(sIRCMessage.Info[7]), sUtilities.SqlEscape(sIRCMessage.Info[8].ToLower()));
                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                }
            }
            else if (sIRCMessage.Info[4].ToLower() == "remove")
            {
                var text = sLManager.GetCommandTexts("git/remove", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 2)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info.Length < 7)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[5].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[6]), sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    GitRss gitr   = null;
                    bool   isstop = false;

                    foreach (var list in RssList)
                    {
                        if (sIRCMessage.Info[5].ToLower() == list.Name.ToLower() && sIRCMessage.Info[6].ToLower() == list.Type.ToLower())
                        {
                            if (!list.Started)
                            {
                                isstop = true;
                                continue;
                            }

                            list.Stop();
                            gitr   = list;
                            isstop = true;
                        }
                    }

                    if (isstop && !gitr.IsNull())
                    {
                        RssList.Remove(gitr);
                    }

                    SchumixBase.DManager.Delete("gitinfo", string.Format("Name = '{0}' And Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[5]), sUtilities.SqlEscape(sIRCMessage.Info[6]), sIRCMessage.ServerName));
                    sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                }
            }
            else if (sIRCMessage.Info[4].ToLower() == "change")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoCommand", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                if (sIRCMessage.Info[5].ToLower() == "colors")
                {
                    var text = sLManager.GetCommandTexts("git/change/colors", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 2)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 8)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 9)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("StatusIsMissing", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (!sIRCMessage.Info[8].IsBoolean())
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ValueIsNotTrueOrFalse", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    var db = SchumixBase.DManager.QueryFirstRow("SELECT Colors FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName);
                    if (!db.IsNull())
                    {
                        bool enabled = db["Colors"].ToBoolean();

                        if (sIRCMessage.Info[8].ToBoolean() == enabled)
                        {
                            if (enabled)
                            {
                                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOn", sIRCMessage.Channel, sIRCMessage.ServerName));
                                return;
                            }
                            else
                            {
                                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOff", sIRCMessage.Channel, sIRCMessage.ServerName));
                                return;
                            }
                        }

                        SchumixBase.DManager.Update("gitinfo", string.Format("Colors = '{0}'", sIRCMessage.Info[8].ToLower()), string.Format("LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName));
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    }
                }
                else if (sIRCMessage.Info[5].ToLower() == "shorturl")
                {
                    var text = sLManager.GetCommandTexts("git/change/shorturl", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 2)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 8)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 9)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("StatusIsMissing", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (!sIRCMessage.Info[8].IsBoolean())
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ValueIsNotTrueOrFalse", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    var db = SchumixBase.DManager.QueryFirstRow("SELECT ShortUrl FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName);
                    if (!db.IsNull())
                    {
                        bool enabled = db["ShortUrl"].ToBoolean();

                        if (sIRCMessage.Info[8].ToBoolean() == enabled)
                        {
                            if (enabled)
                            {
                                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOn", sIRCMessage.Channel, sIRCMessage.ServerName));
                                return;
                            }
                            else
                            {
                                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOff", sIRCMessage.Channel, sIRCMessage.ServerName));
                                return;
                            }
                        }

                        SchumixBase.DManager.Update("gitinfo", string.Format("ShortUrl = '{0}'", sIRCMessage.Info[8].ToLower()), string.Format("LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName));
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                    }
                }
                else if (sIRCMessage.Info[5].ToLower() == "url")
                {
                    var text = sLManager.GetCommandTexts("git/change/url", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 2)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 8)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 9)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("UrlMissing", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName);
                    if (!db.IsNull())
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                        return;
                    }

                    SchumixBase.DManager.Update("gitinfo", string.Format("Link = '{0}'", sUtilities.SqlEscape(sIRCMessage.Info[8])), string.Format("LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName));
                    GitRss gitr   = null;
                    bool   isstop = false;

                    foreach (var list in RssList)
                    {
                        if (sIRCMessage.Info[6].ToLower() == list.Name.ToLower() && sIRCMessage.Info[7].ToLower() == list.Type.ToLower())
                        {
                            if (!list.Started)
                            {
                                isstop = true;
                                continue;
                            }

                            list.Stop();
                            gitr   = list;
                            isstop = true;
                        }
                    }

                    if (isstop && !gitr.IsNull())
                    {
                        RssList.Remove(gitr);
                    }

                    var db1 = SchumixBase.DManager.QueryFirstRow("SELECT Link, Website FROM gitinfo WHERE LOWER(Name) = '{0}' And Type = '{1}' And ServerName = '{2}'", sIRCMessage.Info[6].ToLower(), sIRCMessage.Info[7], sIRCMessage.ServerName);
                    if (!db1.IsNull())
                    {
                        var rss = new GitRss(sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[6]), sUtilities.SqlEscape(sIRCMessage.Info[7]), db1["Link"].ToString(), db1["Website"].ToString());
                        RssList.Add(rss);
                        rss.Start();
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                }
                else if (sIRCMessage.Info[5].ToLower() == "website")
                {
                    var text = sLManager.GetCommandTexts("git/change/website", sIRCMessage.Channel, sIRCMessage.ServerName);
                    if (text.Length < 2)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 7)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 8)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoTypeName", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    if (sIRCMessage.Info.Length < 9)
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("WebsiteNameMissing", sIRCMessage.Channel, sIRCMessage.ServerName));
                        return;
                    }

                    var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM gitinfo WHERE LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName);
                    if (!db.IsNull())
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[0]);
                        return;
                    }

                    SchumixBase.DManager.Update("gitinfo", string.Format("Website = '{0}'", sUtilities.SqlEscape(sIRCMessage.Info[8].ToLower())), string.Format("LOWER(Name) = '{0}' AND Type = '{1}' And ServerName = '{2}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sUtilities.SqlEscape(sIRCMessage.Info[7]), sIRCMessage.ServerName));
                    GitRss gitr   = null;
                    bool   isstop = false;

                    foreach (var list in RssList)
                    {
                        if (sIRCMessage.Info[6].ToLower() == list.Name.ToLower() && sIRCMessage.Info[7].ToLower() == list.Type.ToLower())
                        {
                            if (!list.Started)
                            {
                                isstop = true;
                                continue;
                            }

                            list.Stop();
                            gitr   = list;
                            isstop = true;
                        }
                    }

                    if (isstop && !gitr.IsNull())
                    {
                        RssList.Remove(gitr);
                    }

                    var db1 = SchumixBase.DManager.QueryFirstRow("SELECT Link, Website FROM gitinfo WHERE LOWER(Name) = '{0}' And Type = '{1}' And ServerName = '{2}'", sIRCMessage.Info[6].ToLower(), sIRCMessage.Info[7], sIRCMessage.ServerName);
                    if (!db1.IsNull())
                    {
                        var rss = new GitRss(sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[6]), sUtilities.SqlEscape(sIRCMessage.Info[7]), db1["Link"].ToString(), db1["Website"].ToString());
                        RssList.Add(rss);
                        rss.Start();
                    }

                    sSendMessage.SendChatMessage(sIRCMessage, text[1]);
                }
            }
        }
示例#24
0
 public IRCCommandEventArgs(IRCMessage message)
 {
     Message = message;
 }
        public void ParsesOrigin()
        {
            string message = ":[email protected] PRIVMSG ###cards :!card 4 2";
            var parsed = new IRCMessage(message);

            Assert.AreEqual(parsed.Origin.Host, "irc.puckipedia.com", "Host is incorrect!");
            Assert.AreEqual(parsed.Origin.User, "puck", "User is incorrect!");
            Assert.AreEqual(parsed.Origin.Nick, "puckipedia", "Nick is incorrect!");
        }
示例#26
0
        private void ConsoleWrite(IRCMessage pMessage)
        {
            string hour    = FormatTime(DateTime.Now.Hour);
            string minutes = FormatTime(DateTime.Now.Minute);
            // default color
            //            Console.WriteLine($"{hour}:{minutes} - {pUsername}: {pText}");
            int    viewers   = TwitchAPI.GetNumberOfViewers();
            int    followers = TwitchAPI.GetNumberOfFollowers();
            String uptime    = TwitchAPI.GetUpdateTime();

            //Dont show info in other channel.
            if (pMessage.isChannelMessage)
            {
                // UpTime
                Write($"{uptime}", ConsoleColor.Red);
                // Spacer
                Write($" - ", ConsoleColor.Yellow);

                // Followers
                Write($"{followers}", ConsoleColor.Red);
                // Spacer
                Write($" - ", ConsoleColor.Yellow);

                // Viewers
                Write($"{viewers}", ConsoleColor.Red);
                // Spacer
                Write($" - ", ConsoleColor.Yellow);

                // color coded for readability.
                // Time
                Write($"{hour}:{minutes}", ConsoleColor.Cyan);
                // Spacer
                Write($" - ", ConsoleColor.Yellow);
            }
            else
            {
                // Show Channal
                Write(pMessage.channel, ConsoleColor.Red);
                // Spacer
                Write($" - ", ConsoleColor.Yellow);
            }

            // Username
            // TODO: Add some Color Randomization based off username
            ConsoleColor userColor = ConsoleColor.Cyan;

            if (!pMessage.isChannelMessage)
            {
                userColor = ConsoleColor.DarkRed;
            }
            if (TwitchAPI.IsFollower(pMessage.userName))
            {
                userColor = ConsoleColor.Magenta;
            }
            Write(pMessage.userName, userColor);

            // Spacer
            Write($": ", ConsoleColor.Yellow);
            // Message

            WriteLine(pMessage.message, pMessage.isChannelMessage ? ConsoleColor.White : ConsoleColor.Gray);
        }
示例#27
0
    private void Update()
    {
        lock (_receiveQueue)
            while (_receiveQueue.Count > 0)
            {
                IRCMessage message = _receiveQueue.Dequeue();
                if (!message.Internal)
                {
                    bool isCommand = message.Text.StartsWith("!");

                    TwitchMessage  twitchMessage  = null;
                    CoroutineQueue coroutineQueue = TwitchPlaysService.Instance.CoroutineQueue;
                    if (isCommand)
                    {
                        HighlightGroup.alpha = 1;

                        twitchMessage = Instantiate(MessagePrefab, MessageScrollContents.transform, false);
                        twitchMessage.SetMessage(string.IsNullOrEmpty(message.UserColorCode)
                                                        ? $"<b>{message.UserNickName}</b>: {message.Text}"
                                                        : $"<b><color={message.UserColorCode}>{message.UserNickName}</color></b>: {message.Text}");

                        TwitchPlaysService.Instance.CoroutineQueue.AddToQueue(HighlightMessage(twitchMessage));
                    }

                    coroutineQueue.QueueModified = false;
                    try
                    {
                        OnMessageReceived.Invoke(message);
                    }
                    catch (Exception exception)
                    {
                        DebugHelper.LogException(exception, "An exception has occurred while invoking OnMessageRecieved:");
                    }

                    if (!coroutineQueue.QueueModified && twitchMessage != null)
                    {
                        Destroy(twitchMessage.gameObject);
                    }
                    else if (isCommand)
                    {
                        TwitchPlaysService.Instance.CoroutineQueue.AddToQueue(HideMessage(twitchMessage));
                    }
                }

                InternalMessageReceived(message.UserNickName, message.UserColorCode, message.Text);
            }

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

        float vertScroll = 0;

        foreach (KeyValuePair <TwitchMessage, float> pair in ScrollOutStartTime.ToArray())
        {
            TwitchMessage twitchMessage = pair.Key;
            if (twitchMessage == null)
            {
                ScrollOutStartTime.Remove(twitchMessage);
                continue;
            }

            float alpha = Mathf.Pow(Mathf.Min((Time.time - pair.Value) / 0.167f, 1), 4);
            if (alpha < 1)
            {
                vertScroll += alpha * twitchMessage.GetComponent <RectTransform>().rect.height;
            }
            else
            {
                ScrollOutStartTime.Remove(twitchMessage);
                Destroy(twitchMessage.gameObject);
            }
        }

        // ReSharper disable InconsistentlySynchronizedField
        Vector3 localPosition = MessageScrollContents.transform.localPosition;

        MessageScrollContents.transform.localPosition = new Vector3(localPosition.x, vertScroll, localPosition.z);
        // ReSharper restore InconsistentlySynchronizedField
    }
示例#28
0
 private void InvokeCommand(IRCMessage msg, string cmdStr, params Type[] commandTypes) => InvokeCommand(msg, cmdStr, false, commandTypes);
示例#29
0
        public void HandleTest(IRCMessage sIRCMessage)
        {
            if (!IsAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.Administrator))
            {
                return;
            }

            var sSendMessage = sIrcBase.Networks[sIRCMessage.ServerName].sSendMessage;

            if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "adat")
            {
                sSendMessage.SendChatMessage(sIRCMessage, "Teszt próbálkozás");
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "db")
            {
                var db = SchumixBase.DManager.Query("SELECT Name FROM admins WHERE ServerName = '{0}'", sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    foreach (DataRow row in db.Rows)
                    {
                        string admin = row["Name"].ToString();
                        sSendMessage.SendChatMessage(sIRCMessage, "{0}", admin);
                    }
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "rss")
            {
                var rss = new XmlDocument();
                rss.Load("http://www.assembla.com/spaces/Sandshroud/stream.rss");
                //rss.Load("http://github.com/megax/Schumix2/commits/master.atom");

                var node = rss.SelectSingleNode("rss/channel/item/title");
                //var node = rss.SelectSingleNode("feed/title");
                string title = !node.IsNull() ? node.InnerText : string.Empty;
                sSendMessage.SendChatMessage(sIRCMessage, title);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "vhost")
            {
                sSendMessage.SendChatMessage(sIRCMessage, sIRCMessage.Host);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "amsg")
            {
                sSendMessage.SendCMAmsg("teszt");
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "me")
            {
                sSendMessage.SendCMAction(sIRCMessage.Channel, sIRCMessage.Info.SplitToString(5, SchumixBase.Space));
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "ctcprequest")
            {
                sSendMessage.SendCMCtcpRequest(sIRCMessage.Channel, sIRCMessage.Info.SplitToString(5, SchumixBase.Space));
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "ctcpreply")
            {
                sSendMessage.SendCMCtcpReply(sIRCMessage.Channel, sIRCMessage.Info.SplitToString(5, SchumixBase.Space));
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "text")
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName));
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "durl")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoValue", sIRCMessage.Channel, sIRCMessage.ServerName));
                    return;
                }

                var request = (HttpWebRequest)WebRequest.Create(sIRCMessage.Info[5]);
                request.AllowAutoRedirect = true;
                request.UserAgent         = Consts.SchumixUserAgent;
                request.Referer           = Consts.SchumixReferer;
                var sb = new StringBuilder();

                using (var response = request.GetResponse())
                {
                    using (var stream = response.GetResponseStream())
                    {
                        int    length = 0;
                        byte[] buf    = new byte[1024];

                        while ((length = stream.Read(buf, 0, buf.Length)) != 0)
                        {
                            if (sb.ToString().Contains("</title>"))
                            {
                                break;
                            }

                            sb.Append(Encoding.UTF8.GetString(buf, 0, length));
                        }
                    }
                }

                sSendMessage.SendChatMessage(sIRCMessage, "{0}", sb.Length);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "cachedb")
            {
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("xbot"));
                sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandTexts("xbot")[1]);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "istable")
            {
                if (SchumixBase.DManager.IsCreatedTable("admins"))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, "létezik!");
                }

                if (!SchumixBase.DManager.IsCreatedTable("admin"))
                {
                    sSendMessage.SendChatMessage(sIRCMessage, "nem létezik!");
                }
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "urlshort")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, "Nincs megadva a rövidíteni kívánt url!");
                    return;
                }

                sSendMessage.SendChatMessage(sIRCMessage, BitlyApi.ShortenUrl(sIRCMessage.Info[5]).ShortUrl);
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "serv")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, "Nincs megadva a szervíz neve!");
                    return;
                }

                sSendMessage.SendChatMessage(sIRCMessage, "{0}", sIRCMessage.Info[5].IsServ());
                sSendMessage.SendChatMessage(sIRCMessage, "{0}", sIRCMessage.Info[5].IsServ(Serv.HostServ));
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "isoutredirected")
            {
#if false
                var writer = new StringWriter();
                Console.SetOut(writer);

                sSendMessage.SendChatMessage(sIRCMessage, "Konzol kimenet átírányítása: {0}", Console.IsOutputRedirected);

                var sw = new StreamWriter(Console.OpenStandardOutput());
                sw.AutoFlush = true;
                Console.SetOut(sw);

                sSendMessage.SendChatMessage(sIRCMessage, "Konzol kimenet átírányítása: {0}", Console.IsOutputRedirected);
#endif
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "ismonthname")
            {
                if (sIRCMessage.Info.Length < 6)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, "Nincs megadva a hónap neve!");
                    return;
                }

                sSendMessage.SendChatMessage(sIRCMessage, "{0}", sIRCMessage.Info[5].IsMonthName());
            }
            else if (sIRCMessage.Info.Length >= 5 && sIRCMessage.Info[4].ToLower() == "dbrank")
            {
                var db = SchumixBase.DManager.Query("SELECT Flag FROM admins WHERE ServerName = '{0}'", sIRCMessage.ServerName);
                if (!db.IsNull())
                {
                    foreach (DataRow row in db.Rows)
                    {
                        int rank = row["Flag"].ToInt32();

                        if (rank == 0)
                        {
                            Log.WriteLine("Admin rang: 0");
                        }

                        if (rank == 1)
                        {
                            Log.WriteLine("Admin rang: 1");
                        }

                        if (rank == 2)
                        {
                            Log.WriteLine("Admin rang: 2");
                        }
                    }
                }
                else
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName));
                }
            }
            else
            {
                sSendMessage.SendChatMessage(sIRCMessage, "{0}", sIRCMessage.Info.Length);
            }
        }
示例#30
0
    private bool AttemptInvokeCommand <TObj>(StaticCommand command, IRCMessage msg, string cmdStr, Match m, TObj extraObject)
    {
        if (command.HasAttribute <DebuggingOnlyAttribute>() && !TwitchPlaySettings.data.EnableDebuggingCommands)
        {
            return(false);
        }
        if (command.HasAttribute <ElevatorOnlyAttribute>() && !(GameRoom.Instance is ElevatorGameRoom))
        {
            return(false);
        }
        if (command.HasAttribute <ElevatorDisallowedAttribute>() && GameRoom.Instance is ElevatorGameRoom)
        {
            return(false);
        }

        if (!UserAccess.HasAccess(msg.UserNickName, TwitchPlaySettings.data.AnarchyMode ? command.Attr.AccessLevelAnarchy : command.Attr.AccessLevel, orHigher: true))
        {
            IRCConnection.SendMessageFormat("@{0}, you need {1} access to use that command{2}.",
                                            msg.UserNickName,
                                            UserAccess.LevelToString(TwitchPlaySettings.data.AnarchyMode ? command.Attr.AccessLevelAnarchy : command.Attr.AccessLevel),
                                            TwitchPlaySettings.data.AnarchyMode ? " in anarchy mode" : "");
            // Return true so that the command counts as processed
            return(true);
        }

        if (extraObject is TwitchModule mdl)
        {
            if (mdl.Solved && !command.HasAttribute <SolvedAllowedAttribute>() && !TwitchPlaySettings.data.AnarchyMode)
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.AlreadySolved, mdl.Code, mdl.PlayerName, msg.UserNickName, mdl.BombComponent.GetModuleDisplayName());
                // Return true so that the command counts as processed (otherwise you get the above message multiple times)
                return(true);
            }

            if (mdl.Hidden)
            {
                IRCConnection.SendMessage($"Module {mdl.Code} is currently hidden and cannot be interacted with.");
                return(true);
            }
        }

        Leaderboard.Instance.GetRank(msg.UserNickName, out Leaderboard.LeaderboardEntry entry);
        if (entry?.Team == null && extraObject is TwitchModule && OtherModes.VSModeOn)
        {
            IRCConnection.SendMessage($@"{msg.UserNickName}, you have not joined a team, and cannot solve modules in this mode until you do, please use !join evil or !join good.");
            // Return true so that the command counts as processed (otherwise you get the above message multiple times)
            return(true);
        }

        if (!TwitchGame.IsAuthorizedDefuser(msg.UserNickName, msg.IsWhisper))
        {
            return(true);
        }

        BanData ban = UserAccess.IsBanned(msg.UserNickName);

        if (ban != null)
        {
            if (double.IsPositiveInfinity(ban.BanExpiry))
            {
                IRCConnection.SendMessage($"Sorry @{msg.UserNickName}, You were banned permanently from Twitch Plays by {ban.BannedBy}{(string.IsNullOrEmpty(ban.BannedReason) ? "." : $", for the following reason: {ban.BannedReason}")}", msg.UserNickName, !msg.IsWhisper);
            }
            else
            {
                int secondsRemaining = (int)(ban.BanExpiry - DateTime.Now.TotalSeconds());

                int    daysRemaining    = secondsRemaining / 86400; secondsRemaining %= 86400;
                int    hoursRemaining   = secondsRemaining / 3600; secondsRemaining %= 3600;
                int    minutesRemaining = secondsRemaining / 60; secondsRemaining %= 60;
                string timeRemaining    = $"{secondsRemaining} seconds.";
                if (daysRemaining > 0)
                {
                    timeRemaining = $"{daysRemaining} days, {hoursRemaining} hours, {minutesRemaining} minutes, {secondsRemaining} seconds.";
                }
                else if (hoursRemaining > 0)
                {
                    timeRemaining = $"{hoursRemaining} hours, {minutesRemaining} minutes, {secondsRemaining} seconds.";
                }
                else if (minutesRemaining > 0)
                {
                    timeRemaining = $"{minutesRemaining} minutes, {secondsRemaining} seconds.";
                }

                IRCConnection.SendMessage($"Sorry @{msg.UserNickName}, You were timed out from Twitch Plays by {ban.BannedBy}{(string.IsNullOrEmpty(ban.BannedReason) ? "." : $", For the following reason: {ban.BannedReason}")} You can participate again in {timeRemaining}", msg.UserNickName, !msg.IsWhisper);
            }
            return(true);
        }

        var parameters = command.Method.GetParameters();
        var groupAttrs = parameters.Select(p => (GroupAttribute)p.GetCustomAttributes(typeof(GroupAttribute), false).FirstOrDefault()).ToArray();
        var arguments  = new object[parameters.Length];

        for (int i = 0; i < parameters.Length; i++)
        {
            // Capturing groups from the regular expression
            if (groupAttrs[i] != null && m != null)
            {
                var group = m.Groups[groupAttrs[i].GroupIndex];
                NumberParseResult result;

                // Helper function to parse numbers (ints, floats, doubles)
                NumberParseResult IsNumber <TNum>(TryParse <TNum> tryParse)
                {
                    var isNullable = parameters[i].ParameterType == typeof(Nullable <>).MakeGenericType(typeof(TNum));

                    if (parameters[i].ParameterType != typeof(TNum) && !isNullable)
                    {
                        return(NumberParseResult.NotOfDesiredType);
                    }

                    if (group.Success && tryParse(group.Value, out TNum rslt))
                    {
                        arguments[i] = rslt;
                        return(NumberParseResult.Success);
                    }
                    if (isNullable)
                    {
                        return(NumberParseResult.Success);
                    }
                    IRCConnection.SendMessage(group.Success ? "@{0}, “{1}” is not a valid number." : "@{0}, the command could not be parsed.", msg.UserNickName, !msg.IsWhisper, msg.UserNickName, group.Success ? group.Value : null);
                    return(NumberParseResult.Error);
                }

                // Strings
                if (parameters[i].ParameterType == typeof(string))
                {
                    arguments[i] = m.Success ? group.Value : null;
                }

                // Booleans — only specifies whether the group matched or not
                else if (parameters[i].ParameterType == typeof(bool))
                {
                    arguments[i] = group.Success;
                }

                // Numbers (int, float, double); includes nullables
                else if (
                    (result = IsNumber <int>(int.TryParse)) != NumberParseResult.NotOfDesiredType ||
                    (result = IsNumber <float>(float.TryParse)) != NumberParseResult.NotOfDesiredType ||
                    (result = IsNumber <double>(double.TryParse)) != NumberParseResult.NotOfDesiredType)
                {
                    if (result == NumberParseResult.Error)
                    {
                        return(true);
                    }
                }
            }

            // Built-in parameter names
            else if (parameters[i].ParameterType == typeof(string) && parameters[i].Name == "user")
            {
                arguments[i] = msg.UserNickName;
            }
            else if (parameters[i].ParameterType == typeof(string) && parameters[i].Name == "cmd")
            {
                arguments[i] = cmdStr;
            }
            else if (parameters[i].ParameterType == typeof(bool) && parameters[i].Name == "isWhisper")
            {
                arguments[i] = msg.IsWhisper;
            }
            else if (parameters[i].ParameterType == typeof(IRCMessage))
            {
                arguments[i] = msg;
            }
            else if (parameters[i].ParameterType == typeof(KMGameInfo))
            {
                arguments[i] = GetComponent <KMGameInfo>();
            }
            else if (parameters[i].ParameterType == typeof(KMGameInfo.State))
            {
                arguments[i] = CurrentState;
            }
            else if (parameters[i].ParameterType == typeof(FloatingHoldable) && extraObject is TwitchHoldable twitchHoldable)
            {
                arguments[i] = twitchHoldable.Holdable;
            }

            // Object we passed in (module, bomb, holdable)
            else if (parameters[i].ParameterType.IsAssignableFrom(typeof(TObj)))
            {
                arguments[i] = extraObject;
            }
            else if (parameters[i].IsOptional)
            {
                arguments[i] = parameters[i].DefaultValue;
            }
            else
            {
                IRCConnection.SendMessage("@{0}, this is a bug; please notify the devs. Error: the “{1}” command has an unrecognized parameter “{2}”. It expects a type of “{3}”, and the extraObject is of type “{4}”.", msg.UserNickName, !msg.IsWhisper, msg.UserNickName, command.Method.Name, parameters[i].Name, parameters[i].ParameterType.Name, extraObject?.GetType().Name);
                return(true);
            }
        }

        var invokeResult = command.Method.Invoke(null, arguments);

        if (invokeResult is bool invRes)
        {
            return(invRes);
        }
        else if (invokeResult is IEnumerator coroutine)
        {
            ProcessCommandCoroutine(coroutine, extraObject);
        }
        else if (invokeResult != null)
        {
            IRCConnection.SendMessage("@{0}, this is a bug; please notify the devs. Error: the “{1}” command returned something unrecognized.", msg.UserNickName, !msg.IsWhisper, msg.UserNickName, command.Method.Name);
        }

        if ((TwitchPlaySettings.data.AnarchyMode ? command.Attr.AccessLevelAnarchy : command.Attr.AccessLevel) > AccessLevel.Defuser)
        {
            AuditLog.Log(msg.UserNickName, UserAccess.HighestAccessLevel(msg.UserNickName), msg.Text);
        }
        return(true);
    }
示例#31
0
        public static void ResolvePurchase(Viewer viewer, IRCMessage message, bool separateChannel = false)
        {
            List <string> command = message.Message.Split(' ').ToList();

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

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

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

            Helper.Log(productKey);
            message.Message = string.Join(" ", command.ToArray());

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

            if (incident != null)
            {
                ResolvePurchaseSimple(viewer, message, incident, separateChannel);
                return;
            }

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

            if (incidentVariables != null)
            {
                ResolvePurchaseVariables(viewer, message, incidentVariables, separateChannel);
                return;
            }

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

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

            if (item != null)
            {
                List <String> commandSplit = message.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");
                }

                message.Message = string.Join(" ", commandSplit.ToArray());

                ResolvePurchaseVariables(viewer, message, StoreIncidentDefOf.Item, separateChannel);
            }

            return;
        }
示例#32
0
 protected void HandleMessage(IRCMessage message)
 {
 }
示例#33
0
文件: SedPlugin.cs 项目: jandk/ircbot
        private void HandleMessage(IRCMessage message)
        {
            // Weust` found this bug.
            if (Bot.MessagesByUser(message.User).All(m => SedRegex.IsMatch(m.Message)))
                return;

            var match = SedRegex.Match(message.Message);

            // 1: Check the modifiers
            bool global = false;
            bool caseInsensitive = false;

            if (match.Groups[4].Success)
            {
                string modifier = match.Groups[4].Value;

                if (modifier.Contains("g"))
                    global = true;
                if (modifier.Contains("i") || modifier.Contains("I"))
                    caseInsensitive = true;
            }

            // 2: Check if the regex is valid.
            Regex regex;
            try
            {
                regex = new Regex(
                    match.Groups[2].Value,
                    caseInsensitive ? RegexOptions.IgnoreCase : RegexOptions.None
                );
            }
            catch (ArgumentException) { return; }

            // 3: Check for the message offset
            int offset = 0;
            if (match.Groups[5].Success)
                offset = Convert.ToInt32(match.Groups[5].Value) - 1;

            // 4: Check what mode we're in
            string mode = match.Groups[1].Value;

            string replacement = String.Empty;
            if (mode == "d")
            {
                if (match.Groups[3].Success)
                    return;
            }
            if (mode == "s")
            {
                if (!match.Groups[3].Success)
                    return;

                replacement = match.Groups[3].Value;
                replacement = replacement.Replace("$", @"\$");
                replacement = RepRegex.Replace(replacement, "$$1");
            }

            var msg = Bot.MessagesByUser(message.User).Where(m => !SedRegex.IsMatch(m.Message))
                                                      .Skip(offset)
                                                      .FirstOrDefault();

            if (msg != null && regex.IsMatch(msg.Message))
            {
                // Send the edited message
                Bot.SendChannelMessage(
                    message.Channel,
                    String.Format(
                        "{0} meant: {1}",
                        message.Nick,
                        regex.Replace(msg.Message, replacement, global ? Int32.MaxValue : 1)
                    )
                );
            }
        }
示例#34
0
 public bool HandleHelp(IRCMessage sIRCMessage)
 {
     return(false);
 }
示例#35
0
 private bool WhoisCallback(IRCMessage Msg)
 {
     if (Msg.Count < 3)
         return true;
     String nick = Msg[1];
     String username = Msg[2];
     String host = Msg[3];
     List<string> chans;
     if (checkingUsers.TryGetValue(nick, out chans)) {
         CheckLogin(nick, username, host);
         if (!parserMod.UserHasAccessLevel(nick, IRCModuleUserAccess.Normal)) {
             foreach (string chan in chans) {
                 parserMod.SendRawMessage("KICK " + chan + " " + nick + " :Deine Hostmaske wurde nicht erkannt, bitte im Tool in den Einstellungen eintragen!");
             }
         }
         checkingUsers.Remove(nick);
     }
     return true;
 }
        public void ParsesCommand()
        {
            string message = ":[email protected] PRIVMSG ###cards :!card 4 2";
            var parsed = new IRCMessage(message);

            Assert.AreEqual(parsed.Command, "PRIVMSG");
            Assert.AreEqual(parsed.Origin.Host, "irc.puckipedia.com", "Host is incorrect!");
            Assert.AreEqual(parsed.Origin.User, "puck", "User is incorrect!");
            Assert.AreEqual(parsed.Origin.Nick, "puckipedia", "Nick is incorrect!");
            Assert.AreEqual(2, parsed.Arguments.Length, "Invalid argument count");

            Assert.AreEqual("###cards", parsed.Arguments[0], "Parsed first argument incorrectly");
            Assert.AreEqual("!card 4 2", parsed.Arguments[1], "Parsed second argument incorrectly");
        }
示例#37
0
        private void Warning(IRCMessage sIRCMessage)
        {
            var sSendMessage = sIrcBase.Networks[sIRCMessage.ServerName].sSendMessage;

            sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("compiler/warning", sIRCMessage.Channel, sIRCMessage.ServerName));
        }
示例#38
0
        public void FindLookup(IRCMessage msg, string searchObject, string searchQuery)
        {
            List <string> results = new List <string>();

            switch (searchObject)
            {
            case "disease":
                FindLookup(msg, "diseases", searchQuery);
                break;

            case "skill":
                FindLookup(msg, "skills", searchQuery);
                break;

            case "event":
                FindLookup(msg, "events", searchQuery);
                break;

            case "item":
                FindLookup(msg, "items", searchQuery);
                break;

            case "animal":
                FindLookup(msg, "animals", searchQuery);
                break;

            case "trait":
                FindLookup(msg, "traits", searchQuery);
                break;

            case "diseases":
                IncidentDef[] allDiseases = DefDatabase <IncidentDef> .AllDefs.Where(s =>
                                                                                     s.category == IncidentCategoryDefOf.DiseaseHuman &&
                                                                                     (string.Join("", s.LabelCap.RawText.Split(' ')).ToLower().Contains(searchQuery) ||
                                                                                      string.Join("", s.LabelCap.RawText.Split(' ')).ToLower() == searchQuery)
                                                                                     ).Take(10).ToArray();

                foreach (IncidentDef disease in allDiseases)
                {
                    results.Add(string.Join("", disease.LabelCap.RawText.Split(' ')).ToLower());
                }
                SendTenResults(msg, searchObject.CapitalizeFirst(), searchQuery, results.ToArray());
                break;

            case "skills":
                SkillDef[] allSkills = DefDatabase <SkillDef> .AllDefs.Where(s =>
                                                                             (string.Join("", s.LabelCap.RawText.Split(' ')).ToLower().Contains(searchQuery) ||
                                                                              string.Join("", s.LabelCap.RawText.Split(' ')).ToLower() == searchQuery)
                                                                             ).Take(10).ToArray();

                foreach (SkillDef skill in allSkills)
                {
                    results.Add(skill.defName.ToLower());
                }
                SendTenResults(msg, searchObject.CapitalizeFirst(), searchQuery, results.ToArray());
                break;

            case "events":
                StoreIncident[] allEvents = DefDatabase <StoreIncident> .AllDefs.Where(s =>
                                                                                       s.cost > 0 &&
                                                                                       (string.Join("", s.abbreviation.Split(' ')).ToLower().Contains(searchQuery) ||
                                                                                        string.Join("", s.abbreviation.Split(' ')).ToLower() == searchQuery ||
                                                                                        s.defName.ToLower().Contains(searchQuery) ||
                                                                                        s.defName.ToLower() == searchQuery)
                                                                                       ).Take(10).ToArray();

                foreach (StoreIncident evt in allEvents)
                {
                    results.Add(string.Join("", evt.abbreviation.Split(' ')).ToLower());
                }
                SendTenResults(msg, searchObject.CapitalizeFirst(), searchQuery, results.ToArray());
                break;

            case "items":
                Item[] allItems = StoreInventory.items.Where(s =>
                                                             s.price > 0 &&
                                                             (string.Join("", s.abr.Split(' ')).ToLower().Contains(searchQuery) ||
                                                              string.Join("", s.abr.Split(' ')).ToLower() == searchQuery ||
                                                              s.defname.ToLower().Contains(searchQuery) ||
                                                              s.defname.ToLower() == searchQuery)
                                                             ).Take(10).ToArray();

                foreach (Item item in allItems)
                {
                    results.Add(string.Join("", item.abr.Split(' ')).ToLower());
                }
                SendTenResults(msg, searchObject.CapitalizeFirst(), searchQuery, results.ToArray());
                break;

            case "animals":
                PawnKindDef[] allAnimals = DefDatabase <PawnKindDef> .AllDefs.Where(s =>
                                                                                    s.RaceProps.Animal &&
                                                                                    (string.Join("", s.LabelCap.RawText.Split(' ')).ToLower().Contains(searchQuery) ||
                                                                                     string.Join("", s.LabelCap.RawText.Split(' ')).ToLower() == searchQuery ||
                                                                                     s.defName.ToLower().Contains(searchQuery) ||
                                                                                     s.defName.ToLower() == searchQuery)
                                                                                    ).Take(10).ToArray();

                foreach (PawnKindDef animal in allAnimals)
                {
                    results.Add(animal.defName.ToLower());
                }
                SendTenResults(msg, searchObject.CapitalizeFirst(), searchQuery, results.ToArray());
                break;

            case "traits":
                BuyableTrait[] allTrait = AllTraits.buyableTraits.Where(s =>
                                                                        s.label.Contains(searchQuery) ||
                                                                        s.label == searchQuery ||
                                                                        s.def.defName.ToLower().Contains(searchQuery) ||
                                                                        s.def.defName == searchQuery
                                                                        ).Take(10).ToArray();

                foreach (BuyableTrait trait in allTrait)
                {
                    results.Add(trait.label);
                }
                SendTenResults(msg, searchObject.CapitalizeFirst(), searchQuery, results.ToArray());
                break;
            }
        }
示例#39
0
        private bool Ban(string data, IRCMessage sIRCMessage)
        {
            // DllImport
            if (data.Contains("DllImport"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Timers
            if (data.Contains("System.Timers"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            if (sPlatform.IsWindows)
            {
                return(false);
            }

            // Environment and Security
            if (data.Contains("Environment.Exit") || data.Contains("Environment.SetEnvironmentVariable") ||
                data.Contains("Environment.ExpandEnvironmentVariables") || data.Contains("Environment.FailFast") ||
                data.Contains("Environment.GetLogicalDrives") || data.Contains("Environment.GetEnvironmentVariables") ||
                data.Contains("Environment.CommandLine") || data.Contains("Environment.CurrentDirectory") ||
                data.Contains("Environment.GetFolderPath") || data.Contains("System.Security"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Input, Output
            if (data.Contains("System.IO"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Diagnostics
            if (data.Contains("System.Diagnostics"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Microsoft
            if (data.Contains("Microsoft.Win32") || data.Contains("Microsoft.CSharp"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Compile
            if (data.Contains("System.CodeDom"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Console
            if (data.Contains("Console.SetOut") || data.Contains("Console.Title") || data.Contains("Console.CancelKeyPress") ||
                data.Contains("Console.ResetColor") || data.Contains("Console.SetCursorPosition") ||
                data.Contains("Console.SetError") || data.Contains("Console.SetIn") || data.Contains("Console.SetWindowSize") ||
                data.Contains("Console.BackgroundColor") || data.Contains("Console.CapsLock") || data.Contains("Console.Cursor") ||
                data.Contains("Console.ForegroundColor") || data.Contains("Console.InputEncoding") ||
                data.Contains("Console.KeyAvailable") || data.Contains("Console.LargestWindow") ||
                data.Contains("Console.NumberLock") || data.Contains("Console.OutputEncoding") ||
                data.Contains("Console.TreatControlCAsInput") || data.Contains("Console.Window"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // System.Net
            if (data.Contains("System.Net.Dns") || data.Contains("System.Net.IPAddress") || data.Contains("System.Net.IPEndPoint") ||
                data.Contains("System.Net.IPHostEntry") || SystemNetRegex.IsMatch(data))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Assembly
            if (data.Contains("Assembly.Load") || data.Contains("Assembly.ReflectionOnlyLoad") || data.Contains("Assembly.UnsafeLoadFrom") ||
                data.Contains("Assembly.Location") || data.Contains("Assembly.EscapedCodeBase") || data.Contains("Assembly.CodeBase") ||
                data.Contains("Assembly.GetAssembly"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // AppDomain
            if (data.Contains("AppDomain"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Activator
            if (data.Contains("Activator"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            // Type
            if (data.Contains("GetMethod") || data.Contains("GetType") || data.Contains("GetInterfaces") || data.Contains("GetMember"))
            {
                Warning(sIRCMessage);
                return(true);
            }

            return(false);
        }
示例#40
0
 public override void Execute(object sender, IRCMessage message)
 {
     OnScriptMessage(IRCMessageFactory.BuildPongMessage(message.TrailingParameters));
 }
示例#41
0
 public override void Execute(object sender, IRCMessage message)
 {
     OnScriptMessage(IRCMessageFactory.BuildSendChannelMessage("bot", "Pipe Cleaner Invoked"));
 }
示例#42
0
 public void HandleQuit(IRCMessage sIRCMessage)
 {
     sNameList.Remove(string.Empty, sIRCMessage.Nick, true);
 }
        public void ParseWithoutOrigin()
        {
            string message = "PRIVMSG ###cards :!card 4 10";
            var parsed = new IRCMessage(message);

            Assert.AreEqual(parsed.Origin.Nick, null, "Parsed a nick");
            Assert.AreEqual(parsed.Origin.User, null, "Parsed a user");
            Assert.AreEqual(parsed.Origin.Host, null, "Parsed a host");
        }
示例#44
0
 public void HandleSuccessfulAuth(IRCMessage sIRCMessage)
 {
     sNameList.Channels.Clear();
 }
示例#45
0
        public override void ParseCommand(IRCMessage msg)
        {
            Viewer viewer = Viewers.GetViewer(msg.User);

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

            if (msg.Message.StartsWith("!mypawnskills") && Commands.AllowCommand(msg.Channel))
            {
                if (!component.HasUserBeenNamed(viewer.username))
                {
                    Toolkit.client.SendMessage($"@{viewer.username} you are not in the colony.", true);
                    return;
                }

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

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

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

                Toolkit.client.SendMessage(output, true);
            }

            if (msg.Message.StartsWith("!mypawnstory") && Commands.AllowCommand(msg.Channel))
            {
                if (!component.HasUserBeenNamed(viewer.username))
                {
                    Toolkit.client.SendMessage($"@{viewer.username} you are not in the colony.", true);
                    return;
                }

                Pawn pawn = component.PawnAssignedToUser(viewer.username);

                string output = $"@{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].titleShort;
                    if (i != backstories.Count - 1)
                    {
                        output += ", ";
                    }
                }

                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, true);
            }

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

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

                string newName = command[1];

                if (newName == null || newName == "" || newName.Length > 16)
                {
                    Toolkit.client.SendMessage($"@{viewer.username} your name can be up to 16 characters.", true);
                    return;
                }

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

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

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

            if (Viewer.IsModerator(viewer.username) || 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($"@{viewer.username} invalid username", false);
                        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($"@{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($"@{viewer.username} invalid username", false);
                        return;
                    }

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

                    nameRequests.Remove(username);
                    Toolkit.client.SendMessage($"@{viewer.username} declined name change request from {username}");
                }
            }
        }
示例#46
0
        /// <summary>
        ///     Ha a szobában a köszönés funkció be van kapcsolva,
        ///     akkor köszön az éppen belépőnek.
        /// </summary>
        public void HandleJoin(IRCMessage sIRCMessage)
        {
            if (sIRCMessage.Nick == sIrcBase.Networks[sIRCMessage.ServerName].sMyNickInfo.NickStorage)
            {
                return;
            }

            if (sFunctions.AutoKick("join", sIRCMessage.Nick, sIRCMessage.Channel))
            {
                return;
            }

            if (sIrcBase.Networks[sIRCMessage.ServerName].sIgnoreNickName.IsIgnore(sIRCMessage.Nick))
            {
                return;
            }

            var sMyChannelInfo = sIrcBase.Networks[sIRCMessage.ServerName].sMyChannelInfo;
            var sSendMessage   = sIrcBase.Networks[sIRCMessage.ServerName].sSendMessage;
            var sSender        = sIrcBase.Networks[sIRCMessage.ServerName].sSender;

            sIRCMessage.Channel = sIRCMessage.Channel.Remove(0, 1, SchumixBase.Colon);
            sNameList.Add(sIRCMessage.Channel, sIRCMessage.Nick);

            if (sMyChannelInfo.FSelect(IFunctions.Automode) && sMyChannelInfo.FSelect(IChannelFunctions.Automode, sIRCMessage.Channel))
            {
                AutoMode    = true;
                ModeChannel = sIRCMessage.Channel;
                sSender.NickServStatus(sIRCMessage.Nick);
            }

            if (sMyChannelInfo.FSelect(IFunctions.Greeter) && sMyChannelInfo.FSelect(IChannelFunctions.Greeter, sIRCMessage.Channel))
            {
                var    rand    = new Random();
                string greeter = string.Empty;
                var    text    = sLManager.GetCommandTexts("handlejoin", sIRCMessage.Channel, sIRCMessage.ServerName);
                if (text.Length < 3)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)));
                    return;
                }

                var text2 = sLManager.GetCommandTexts("handlejoin/random", sIRCMessage.Channel, sIRCMessage.ServerName);
                greeter = text2[rand.Next(0, text2.Length - 1)];

                if (DateTime.Now.Hour >= 3 && DateTime.Now.Hour <= 9)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[0], sIRCMessage.Nick);
                }
                else if (DateTime.Now.Hour >= 20 && DateTime.Now.Hour < 3)
                {
                    sSendMessage.SendChatMessage(sIRCMessage, text[1], sIRCMessage.Nick);
                }
                else
                {
                    if (IsAdmin(sIRCMessage.Nick, sIRCMessage.Host))
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, text[2]);
                    }
                    else
                    {
                        sSendMessage.SendChatMessage(sIRCMessage, "{0} {1}", greeter, sIRCMessage.Nick);
                    }
                }
            }
        }
示例#47
0
        private static void CreateThread(IRCMessage pMessageInfo)
        {
            Sync synth = null;

            try
            {
                var text     = pMessageInfo.message;
                var username = pMessageInfo.userName;

                if (text.Length > 230)
                {
                    var split = text.Split(' ').ToList().Distinct().ToArray();
                    text = String.Join(" ", split);
                }

                bool speakUserName = false;
                while (true)
                {
                    if (_readyStateSyncQueue.Count > 0)
                    {
                        lock (_readyStateSyncQueue)
                        {
                            if (_readyStateSyncQueue.Count > 0)
                            {
                                if (_lastUserName != username)
                                {
                                    _lastUserName = username;
                                    speakUserName = true;
                                }

                                if ((DateTime.Now - _lastUserNameDateTime).TotalMinutes > 2)
                                {
                                    speakUserName         = true;
                                    _lastUserNameDateTime = DateTime.Now;
                                }

                                synth = _readyStateSyncQueue.Dequeue();
                                break;
                            }
                        }
                    }

                    ResetEvent.WaitOne(1000);
                    ResetEvent.Reset();
                }


                //Clean out addresses.
                var words = text.Split(' ').ToArray();
                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i].ToLower().Contains("http"))
                    {
                        words[i] = string.Empty;
                    }
                }
                text = string.Join(" ", words);
                //CLEAN TEXT

                synth.SetRate(username, text);
                if (speakUserName)
                {
                    synth.Synth.Speak(username);
                }
                synth.RandomVoice(username);

                // Speak a string.
                synth.Speak(text);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
            finally
            {
                if (synth != null)
                {
                    synth.Enqueue();
                }

                thread++;
            }
        }
示例#48
0
 public static void IrcHandleTest2(IRCMessage sIRCMessage)
 {
     //Log.WriteLine(sIRCMessage.Args);
 }
 public CommandQueueItem(IRCMessage msg, string name = null)
 {
     Message = msg;
     Name    = name;
 }
示例#50
0
 /// <summary>
 /// IRCサーバからのメッセージを送信します
 /// </summary>
 /// <param name="msg"></param>
 public void SendServerMessage(IRCMessage msg)
 {
     msg.Prefix = Server.ServerName;
     Send(msg);
 }