Exemplo n.º 1
0
 private void Run(IInvokeSource source, ParsedCommand message)
 {
     this.RequireOwner();
     string key = message.GetTrail(0);
     this.RoomService.ChangeKey(key);
     source.Reply("Set key to {0}.", key);
 }
 public CommandExceptionEvent(IInvokeSource source, ParsedRequest request, CommandException exception)
 {
     this.Exception = exception;
     this.Source    = source;
     this.Request   = request;
     this.Handled   = exception.Ignored;
 }
Exemplo n.º 3
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireEdit();

            bool enabled;

            if (message.Count >= 1)
            {
                try
                {
                    enabled = Boolean.Parse(message.Args[0]);
                }
                catch (Exception ex)
                {
                    throw new CommandException("Unable to parse parameter: enabled", ex);
                }
            }
            else
            {
                enabled = !this.PlayerService.OwnPlayer.IsGod;
            }

            this.ActionService.GodMode(enabled);

            source.Reply("God mode was set to {0}.", enabled);
        }
Exemplo n.º 4
0
 private void RequireModerator(IInvokeSource source)
 {
     if (requireModerator)
     {
         Group.Moderator.RequireFor(source);
     }
 }
Exemplo n.º 5
0
        public void Invoke(IInvokeSource source, ParsedCommand message)
        {
            var e = new InvokeEvent(source, message);
            this.Events.Raise(e);

            if (!e.Handled && source.Group >= this.ResponseMinGroup)
                source.Reply(UnknownCommandStr);
        }
Exemplo n.º 6
0
        protected override void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();

            var name = message.GetTrail(0);
            this.RoomService.SetName(name);
            source.Reply("Name changed to: {0}", name);
        }
Exemplo n.º 7
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            Player player = this.PlayerService.MatchPlayer(message.Args[0]);

            this.Chatter.Unmute(player.Username);

            source.Reply("Unmuted {0}.", player.ChatName);
        }
Exemplo n.º 8
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            Player player = this.PlayerService.MatchPlayer(message.Args[0]);

            this.Chatter.ReportAbuse(player.Username, message.GetTrail(1));

            source.Reply("Reported {0}.", player.ChatName);
        }
Exemplo n.º 9
0
 public static void RequireFor(this PlayerInvokeOrigin origin, IInvokeSource source,
     string errorMessage = "Command is not available here.")
 {
     var playerSource = source as PlayerInvokeSource;
     if (playerSource != null)
     {
         if (playerSource.Origin != origin) throw new InvalidInvokeOriginCommandException(errorMessage);
     }
 }
Exemplo n.º 10
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();
            Player player = this.GetPlayerOrSelf(source, message);
            this.RequireSameRank(source, player);

            this.Chatter.ChatService.Kick(source.Name, player.Username,
                (message.Count > 1 ? message.GetTrail(1) : "Tsk tsk tsk"));
        }
Exemplo n.º 11
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();
            if (message.Count == 0 || message.Args[0] != "SAVE")
                throw new CommandException("To use save, type !save SAVE");

            this.RoomService.Save();
            source.Reply("Saved.");
        }
Exemplo n.º 12
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();

            if (message.Count == 0 || message.Args[0] != "CLEAR")
                throw new CommandException("To use clear, type !clear CLEAR");

            this.RoomService.Clear();
            source.Reply("Cleared level.");
        }
Exemplo n.º 13
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();
            Player player = this.GetPlayerOrSelf(source, message);
            this.RequireSameRank(source, player);

            this.Chatter.GiveEdit(player.Username);

            source.Reply("Gave edit to {0}.", player.ChatName);
        }
Exemplo n.º 14
0
 public static Group GetGroup(this IInvokeSource source)
 {
     try
     {
         return(source.ToPermissionInvokeSource().Group);
     }
     catch (InvalidInvokeSourceCommandException)
     {
         return(Group.External);
     }
 }
Exemplo n.º 15
0
 private void Run(IInvokeSource source, ParsedCommand message)
 {
     if (message.Count >= 2)
     {
         this.Ban(source, message.Args[0], message.GetTrail(1));
     }
     else
     {
         this.Ban(source, message.Args[0]);
     }
 }
Exemplo n.º 16
0
        protected override void Run(IInvokeSource source, ParsedCommand message)
        {
            string key = String.Empty;

            if (message.Count >= 1)
                key = message.GetTrail(0);

            this.RoomService.Access(key);

            source.Reply("Access sent.");
        }
        public static ConsoleInvokeSource ToConsoleInvokeSource(this IInvokeSource source,
                                                                string errorMessage = "This command is not available in game.")
        {
            var consoleSource = source as ConsoleInvokeSource;

            if (consoleSource == null)
            {
                throw new InvalidInvokeSourceCommandException(errorMessage);
            }

            return(consoleSource);
        }
        public static PlayerInvokeSource ToPlayerInvokeSource(this IInvokeSource source,
                                                              string errorMessage = "You must call this command as a player.")
        {
            var playerSource = source as PlayerInvokeSource;

            if (playerSource == null)
            {
                throw new InvalidInvokeSourceCommandException(errorMessage);
            }

            return(playerSource);
        }
