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); }
static void chan_UserChatCleared(TwitchChannel channel, TwitchUser user) { WriteLine(channel, "[{0}] {1} chat clear", channel.Name, user.Name); }
public ChatAction(TwitchChannel channel, MainWindow controller, TwitchUser user, string message) : base(channel, controller, ItemType.Action, user, message) { }
public ChatMessage(TwitchChannel channel, MainWindow controller, TwitchUser user, string message, bool question) : base(channel, controller, question ? ItemType.Question : ItemType.Message) { User = user; Message = message; }
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); }
private void ModLeft(TwitchChannel conn, TwitchUser user) { if (user == CurrentUser) ModButtonVisibility = Visibility.Collapsed; }
private void DispatcherClearChat(TwitchUser user) { foreach (var msg in Messages) { if (msg.User != user) continue; msg.ClearChat(); } }
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)); }
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; } }
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()); }
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()); }
static void chan_ActionReceived(TwitchChannel channel, TwitchUser user, string text) { WriteLine(channel, "[{0}] {1}: {2}", channel.Name, user.Name, text); }
static void chan_ModeratorLeft(TwitchChannel channel, TwitchUser user) { WriteLine(channel, "[{0}] {1} left", channel.Name, user.Name); }
static void chan_ModeratorJoined(TwitchChannel channel, TwitchUser user) { WriteLine(channel, "[{0}] {1} joined", channel.Name, user.Name); }
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); }
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)); }
public async void Unban(TwitchUser user) { var chan = m_channel; while (!m_channel.Unban(user)) await Task.Delay(250); }
private void UserClearChatHandler(TwitchChannel sender, TwitchUser user) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<TwitchUser>(DispatcherClearChat), user); }
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; }
private void ModJoined(TwitchChannel conn, TwitchUser user) { if (user == CurrentUser) ModButtonVisibility = Visibility.Visible; }
async void BanWorker(TwitchChannel chan, TwitchUser user) { while (!chan.Ban(user) && chan.IsJoined) await Task.Delay(250); }
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); } } }
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); }
public Subscriber(TwitchChannel channel, MainWindow controller, TwitchUser user) : base(channel, controller, ItemType.Subscriber) { User = user; }
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; }
public ChatMessage(TwitchChannel channel, MainWindow controller, ItemType type, TwitchUser user, string message) : base(channel, controller, type) { User = user; Message = message; }
void ModListReceived(TwitchChannel channel, TwitchUser[] moderators) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<TwitchChannel>(ModListReceivedWorker), channel); }
internal bool Send(TwitchUser user, string message) { if (m_messageLimiter.CanSendMessage(user.IsModerator)) { m_irc.Send(message); return true; } return false; }
static void chan_UserSubscribed(TwitchChannel channel, TwitchUser user) { WriteLine(channel, "[{0}] {1} subscribed", channel.Name, user.Name); }