コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
ファイル: JinxMod.cs プロジェクト: Mofsy/jinxbot-plugins
        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;
        }
コード例 #3
0
ファイル: XmlDatabase.cs プロジェクト: Mofsy/jinxbot-plugins
        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);
        }
コード例 #4
0
ファイル: JinxMod.cs プロジェクト: Mofsy/jinxbot-plugins
 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>.";
     }
 }
コード例 #5
0
 public void RemoveRoleFromUser(IJinxBotPrincipal user, string role)
 {
     
 }
コード例 #6
0
 public void AddUserToRole(IJinxBotPrincipal user, string role)
 {
     
 }
コード例 #7
0
 public void RemoveRoleFromUser(IJinxBotPrincipal user, string role)
 {
 }
コード例 #8
0
 public void AddUserToRole(IJinxBotPrincipal user, string role)
 {
 }