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);
        }
Beispiel #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();
        }
Beispiel #3
0
        public TwitchChannelState(IrcMessage message)
        {
            foreach (KeyValuePair <string, string> tag in message.Tags)
            {
                switch (tag.Key)
                {
                case "broadcaster-lang":
                    BroadcasterLanguage = tag.Value;
                    break;

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

                case "followers-only":
                    FollowersOnlyMinutes = int.Parse(tag.Value);
                    break;

                case "r9k":
                    IsR9k = tag.Value.Equals("1");
                    break;

                case "rituals":
                    RitualsEnabled = tag.Value.Equals("1");
                    break;

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

                case "slow":
                    IsSlowMode = tag.Value.Equals("1");
                    break;

                case "subs-only":
                    IsSubOnly = tag.Value.Equals("1");
                    break;
                }
            }

            Channel = message.GetChannel();
        }
Beispiel #4
0
        public TwitchUserState(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 "emote-sets":
                    Emotesets = tag.Value.Split(',');
                    break;

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

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

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

            Channel = message.GetChannel();
        }
Beispiel #5
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;
            }
        }
Beispiel #6
0
        public TwitchSubscriptionGift(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-recipient-display-name":
                    RecipientDisplayName = tag.Value;
                    break;

                case "msg-param-recipient-id":
                    RecipientUserId = tag.Value;
                    break;

                case "msg-param-recipient-user-name":
                    RecipientUserName = 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();
        }
Beispiel #7
0
        public TwitchChannelRitual(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-ritual-name":
                    RitualName = tag.Value;
                    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();
            Message = message.GetParameterByIndex(1);
        }