Just to wrap this up if anyone stumbles on this thread in the future trying to get /vips and /mods from chat, here’s what I ended up with to process the output.
Here line is the string that came back from streamReader.ReadLineAsync. There are two List<string> objects: vips and mods that get populated with the data from the NOTICEs.
string[] split = line.Split(' ');
//PING :tmi.twitch.tv
//Respond with PONG :tmi.twitch.tv
if (line.StartsWith("PING"))
{
await TryWriteLineAsync($"PONG {split[1]}");
}
else if (split.Length > 2 && split[1] == "NOTICE")
{
//:tmi.twitch.tv NOTICE #robertsmania :The moderators of this channel are: mod1, mod2, mod3, ... modX
//:tmi.twitch.tv NOTICE #robertsmania :The VIPs of this channel are: vip1, vip2, vip3, .. vipX.
// ^^^^^^^^
//Grab the channel name here
int secondColonPosition = line.IndexOf(':', 1);//the 1 here is what skips the first character
string message = line.Substring(secondColonPosition + 1);//Everything past the second colon
string channel = split[2].TrimStart('#');
if (message.StartsWith("The VIPs of this channel are:"))
{
int thirdColonPosition = line.IndexOf(':', secondColonPosition + 1);
string vipStr = line.Substring(thirdColonPosition + 2); //2 skips the space after the colon, should be list of VIPs
vipStr = vipStr.TrimEnd('.'); //VIPs do apper to have a period?
vips = vipStr.Split(new string[] {", "}, StringSplitOptions.None).ToList();
}
else if (message.StartsWith("The moderators of this channel are:"))
{
int thirdColonPosition = line.IndexOf(':', secondColonPosition + 1);
string modsStr = line.Substring(thirdColonPosition + 2); //2 skips the space afte rthe colon, should be list of mods
modsStr = modsStr.TrimEnd('.'); //mods doesnt look like it has a period?
mods = modsStr.Split(new string[] {", "}, StringSplitOptions.None).ToList();
}
} ...
And then goes on to process other types of messages.