minor updates to IRC

This commit is contained in:
Cameron
2024-04-02 18:19:35 -05:00
parent 4806e50736
commit 19e71a5afd
2 changed files with 21 additions and 1 deletions

View File

@@ -13,7 +13,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
using TwitchIrcClient.IRC.Messages; using TwitchIrcClient.IRC.Messages;
using TwitchIrcClient.IRC.Messages;
namespace TwitchIrcClient.IRC namespace TwitchIrcClient.IRC
{ {

View File

@@ -14,6 +14,27 @@ namespace TwitchIrcClient.IRC.Messages
/// </summary> /// </summary>
public class Privmsg : ReceivedMessage public class Privmsg : ReceivedMessage
{ {
/// <summary>
/// Contains metadata related to the chat badges in the badges tag.
/// According to Twitch's documentation this should only include info about
/// subscription length, but it also contains prediction info and who knows what else.
/// </summary>
public IEnumerable<string> BadgeInfo => TryGetTag("badge-info").Split(',');
/// <summary>
/// Contains the total number of months the user has subscribed, even if they aren't
/// subscribed currently.
/// </summary>
public int SubscriptionLength
{ get
{
//TODO redo this, functional style clearly didn't work here
if (int.TryParse((BadgeInfo.FirstOrDefault(
b => b.StartsWith("SUBSCRIBER", StringComparison.CurrentCultureIgnoreCase)) ?? "")
.Split("/", 2).ElementAtOrDefault(1) ?? "", out int value))
return value;
return 0;
}
}
/// <summary> /// <summary>
/// List of chat badges. Most badges have only 1 version, but some badges like /// List of chat badges. Most badges have only 1 version, but some badges like
/// subscriber badges offer different versions of the badge depending on how /// subscriber badges offer different versions of the badge depending on how