Exemplo n.º 19
0
        public static void RequireFor(this PlayerInvokeOrigin origin, IInvokeSource source,
                                      string errorMessage = "Command is not available here.")
        {
            var playerSource = source as PlayerInvokeSource;

            if (playerSource != null)
            {
                if (playerSource.Origin != origin)
                {
                    throw new InvalidInvokeOriginCommandException(errorMessage);
                }
            }
        }
Exemplo n.º 20
0
        private void OffCommand(IInvokeSource source, ParsedRequest request)
        {
            RequireModerator(source);

            if (!roundsManager.Enabled)
            {
                source.Reply("Bot is already disabled.");
            }
            else
            {
                source.Reply("Disabling bot...");
                roundsManager.Enabled = false;
            }
        }
Exemplo n.º 21
0
        private void StopCommand(IInvokeSource source, ParsedRequest request)
        {
            RequireModerator(source);

            if (!roundsManager.Enabled)
            {
                source.Reply("Bot is not enabled!");
            }
            else
            {
                source.Reply("Stopping round...");
                roundsManager.ForceStop();
            }
        }
Exemplo n.º 22
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();

            bool isVisible;
            try
            {
                isVisible = Boolean.Parse(message.Args[0]);
            }
            catch (Exception ex)
            {
                throw new CommandException("Unable to parse parameter: isVisible", ex);
            }
            this.Chatter.ChangeVisibility(isVisible);
            source.Reply("Changed visibility to {0}.", isVisible);
        }
Exemplo n.º 23
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            Smiley smiley;
            try
            {
                smiley = (Smiley)Enum.Parse(typeof(Smiley), message.Args[0], true);
            }
            catch (Exception ex)
            {
                throw new CommandException("Unable to parse parameter: smiley", ex);
            }

            this.ActionService.ChangeFace(smiley);

            source.Reply("Smiley set to {0}.", smiley);
        }
Exemplo n.º 24
0
        protected override void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();

            bool isAllowed;
            try
            {
                isAllowed = Boolean.Parse(message.Args[0]);
            }
            catch (Exception ex)
            {
                throw new CommandException("Unable to parse parameter: isAllowed", ex);
            }
            this.RoomService.SetAllowPotions(isAllowed);
            source.Reply("Potions enabled: {0}.", isAllowed);
        }
Exemplo n.º 25
0
        protected override void Run(IInvokeSource source, ParsedCommand message)
        {
            this.RequireOwner();
            Player player = this.PlayerService.MatchPlayer(message.Args[0]);
            this.RequireSameRank(source, player);

            if (message.Count >= 3)
            {
                int x = message.GetInt(1);
                int y = message.GetInt(2);

                this.Chatter.Teleport(player.Username, x, y);
            }
            else if (message.Count == 2)
            {
                try
                {
                    Player target = this.PlayerService.MatchPlayer(message.Args[1]);
                    this.Chatter.Teleport(player.Username, target.BlockX, target.BlockY);
                }
                catch (CommandException ex)
                {
                    throw new CommandException(ex.Message + " Parameter: target", ex);
                }
            }
            else
            {
                var playerSource = source as PlayerInvokeSource;
                if (playerSource != null)
                {
                    int x = playerSource.Player.BlockX;
                    int y = playerSource.Player.BlockX;

                    this.Chatter.Teleport(player.Username, x, y);
                }
                else
                {
                    this.Chatter.Teleport(player.Username);
                }
            }

            source.Reply("Teleported {0}.", player.ChatName);
        }
Exemplo n.º 26
0
        public static IPermissionInvokeSource ToPermissionInvokeSource(this IInvokeSource source)
        {
            var permissionSource = source as IPermissionInvokeSource;

            if (permissionSource != null)
            {
                return(permissionSource);
            }

            var pSource = source as PlayerInvokeSource;

            if (pSource != null)
            {
                return(new PlayerPermissionInvokeSourceAdapter(pSource));
            }

            throw new InvalidInvokeSourceCommandException(
                      "Unable to retrieve your permissions. Command could not be run.");
        }
