Example #1
0
        public static string GetWidgetUrl(ulong id, WidgetImageFormat format = WidgetImageFormat.Svg,
                                          int?topColor  = null, int?middleColor = null, int?usernameColor  = null, int?certifiedColor = null,
                                          int?dataColor = null, int?labelColor  = null, int?highlightColor = null)
        {
            string url = GetBaseWidgetUrl(id, format);

            var args = new List <string>();

            if (topColor != null)
            {
                args.Add($"topcolor={topColor.Value:X}");
            }

            if (middleColor != null)
            {
                args.Add($"middlecolor={middleColor.Value:X}");
            }

            if (usernameColor != null)
            {
                args.Add($"usernamecolor={usernameColor.Value:X}");
            }

            if (certifiedColor != null)
            {
                args.Add($"certifiedcolor={certifiedColor.Value:X}");
            }

            if (dataColor != null)
            {
                args.Add($"datacolor={dataColor.Value:X}");
            }

            if (labelColor != null)
            {
                args.Add($"labelcolor={labelColor.Value:X}");
            }

            if (highlightColor != null)
            {
                args.Add($"highlightcolor={highlightColor.Value:X}");
            }

            return(CreateQuery(url, args));
        }
Example #2
0
        public static string GetWidgetUrl(ulong id, SmallWidgetType type, WidgetImageFormat format = WidgetImageFormat.Svg, int?avatarBackgroundColor = null,
                                          int?leftColor = null, int?rightColor = null, int?leftTextColor = null, int?rightTextColor = null, bool useAvatar = true)
        {
            string url = GetBaseWidgetUrl(id, format, type);

            var args = new List <string>();

            if (!useAvatar)
            {
                args.Add($"noavatar=true");
            }

            if (avatarBackgroundColor != null)
            {
                args.Add($"avatarbg={avatarBackgroundColor.Value:X}");
            }

            if (leftColor != null)
            {
                args.Add($"leftcolor={leftColor.Value:X}");
            }

            if (rightColor != null)
            {
                args.Add($"rightcolor={rightColor.Value:X}");
            }

            if (leftTextColor != null)
            {
                args.Add($"lefttextcolor={leftTextColor.Value:X}");
            }

            if (rightTextColor != null)
            {
                args.Add($"righttextcolor={rightTextColor.Value:X}");
            }

            return(CreateQuery(url, args));
        }
 /// <summary>
 /// Returns a string that represents the image URL of an <see cref="IDblWidget"/>.
 /// </summary>
 /// <param name="id">The unique identifier of the bot to build a widget for.</param>
 /// <param name="format">The image format that this <see cref="IDblWidget"/> will be built for.</param>
 /// <returns>An image URL representing a widget.</returns>
 public string ToString(ulong id, WidgetImageFormat format = WidgetImageFormat.Svg)
 => DblApi.GetWidgetUrl(id, Type, format, AvatarBackgroundColor,
                        LeftColor, RightColor, LeftTextColor, RightTextColor, UseAvatar ?? true);
 /// <summary>
 /// Builds a new <see cref="IDblWidget"/> from this <see cref="SmallWidgetBuilder"/>.
 /// </summary>
 /// <param name="id">The unique identifier of the bot to build a widget for.</param>
 /// <param name="format">The image format that this <see cref="IDblWidget"/> will be built for.</param>
 /// <returns>A generic <see cref="IDblWidget"/> object.</returns>
 public IDblWidget Build(ulong id, WidgetImageFormat format = WidgetImageFormat.Svg)
 => new DblWidget(id, format, this);
 /// <summary>
 /// Returns a string that represents the image URL of an <see cref="IDblWidget"/>.
 /// </summary>
 /// <param name="id">The unique identifier of the bot to build a widget for.</param>
 /// <param name="format">The image format that this <see cref="IDblWidget"/> will be built for.</param>
 /// <returns>An image URL representing a widget.</returns>
 public string ToString(ulong id, WidgetImageFormat format = WidgetImageFormat.Svg)
 => DblApi.GetWidgetUrl(id, format, TopColor, MiddleColor,
                        UsernameColor, CertifiedColor, DataColor, LabelColor, HighlightColor);
Example #6
0
 internal DblWidget(ulong id, WidgetImageFormat format, SmallWidgetBuilder builder)
     : this(id, format)
 {
     Size     = WidgetSize.Small;
     ImageUrl = builder.ToString(id, format);
 }
Example #7
0
 private DblWidget(ulong id, WidgetImageFormat format)
 {
     UserId = id;
     Format = format;
 }
Example #8
0
 public string GetWidgetUrl(ulong botId, WidgetImageFormat imageFormat = WidgetImageFormat.Svg)
 {
     return($"{Api.GetBaseUrl()}/widget/{botId}?type={imageFormat.ToString().ToLower()}");
 }
Example #9
0
 public string GetWidgetUrl(WidgetImageFormat imageFormat = WidgetImageFormat.Svg)
 {
     return(GetWidgetUrl(BotId, imageFormat));
 }
Example #10
0
 internal static string GetWidgetUrl(ulong id, WidgetImageFormat format, LargeWidgetBuilder builder)
 {
     return(SetQueryParams(GetBaseWidgetUrl(id, format), builder));
 }