Exemplo n.º 1
0
        public TwitchWhisperMessage(IrcMessage message)
        {
            foreach (KeyValuePair <string, string> tag in message.Tags)
            {
                switch (tag.Key)
                {
                case "badges":
                    Badges = ParseBadges(tag.Value);
                    break;

                case "color":
                    UserColor = tag.Value;
                    break;

                case "display-name":
                    DisplayName = tag.Value;
                    break;

                case "emotes":
                    Emotes = tag.Value;
                    break;

                case "message-id":
                    MessageId = tag.Value;
                    break;

                case "thread-id":
                    ThreadId = tag.Value;
                    break;

                case "turbo":
                    IsTurbo = tag.Value.Equals("1");
                    break;

                case "user-id":
                    UserId = tag.Value;
                    break;

                case "user-type":
                    UserType = ConvertToUserType(tag.Value);
                    break;
                }
            }

            UserName = message.GetUserName();
            Body     = message.GetParameterByIndex(1);
        }
Exemplo n.º 2
0
        public TwitchChatMessage(IrcMessage message)
        {
            foreach (KeyValuePair <string, string> tag in message.Tags)
            {
                switch (tag.Key)
                {
                case "badges":
                    Badges = ParseBadges(tag.Value);
                    break;

                case "bits":
                    Bits = int.Parse(tag.Value);
                    break;

                case "color":
                    UserColor = tag.Value;
                    break;

                case "display-name":
                    DisplayName = tag.Value;
                    break;

                case "emotes":
                    Emotes = tag.Value;
                    break;

                case "emote-only":
                    IsEmotesOnly = tag.Value.Equals("1");
                    break;

                case "id":
                    MessageId = tag.Value;
                    break;

                case "mod":
                    IsModerator = tag.Value.Equals("1");
                    break;

                case "room-id":
                    ChannelId = tag.Value;
                    break;

                case "subscriber":
                    IsSubscriber = tag.Value.Equals("1");
                    break;

                case "tmi-sent-ts":
                    Timestamp = long.Parse(tag.Value);
                    break;

                case "turbo":
                    IsTurbo = tag.Value.Equals("1");
                    break;

                case "user-id":
                    UserId = tag.Value;
                    break;

                case "user-type":
                    UserType = ConvertToUserType(tag.Value);
                    break;
                }
            }

            UserName = message.GetUserName();
            Channel  = message.GetChannel();

            string messageBody = message.GetParameterByIndex(1);
            Match  actionMatch = Regex.Match(messageBody, @"\u0001ACTION\s(.+)\u0001");

            if (actionMatch.Success)
            {
                Body     = actionMatch.Groups[1].Value;
                IsAction = true;
            }
            else
            {
                Body = messageBody;
            }
        }