Пример #1
0
 public static int GetBits(ParsedTwitchMessage msg)
 {
     if (msg.bits != "")
     {
         return(0);
     }
     else
     {
         int totalBits = 0;
         foreach (string str in msg.bits.Split(",".ToCharArray()))
         {
             totalBits += Convert.ToInt32(str);
         }
         return(totalBits);
     }
 }
Пример #2
0
        public static ParsedTwitchMessage ParseTwitchMessage(string msg)
        {
            ParsedTwitchMessage parsedMsg = new ParsedTwitchMessage();

            string separator    = ":";
            string tagSeparator = ";";

            string tags = msg.Split(separator.ToCharArray())[0];

            parsedMsg.user    = msg.Split(separator.ToCharArray())[1];
            parsedMsg.message = msg.Split(separator.ToCharArray())[2];

            foreach (string str in tags.Split(tagSeparator.ToCharArray()))
            {
                if (str.Contains("badge-info="))
                {
                    parsedMsg.badgeInfo = str.Replace("badge-info=", "");
                }
                else if (str.Contains("badges="))
                {
                    parsedMsg.badges = str.Replace("badges=", "");
                }
                else if (str.Contains("bits="))
                {
                    parsedMsg.bits = str.Replace("bits=", "");
                }
                else if (str.Contains("client-nonce="))
                {
                    parsedMsg.clientNonce = str.Replace("client-nonce=", "");
                }
                else if (str.Contains("color="))
                {
                    parsedMsg.color = str.Replace("color=", "");
                }
                else if (str.Contains("display-name="))
                {
                    parsedMsg.displayName = str.Replace("display-name=", "");
                }
                else if (str.Contains("emotes="))
                {
                    parsedMsg.emotes = str.Replace("emotes=", "");
                }
                else if (str.Contains("flags="))
                {
                    parsedMsg.flags = str.Replace("flags=", "");
                }
                else if (str.Substring(0, 3) == "id=")
                {
                    parsedMsg.id = str.Replace("id=", "");
                }
                else if (str.Contains("mod="))
                {
                    parsedMsg.mod = str.Replace("mod=", "");
                }
                else if (str.Contains("room-id="))
                {
                    parsedMsg.roomId = str.Replace("room-id=", "");
                }
                else if (str.Contains("tmi-sent-ts="))
                {
                    parsedMsg.tmiSentTs = str.Replace("tmi-sent-ts=", "");
                }
                else if (str.Contains("user-id="))
                {
                    parsedMsg.userId = str.Replace("user-id=", "");
                }
            }
            return(parsedMsg);
        }