Exemple #1
0
        private void TwitchClient_OnWhisperReceived(object sender, OnWhisperReceivedArgs e)
        {
            // If sender is allowed
            if (!UserFilter.IsUserAllowed(e.WhisperMessage.Username, e.WhisperMessage.UserType))
            {
                return;
            }

            OnNotificationArgs notificationArgs = new OnNotificationArgs(DateTime.Now, e.WhisperMessage.DisplayName, e.WhisperMessage.Message, NotificationType.Whisper, e.WhisperMessage.Message.GetUrls());

            OnNotification(notificationArgs);
        }
Exemple #2
0
        private void TwitchClient_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            // If sender is allowed
            if (!UserFilter.IsUserAllowed(e.ChatMessage.Username, e.ChatMessage.UserType))
            {
                return;
            }

            // If message is allowed
            if (!MessageFilter.IsMessageAllowed(e.ChatMessage.Message))
            {
                return;
            }

            // If only show mentions is enabled
            if (SettingsManager.Configuration.Notifications.OnlyShowMentions)
            {
                if (e.ChatMessage.Message.IndexOf($"@{AuthorizedUser.DisplayName}", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    return;
                }
            }

            // If message is a recent duplicate, skip
            if (IsRepeatMessage(e.ChatMessage))
            {
                return;
            }
            SetLastMessage(e.ChatMessage);

            // Store the message and trim it
            string message = e.ChatMessage.Message.Trim();

            // If the message starts with a exclamation point, skip. It is probability a command for a bot
            if (message.StartsWith("!"))
            {
                return;
            }

            // If the message starts with a colon, remove the colon. It is from /me
            if (message.StartsWith(":"))
            {
                message = message.Remove(0, 1).Trim();
            }

            // Remove all channel emotes
            message = string.Join(" ", message.Split(' ').Except(e.ChatMessage.EmoteSet.Emotes.Select(x => x.Name).ToArray()));

            // Remove all BetterTTV emotes
            message = string.Join(" ", message.Split(' ').Except(_BetterTTVEmotes));

            // Remove all FrankerFaceZ emotes
            message = string.Join(" ", message.Split(' ').Except(_FrankerFaceZEmotes));

            // If message is empty, skip
            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            OnNotificationArgs notificationArgs = new OnNotificationArgs(DateTime.Now, e.ChatMessage.DisplayName, message, GetNotificationType(e.ChatMessage.UserType), message.GetUrls());

            OnNotification(notificationArgs);
        }