예제 #1
0
        internal TwitchChannel(TwitchConnection twitch, string channel)
        {
            channel = channel.ToLower();

            m_twitch = twitch;
            Name = channel;
            m_prvtMsg = string.Format("PRIVMSG #{0} :", channel);

            var user = GetUser(channel);
            user.IsStreamer = true;
            user.IsModerator = true;

            User = GetUser(m_twitch.User);
        }
예제 #2
0
 static void chan_UserChatCleared(TwitchChannel channel, TwitchUser user)
 {
     WriteLine(channel, "[{0}] {1} chat clear", channel.Name, user.Name);
 }
예제 #3
0
 public ChatAction(TwitchChannel channel, MainWindow controller, TwitchUser user, string message)
     : base(channel, controller, ItemType.Action, user, message)
 {
 }
예제 #4
0
 public ChatMessage(TwitchChannel channel, MainWindow controller, TwitchUser user, string message, bool question)
     : base(channel, controller, question ? ItemType.Question : ItemType.Message)
 {
     User = user;
     Message = message;
 }
예제 #5
0
        private void SetMessage(ChatMessage msg)
        {
            m_user = msg.User;

            m_ban = new TimeOutIcon(GetImage(s_ban), GetImage(s_check));
            m_ban.BaselineAlignment = BaselineAlignment.Center;
            m_ban.Clicked += m_ban_Clicked;
            m_ban.Restore += Unban;

            m_eight = new TimeOutIcon(GetImage(s_eight), GetImage(s_check));
            m_eight.BaselineAlignment = BaselineAlignment.Center;
            m_eight.Clicked += m_eight_Clicked;
            m_eight.Restore += Unban;

            m_timeout = new TimeOutIcon(GetImage(s_timeout), GetImage(s_check));
            m_timeout.Clicked += m_timeout_Clicked;
            m_timeout.BaselineAlignment = BaselineAlignment.Center;
            m_timeout.Restore += Unban;

            if (Controller.ShowTimestamps)
                Inlines.Add(new Run(DateTime.Now.ToString("hh:mm ")) { Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070")), BaselineAlignment = BaselineAlignment.Center });

            if (Controller.ShowIcons && Controller.CurrentUser.IsModerator)
            {
                Inlines.Add(m_ban);
                Inlines.Add(m_eight);
                Inlines.Add(m_timeout);
            }

            if (m_user.IsModerator)
            {
                m_mod = new InlineUIContainer(GetImage(s_mod));
                m_mod.BaselineAlignment = BaselineAlignment.Center;
                Inlines.Add(m_mod);
            }

            var user = msg.User;
            if (user.IsSubscriber)
            {
                var sub = new InlineUIContainer(GetImage(s_sub));
                sub.BaselineAlignment = BaselineAlignment.Center;
                Inlines.Add(sub);
            }

            Brush userColor = Brushes.Black;
            if (user.Color != null)
            {
                try
                {
                    userColor = (SolidColorBrush)(new BrushConverter().ConvertFrom(msg.User.Color));
                }
                catch (NotSupportedException)
                {
                }
            }

            m_name = new Run(user.Name) { FontWeight = FontWeights.Bold, Foreground = userColor, BaselineAlignment = BaselineAlignment.Center };
            Inlines.Add(m_name);

            if (msg.Type != ItemType.Action)
                Inlines.Add(new Run(": ") { BaselineAlignment = BaselineAlignment.Center });

            BuildText(msg);
        }
예제 #6
0
 private void ModLeft(TwitchChannel conn, TwitchUser user)
 {
     if (user == CurrentUser)
         ModButtonVisibility = Visibility.Collapsed;
 }
예제 #7
0
        private void DispatcherClearChat(TwitchUser user)
        {
            foreach (var msg in Messages)
            {
                if (msg.User != user)
                    continue;

                msg.ClearChat();
            }
        }
예제 #8
0
        private void ChatMessageReceived(TwitchChannel sender, TwitchUser user, string text)
        {
            if (m_options.Ignore.Contains(user.Name))
                return;

            var emotes = Emoticons;
            if (emotes != null)
                emotes.EnsureDownloaded(user.ImageSet);

            bool question = false;
            if (HighlightQuestions)
            {
                foreach (var highlight in m_options.Highlights)
                {
                    if (text.ToLower().Contains(highlight))
                    {
                        question = true;
                        break;
                    }
                }
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<ChatItem>(AddItem), new ChatMessage(sender, this, user, text, question));
        }
예제 #9
0
        public TwitchUser GetUser(string name)
        {
            name = name.ToLower();

            lock (m_users)
            {
                TwitchUser result;
                if (m_users.TryGetValue(name, out result))
                    return result;

                TwitchUserData data = m_twitch.GetUserData(name);
                result = m_users[name] = new TwitchUser(data);
                return result;
            }
        }
예제 #10
0
        public bool Timeout(TwitchUser user, int duration)
        {
            if (duration <= 0)
                throw new ArgumentException("duration must be 1 or greater");

            StringBuilder sb = new StringBuilder(m_prvtMsg.Length + r_timeout.Length + user.Name.Length + 8);
            sb.Append(m_prvtMsg);
            sb.Append(r_timeout);
            sb.Append(user.Name);
            sb.Append(' ');
            sb.Append(duration);
            sb.Append('\n');

            return m_twitch.Send(User, sb.ToString());
        }
예제 #11
0
        public bool Ban(TwitchUser user)
        {
            StringBuilder sb = new StringBuilder(m_prvtMsg.Length + r_ban.Length + user.Name.Length + 1);
            sb.Append(m_prvtMsg);
            sb.Append(r_ban);
            sb.Append(user.Name);
            sb.Append('\n');

            return m_twitch.Send(User, sb.ToString());
        }
예제 #12
0
 static void chan_ActionReceived(TwitchChannel channel, TwitchUser user, string text)
 {
     WriteLine(channel, "[{0}] {1}: {2}", channel.Name, user.Name, text);
 }
예제 #13
0
 static void chan_ModeratorLeft(TwitchChannel channel, TwitchUser user)
 {
     WriteLine(channel, "[{0}] {1} left", channel.Name, user.Name);
 }
예제 #14
0
 static void chan_ModeratorJoined(TwitchChannel channel, TwitchUser user)
 {
     WriteLine(channel, "[{0}] {1} joined", channel.Name, user.Name);
 }
예제 #15
0
        private void SubscribeHandler(TwitchChannel sender, TwitchUser user)
        {
            if (PlaySounds)
                m_subSound.Play();

            var sub = new Subscriber(sender, this, user);
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<Subscriber>(DispatcherUserSubscribed), sub);
        }
예제 #16
0
        private void ChatActionReceived(TwitchChannel sender, TwitchUser user, string text)
        {
            if (m_options.Ignore.Contains(user.Name))
                return;

            var emotes = Emoticons;
            if (emotes != null)
                emotes.EnsureDownloaded(user.ImageSet);

            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<ChatItem>(AddItem), new ChatAction(sender, this, user, text));
        }
