Example #1
0
        private static void PrivateMessageHandler(TwitchChannel channel, IrcRawMessageEventArgs args)
        {
            var parameters = args.Message.Parameters;

            if (parameters.Count < 2)
            {
                return;
            }

            if (parameters[1].StartsWith("specialuser", StringComparison.InvariantCultureIgnoreCase))
            {
                var userBadgeParams = parameters[1].Split(' ');
                if (userBadgeParams.Length == 3)
                {
                    channel.SetUserBadge(userBadgeParams[1], userBadgeParams[2]);
                }
            }
            else if (parameters[1].StartsWith("usercolor", StringComparison.InvariantCultureIgnoreCase))
            {
                var userColorParams = parameters[1].Split(' ');

                //ObservableCollection<UserBadge> userbadges = null;
                //channel.userBadges.TryGetValue(userColorParams[1], out userbadges);
                //if (userColorParams.Length == 3)
                //    channel.AddChatUser(userColorParams[1], "user", userbadges);
            }

            if (!parameters[0].Equals(channel.ChannelName, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            channel.ChannelStats.MessagesCount++;
            channel.Chat.UpdateStats();

            if (channel.ReadMessage != null)
            {
                channel.ReadMessage(new ChatMessage()
                {
                    Channel         = channel.ChannelName,
                    ChatIconURL     = channel.Chat.IconURL,
                    ChatName        = channel.Chat.ChatName,
                    FromUserName    = args.Message.Source.Name,
                    HighlyImportant = false,
                    IsSentByMe      = false,
                    Text            = parameters[1],
                    UserBadges      = channel.userBadges.ContainsKey(args.Message.Source.Name) ? channel.userBadges[args.Message.Source.Name] : null
                });
            }
        }
Example #2
0
        private static void ModeHandler(TwitchChannel channel, IrcRawMessageEventArgs args)
        {
            var parameters = args.Message.Parameters;

            if (parameters.Count < 3)
            {
                return;
            }
            if (!parameters[1].Equals("+o"))
            {
                return;
            }

            var username = parameters[2];

            if (!username.Equals(channel.Chat.NickName, StringComparison.InvariantCultureIgnoreCase))
            {
                channel.SetUserBadge(parameters[2], "mod");
            }
        }