TwitchChat/TwitchChatMember.cs
using System.Collections.Generic;
using System.Linq;
namespace TwitchAPI;
public class TwitchChatUser
{
static string[] DefaultColors = new string[] { "#FF0000", "#0000FF", "#008000", "#B22222", "#FF7F50", "#9ACD32", "#FF4500", "#2E8B57", "#DAA520", "#D2691E", "#5F9EA0", "#1E90FF", "#FF69B4", "#8A2BE2", "#00FF7F" };
/// <summary>
/// The ID of the user.
/// </summary>
public int Id { get; internal set; } = -1;
/// <summary>
/// The user's display name.
/// </summary>
public string Name { get; internal set; }
/// <summary>
/// A list of badges the user has.
/// </summary>
public List<TwitchChatBadge> Badges { get; internal set; } = new();
/// <summary>
/// Whether the user is subscribed to the channel.
/// </summary>
public bool IsSubscribed { get; internal set; } = false;
/// <summary>
/// Whether the user is a moderator of the channel.
/// </summary>
public bool IsModerator { get; internal set; } = false;
/// <summary>
/// Whether the user is a returning chatter to the channel.
/// </summary>
public bool IsReturningChatter { get; internal set; } = false;
/// <summary>
/// Whether or not the user is a Twitch Turbo member.
/// </summary>
public bool IsTurbo { get; internal set; } = false;
/// <summary>
/// Whether or not the user is a Twitch Prime member.
/// </summary>
public bool IsPrimeMember { get; internal set; } = false;
/// <summary>
/// How many months the user has been subscribed to the channel.
/// </summary>
public int MonthsSubscribed { get; internal set; } = 0;
/// <summary>
/// The color of the user's name in chat.
/// </summary>
public Color Color { get; internal set; } = Color.White;
public TwitchChatUser( string name )
{
Name = name;
var random = new System.Random( Name.GetHashCode() );
Color = Color.Parse( DefaultColors.ElementAt( random.Next( 0, DefaultColors.Length ) ) ) ?? Color.White;
}
/// <summary>
/// Returns the URL of the user's avatar.
/// </summary>
/// <returns></returns>
public string GetAvatarUrl()
{
return $"https://cdn.frankerfacez.com/avatar/twitch/{Id}";
}
public override string ToString()
{
return $"{Name}";
}
}