예제 #1
0
        /// <summary>
        /// 检查头像是否存在
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="size"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool AvatarCheck(int uid, AvatarSize size = AvatarSize.Middle, AvatarType type = AvatarType.Virtual)
        {
            var args = new Dictionary <string, string>
            {
                { "uid", uid.ToString() },
                { "size", size.ToString().ToLower() },
                { "type", type.ToString().ToLower() },
                { "check_file_exists", "1" }
            };

            return(toBool(SendGet(UcConfig.UcApi + "avatar.php", args)));
        }
예제 #2
0
파일: Avatars.cs 프로젝트: xiongeee/BBX
        /// <summary>获取用户头像URL,根据AvatarStatic配置可能是动态或者静态</summary>
        /// <param name="uid"></param>
        /// <param name="avatarSize"></param>
        /// <returns></returns>
        public static String GetAvatarUrl(int uid, AvatarSize avatarSize = AvatarSize.Medium)
        {
            var config = GeneralConfigInfo.Current;

            if (config.AvatarStatic)
            {
                return(GetStaticUrl(uid.ToString(), avatarSize));
            }

            var root = Utils.GetRootUrl(BaseConfigs.GetForumPath);

            if (!config.ImageServer.IsNullOrEmpty())
            {
                root = config.ImageServer.EnsureEnd("/");
            }

            return(String.Format("{0}tools/avatar.aspx?uid={1}&size={2}", root, uid, avatarSize.ToString().ToLower()));
        }
예제 #3
0
        /// <summary>
        /// Gets a URL that can be used to download the user's avatar. If the user has not yet set their avatar, it will return the default one that discord is using. The default avatar only supports the <see cref="AvatarFormat.PNG"/> format.
        /// </summary>
        /// <param name="format">The format of the target avatar</param>
        /// <param name="size">The optional size of the avatar you wish for. Defaults to x128.</param>
        /// <returns></returns>
        public string GetAvatarURL(AvatarFormat format, AvatarSize size = AvatarSize.x128)
        {
            //Prepare the endpoint
            string endpoint = "/avatars/" + ID + "/" + Avatar;

            //The user has no avatar, so we better replace it with the default
            if (string.IsNullOrEmpty(Avatar))
            {
                //Make sure we are only using PNG
                if (format != AvatarFormat.PNG)
                {
                    throw new BadImageFormatException("The user has no avatar and the requested format " + format.ToString() + " is not supported. (Only supports PNG).");
                }

                //Get the endpoint
                int descrim = Discriminator % 5;
                endpoint = "/embed/avatars/" + descrim;
            }

            //Finish of the endpoint
            string s = size.ToString().Trim('x');

            return("https://" + CdnEndpoint + endpoint + GetAvatarExtension(format) + "?size=" + s);
        }
예제 #4
0
 /// <summary>
 /// 获取头像物理路径
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public static string GetPhysicsAvatarPath(string uid, AvatarSize size)
 {
     return Utils.GetMapPath(forumPath + "avatars/" +
         string.Format(AVATAR_URL, uid.Substring(0, 3), uid.Substring(3, 2), uid.Substring(5, 2), uid.Substring(7, 2), size.ToString().ToLower()));
 }
예제 #5
0
 /// <summary>
 /// 获取默认头像
 /// </summary>
 /// <param name="avatarSize"></param>
 /// <returns></returns>
 public static string GetDefaultAvatarUrl(AvatarSize avatarSize)
 {
     return Utils.GetRootUrl(forumPath) + "images/common/noavatar_" + avatarSize.ToString().ToLower() + ".gif";
 }
예제 #6
0
 /// <summary>
 /// 获取默认头像
 /// </summary>
 /// <param name="avatarSize"></param>
 /// <returns></returns>
 public static string GetDefaultAvatarUrl(AvatarSize avatarSize)
 {
     return(Utils.GetRootUrl(forumPath) + "images/common/noavatar_" + avatarSize.ToString().ToLower() + ".gif");
 }
예제 #7
0
 /// <summary>
 /// 获取头像物理路径
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public static string GetPhysicsAvatarPath(string uid, AvatarSize size)
 {
     return(Utils.GetMapPath(forumPath + "avatars/" +
                             string.Format(AVATAR_URL, uid.Substring(0, 3), uid.Substring(3, 2), uid.Substring(5, 2), uid.Substring(7, 2), size.ToString().ToLower())));
 }
예제 #8
0
 /// <summary>
 /// 得到头像地址
 /// </summary>
 /// <param name="uid">Uid</param>
 /// <param name="size">大小</param>
 /// <param name="type">类型</param>
 /// <returns></returns>
 public string AvatarUrl(int uid, AvatarSize size, AvatarType type = AvatarType.Virtual)
 {
     return(string.Format("{0}avatar.php?uid={1}&type={2}&size={3}", UcConfig.UcApi, uid,
                          type.ToString().ToLower(), size.ToString().ToLower()));
 }
예제 #9
0
 /// <summary>
 /// 检查头像是否存在
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="size"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool AvatarCheck(decimal uid, AvatarSize size = AvatarSize.Middle, AvatarType type = AvatarType.Virtual)
 {
     var args = new Dictionary<string, string>
                    {
                        {"uid", uid.ToString()},
                        {"size", size.ToString().ToLower()},
                        {"type", type.ToString().ToLower()},
                        {"check_file_exists", "1"}
                    };
     return toBool(SendGet(UcConfig.UcApi + "avatar.php", args));
 }
예제 #10
0
 /// <summary>
 /// 得到头像地址
 /// </summary>
 /// <param name="uid">Uid</param>
 /// <param name="size">大小</param>
 /// <param name="type">类型</param>
 /// <returns></returns>
 public string AvatarUrl(decimal uid, AvatarSize size, AvatarType type = AvatarType.Virtual)
 {
     return string.Format("{0}avatar.php?uid={1}&type={2}&size={3}", UcConfig.UcApi, uid,
                          type.ToString().ToLower(), size.ToString().ToLower());
 }
예제 #11
0
파일: Avatars.cs 프로젝트: xiongeee/BBX
 static String GetDefault(AvatarSize avatarSize = AvatarSize.Medium)
 {
     return(Utils.GetMapPath(forumPath.CombinePath("avatars/avatar_" + avatarSize.ToString().ToLower() + ".jpg")));
 }
예제 #12
0
파일: Avatars.cs 프로젝트: xiongeee/BBX
 public static String GetPhysicsAvatarPath(String uid, AvatarSize size)
 {
     return(Utils.GetMapPath(forumPath + FormatPathPrefix(uid) + size.ToString().ToLower() + ".jpg"));
 }