Beispiel #1
0
        public void Handle(object sender, EditOperationRequestEventArgs e)
        {
            string        message = string.Empty;
            CustomCommand cc      = FetchFromSet(e.RequestName, customCommandRepository.GetAll());

            if (DeleteCommand(cc))
            {
                int      cooldown = e.isCooldownDefault ? cc.Cooldown : e.GetCooldown();
                string[] users    = e.isPermittedUsersDefault ? cc.PermittedUsers.ToArray() :
                                    e.GetPermittedUsers();

                CustomCommand toAdd = customCommandFactory.Create(e.RequestName,
                                                                  e.RequestValue, e.GetCooldown(), e.GetPermittedUsers());

                if (AddCommand(toAdd))
                {
                    message = string.Format("!{0} command has been updated!", e.RequestName);
                }
                else if (AddCommand(cc))
                {
                    message = string.Format("!{0} command has NOT been updated, please " +
                                            "the edit operation syntax for errors.",
                                            e.RequestName);
                }
                else
                {
                    message = string.Format("!{0} has been corrupted during updating, " +
                                            "please using the add operation to make this command.");
                }
            }
            else
            {
                message = "Unable to change the command at this time!";
            }

            client.SendMessage(message);
        }
Beispiel #2
0
        public void Handle(object sender, DeleteOperationRequestEventArgs e)
        {
            CustomCommand command = FetchFromSet(e.RequestName,
                                                 customCommandRepository.GetAll());

            string message = string.Empty;

            if (DeleteCommand(command))
            {
                message = string.Format("!{0} command has been deleted!", command.Name);
            }

            if (!string.IsNullOrEmpty(message))
            {
                if (e.IsWhisper)
                {
                    client.Whisper(e.User, message);
                }
                else
                {
                    client.SendMessage(message);
                }
            }
        }
Beispiel #3
0
 public void Save(CustomCommand cc)
 {
     commands.Add(cc);
 }