Пример #1
0
        public string ParseCommand(Func<MessageSource> sender, string message)
        {
            int firstSpace = message.IndexOf(' ');

            CommandArgs args;

            if (firstSpace == -1)
            {
                // TODO: Revisit this new string[0] thing; preferrably should pass null or something
                args = new CommandArgs(message, new string[0], String.Empty);
            }
            else
            {
                string full = message.Substring(firstSpace + 1).Trim();
                args = new CommandArgs(message.Substring(0, firstSpace), full.Split(), full);
            }

            ICommand command;

            if (_commands.TryGetValue(args.Name, out command))
            {
                return command.Parse(sender(), args);
            }

            return null;
        }
Пример #2
0
        public string Parse(MessageSource source, CommandArgs args)
        {
            string hostname = source.Hostname;

            if(args.Args.Count == 2 && source.Permission.IsSuperOperator)
            {
                hostname = args.Args[1];
            }else if(args.Args.Count != 1)
            {
                return "Usage - " + args.Name + " <nickname>";
            }

            return _settings.SetUserPermissionNick(hostname, args.Args[0]) ? "Changed nick to " + args.Args[0] : "You don't seem to have a permission set";
        }