예제 #17
0
        public async void Unban(TwitchUser user)
        {
            var chan = m_channel;

            while (!m_channel.Unban(user))
                await Task.Delay(250);
        }
예제 #18
0
 private void UserClearChatHandler(TwitchChannel sender, TwitchUser user)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<TwitchUser>(DispatcherClearChat), user);
 }
예제 #19
0
        public bool Ban(TwitchUser user)
        {
            MessageBoxResult res = MessageBoxResult.Yes;
            if (ConfirmBans)
                res = MessageBox.Show(string.Format("Ban user {0}?", user.Name), "Ban User", MessageBoxButton.YesNo);

            if (res == MessageBoxResult.Yes)
            {
                BanWorker(m_channel, user);
                return true;
            }

            return false;
        }
예제 #20
0
 private void ModJoined(TwitchChannel conn, TwitchUser user)
 {
     if (user == CurrentUser)
         ModButtonVisibility = Visibility.Visible;
 }
예제 #21
0
 async void BanWorker(TwitchChannel chan, TwitchUser user)
 {
     while (!chan.Ban(user) && chan.IsJoined)
         await Task.Delay(250);
 }
예제 #22
0
 private static async void TimeoutUserList(int duration, TwitchChannel channel, TwitchUser[] users)
 {
     foreach (var user in users)
     {
         if (duration == -1)
         {
             while (!channel.Ban(user))
                 await Task.Delay(250);
         }
         else
         {
             while (!channel.Timeout(user, duration))
                 await Task.Delay(250);
         }
     }
 }
예제 #23
0
        async void TimeoutWorker(TwitchChannel chan, TwitchUser user, int duration)
        {
            if (duration < 1)
                duration = 1;

            while (!chan.Timeout(user, duration) && chan.IsJoined)
                await Task.Delay(250);
        }
예제 #24
0
 public Subscriber(TwitchChannel channel, MainWindow controller, TwitchUser user)
     : base(channel, controller, ItemType.Subscriber)
 {
     User = user;
 }
예제 #25
0
        public bool Timeout(TwitchUser user, int duration)
        {
            if (duration <= 0)
                duration = 1;

            MessageBoxResult res = MessageBoxResult.Yes;
            if (ConfirmTimeouts && duration > 1)
                res = MessageBox.Show(string.Format("Timeout user {0}?", user.Name), "Timeout User", MessageBoxButton.YesNo);

            if (res == MessageBoxResult.Yes)
            {
                TimeoutWorker(m_channel, user, duration);
                return true;
            }

            return false;
        }
예제 #26
0
 public ChatMessage(TwitchChannel channel, MainWindow controller, ItemType type, TwitchUser user, string message)
     : base(channel, controller, type)
 {
     User = user;
     Message = message;
 }
예제 #27
0
 void ModListReceived(TwitchChannel channel, TwitchUser[] moderators)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<TwitchChannel>(ModListReceivedWorker), channel);
 }
예제 #28
0
        internal bool Send(TwitchUser user, string message)
        {
            if (m_messageLimiter.CanSendMessage(user.IsModerator))
            {
                m_irc.Send(message);
                return true;
            }

            return false;
        }
예제 #29
0
 static void chan_UserSubscribed(TwitchChannel channel, TwitchUser user)
 {
     WriteLine(channel, "[{0}] {1} subscribed", channel.Name, user.Name);
 }