Exemplo n.º 27
0
 protected override void Run(IInvokeSource source, ParsedCommand message)
 {
     if (message.Count >= 1)
     {
         string user = message.Args[0];
         this.PlayerService.MatchPlayer(user,
             player =>
                 source.Reply("{0}'s rank is {1}", player.ChatName, player.GetGroup()),
             username =>
                 source.Reply("{0} is now {1}.", PlayerUtils.GetChatName(username),
                     this.Host.GetPermission(PlayerUtils.GetStorageName(username))));
     }
     var playerSource = source as PlayerInvokeSource;
     if (playerSource != null)
     {
         source.Reply("{0}'s rank is {1}", playerSource.Player.ChatName, playerSource.Player.GetGroup());
     }
     else
     {
         throw new UnknownPlayerCommandException("No player was specified!");
     }
 }
Exemplo n.º 28
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            DateTime timeout;
            try
            {
                TimeSpan duration = TimeSpan.Parse(message.Args[1]);
                timeout = DateTime.UtcNow.Add(duration);
            }
            catch (Exception ex)
            {
                throw new CommandException("Unable to parse parameter: duration", ex);
            }

            if (message.Count >= 3)
            {
                this.Ban(source, message.Args[0], timeout, message.GetTrail(2));
            }
            else
            {
                this.Ban(source, message.Args[0], timeout);
            }
        }
Exemplo n.º 29
0
        protected override void Run(IInvokeSource source, ParsedCommand message)
        {
            Potion pot;
            try
            {
                pot = (Potion)Enum.Parse(typeof(Potion), message.Args[0], true);
            }
            catch (Exception ex)
            {
                throw new CommandException("Unable to parse parameter: potion", ex);
            }

            try
            {
                this.PotionService.UsePotion(pot);
            }
            catch (InvalidOperationException ex)
            {
                throw new CommandException("Unable to use potion: " + ex.Message, ex);
            }

            source.Reply("Potion {0} used.", pot);
        }
Exemplo n.º 30
0
        protected override void Run(IInvokeSource source, ParsedCommand message)
        {
            bool enabled;

            if (message.Count >= 1)
            {
                try
                {
                    enabled = Boolean.Parse(message.Args[0]);
                }
                catch (Exception ex)
                {
                    throw new CommandException("Unable to parse parameter: enabled", ex);
                }
            }
            else
            {
                enabled = !this.PlayerService.OwnPlayer.IsGuardian;
            }

            this.ActionService.GuardianMode(enabled);

            source.Reply("Guardian mode was set to {0}.", enabled);
        }
Exemplo n.º 31
0
 protected override void Run(IInvokeSource source, ParsedCommand message)
 {
     this.RequireOwner();
     this.Chatter.Reset();
     source.Reply("Level reset.");
 }
 public static void Reply(this IInvokeSource invokeSource, string message, params object[] args)
 {
     // ReSharper disable once RedundantStringFormatCall
     invokeSource.Reply(string.Format(message, args));
 }
Exemplo n.º 33
0
 private void Run(IInvokeSource source, ParsedCommand message)
 {
     this.RunPermissionCommand(source, message, Group.Moderator);
 }
Exemplo n.º 34
0
 private void Run(IInvokeSource source, ParsedCommand message)
 {
     this.ActionService.GetCrown();
     source.Reply("Got crown.");
 }
Exemplo n.º 35
0
        private void Run(IInvokeSource source, ParsedCommand message)
        {
            source.Reply("Restarting...");

            this.HostService.Restart();
        }
Exemplo n.º 36
0
 private void Run(IInvokeSource source, ParsedCommand message)
 {
     this.KeyService.PressKey(Key.Blue);
     source.Reply("Pressed blue key.");
 }
Exemplo n.º 37
0
 void HiCommand(IInvokeSource source, ParsedRequest request)
 {
     source.Reply("Hello");
 }
Exemplo n.º 38
0
        private static void HiCommand(IInvokeSource source, ParsedRequest request)
        {
            var player = source.ToPlayerInvokeSource().Player;

            source.Reply("Hello world {0}!", player.Username);
        }
Exemplo n.º 39
0
 protected override void Run(IInvokeSource source, ParsedCommand message)
 {
     this.RunPermissionCommand(source, message, Group.Operator);
 }
Exemplo n.º 40
0
 public CommandEvent(IInvokeSource source, ParsedRequest request)
 {
     this.Source  = source;
     this.Request = request;
 }
Exemplo n.º 41
0
 private void Run(IInvokeSource source, ParsedCommand message)
 {
     if (this.PlayerService.OwnPlayer.HasSilverCrown)
         throw new CommandException("Bot already has crown!");
     this.ActionService.CompleteLevel();
 }
Exemplo n.º 42
0
 protected override void Run(IInvokeSource source, ParsedCommand message)
 {
     this.KeyService.PressKey(Key.Green);
     source.Reply("Pressed green key.");
 }
Exemplo n.º 43
0
 void HiCommand(IInvokeSource source, ParsedRequest request)
 {
     source.Reply("Hello");
 }