private void ProcessCommand(ChatMessageEventArgs e, string contents) { string[] commandParts = contents.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string command = null; string[] parameters = new string[commandParts.Length - 1]; if (commandParts.Length > 0) { command = commandParts[0]; } if (commandParts.Length > 1) { Array.Copy(commandParts, 1, parameters, 0, parameters.Length); } IJinxBotPrincipal commander = m_client.Database.FindUsers(e.Username).FirstOrDefault(); if (commander != null) { foreach (ICommandHandler handler in m_client.CommandHandlers) { if (handler.HandleCommand(commander, command, parameters)) { break; } } } }
public bool HandleCommand(IJinxBotPrincipal commander, string command, string[] parameters) { // TODO: Fix the ability to determine if I am the owner (that is, if I'm commanding myself) if (commander.Username.Equals(m_bnet.UniqueUsername, StringComparison.OrdinalIgnoreCase) || commander.IsInRole("O")) { switch (command.ToUpper()) { case "FIND": if (parameters.Length == 1) { Find(parameters[0]); return true; } return false; case "ADDROLE": if (parameters.Length == 2) { AddRole(parameters); return true; } return false; case "REMROLE": if (parameters.Length == 2) { RemoveRole(parameters); return true; } return false; default: return false; } } return false; }
public void AddUserToRole(IJinxBotPrincipal user, string role) { User u = user as User; if (u == null) throw new InvalidCastException("Attempted to use a user from a different provider; expected JinxBot.Plugins.Data.XmlDatabase.User"); u.AddRole(role); }
public IEnumerable<string> GetCommandHelp(IJinxBotPrincipal commander) { if (commander.Username.Equals(m_bnet.UniqueUsername, StringComparison.OrdinalIgnoreCase) || commander.IsInRole("O")) { yield return "addrole <user|meta> <role> - Adds the specified role to a user or meta"; yield return "delrole <user|meta> <role> - Removes the specified role from a user or meta"; yield return "find <user> - Finds the most recent occurrance of <user>."; } }
public void RemoveRoleFromUser(IJinxBotPrincipal user, string role) { }
public void AddUserToRole(IJinxBotPrincipal user, string role) { }