예제 #1
0
        public static void AddBasicCommand(string name, string response)
        {
            var command = new BasicCommand()
            {
                name     = name,
                response = response
            };

            Program.Settings.Commands.Add(command);
            Program.Settings.Save();
        }
예제 #2
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            //if (e.ChatMessage.Message.Contains("badword"))
            //client.TimeoutUser(e.ChatMessage.Channel, e.ChatMessage.Username, TimeSpan.FromMinutes(30), "Bad word! 30 minute timeout!");

            string message = e.ChatMessage.Message;

            if (message.Contains("!"))
            {
                if (message.Contains("!addcom"))
                {
                    var split = message.Split(' ');

                    if (split.Length <= 2)
                    {
                        client.SendWhisper(e.ChatMessage.Username, "Vous devez renseigner une commande valide.");
                        return;
                    }

                    string commandName = split[1];
                    string response    = split[2];

                    if (commandName[0] != '!')
                    {
                        commandName = "!" + commandName;
                        return;
                    }

                    if (!Program.Settings.CheckIfCommandExist(commandName))
                    {
                        BasicCommand.AddBasicCommand(commandName, response);
                        client.SendWhisper(e.ChatMessage.Username, "Commande " + commandName + " est ajouté");
                    }
                }

                if (Program.Settings.CheckIfCommandExist(message))
                {
                    var command = Program.Settings.GetCommand(message);
                    if (command != null)
                    {
                        client.SendMessage(e.ChatMessage.Channel, command.response);
                    }
                }
            }
        }