Exemplo n.º 1
0
        public TwitchUserTimeout(IrcMessage message)
        {
            foreach (KeyValuePair <string, string> tag in message.Tags)
            {
                switch (tag.Key)
                {
                case "ban-duration":
                    TimeoutDuration = int.Parse(tag.Value);
                    break;

                case "ban-reason":
                    TimeoutReason = tag.Value;
                    break;

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

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

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

            Channel        = message.GetChannel();
            TargetUserName = message.GetParameterByIndex(1);
        }
Exemplo n.º 2
0
        public ChannelMode(IrcMessage message)
        {
            string modesWithAction = message.GetParameterByIndex(1);
            Match  modesMatch      = Regex.Match(modesWithAction, @"^([+-])?([a-zA-Z]{1,3})$");

            if (modesMatch.Success)
            {
                string rawActionValue = modesMatch.Groups[1].Value;

                Action = GetChannelModeActionType(rawActionValue);
                Modes  = modesMatch.Groups[2].Value;
            }

            ModeParams = message.GetParameterByIndex(2);
            Channel    = message.GetChannel();
        }
Exemplo n.º 3
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.º 4
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;
            }
        }
Exemplo n.º 5
0
        public TwitchSubscription(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 "id":
                    MessageId = tag.Value;
                    break;

                case "login":
                    UserName = tag.Value;
                    break;

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

                case "msg-param-months":
                    Months = int.Parse(tag.Value);
                    break;

                case "msg-param-sub-plan":
                    SubscriptionPlanType = ConvertToSubscriptionPlanType(tag.Value);
                    break;

                case "msg-param-sub-plan-name":
                    SubscriptionPlanName = tag.Value.Replace("\\s", " ");
                    break;

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

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

                case "system-msg":
                    SystemMessage = tag.Value.Replace("\\s", " ");
                    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;
                }
            }

            Channel     = message.GetChannel();
            UserMessage = message.GetParameterByIndex(1);
        }