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; }
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); }
private void RequireModerator(IInvokeSource source) { if (requireModerator) { Group.Moderator.RequireFor(source); } }
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); }
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); }
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); }
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); }
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); } }
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")); }
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."); }
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."); }
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); }
public static Group GetGroup(this IInvokeSource source) { try { return(source.ToPermissionInvokeSource().Group); } catch (InvalidInvokeSourceCommandException) { return(Group.External); } }
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]); } }
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); }
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); } } }
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; } }
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(); } }
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); }
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); }
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); }
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); }
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."); }
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!"); } }
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); } }
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); }
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); }
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)); }
private void Run(IInvokeSource source, ParsedCommand message) { this.RunPermissionCommand(source, message, Group.Moderator); }
private void Run(IInvokeSource source, ParsedCommand message) { this.ActionService.GetCrown(); source.Reply("Got crown."); }
private void Run(IInvokeSource source, ParsedCommand message) { source.Reply("Restarting..."); this.HostService.Restart(); }
private void Run(IInvokeSource source, ParsedCommand message) { this.KeyService.PressKey(Key.Blue); source.Reply("Pressed blue key."); }
void HiCommand(IInvokeSource source, ParsedRequest request) { source.Reply("Hello"); }
private static void HiCommand(IInvokeSource source, ParsedRequest request) { var player = source.ToPlayerInvokeSource().Player; source.Reply("Hello world {0}!", player.Username); }
protected override void Run(IInvokeSource source, ParsedCommand message) { this.RunPermissionCommand(source, message, Group.Operator); }
public CommandEvent(IInvokeSource source, ParsedRequest request) { this.Source = source; this.Request = request; }
private void Run(IInvokeSource source, ParsedCommand message) { if (this.PlayerService.OwnPlayer.HasSilverCrown) throw new CommandException("Bot already has crown!"); this.ActionService.CompleteLevel(); }
protected override void Run(IInvokeSource source, ParsedCommand message) { this.KeyService.PressKey(Key.Green); source.Reply("Pressed green key."); }