protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments, CancellationToken token) { if (this.UseChatModeration && arguments.Count() > 0) { string moderationReason = await ModerationHelper.ShouldBeModerated(user, arguments.ElementAt(0)); if (!string.IsNullOrEmpty(moderationReason)) { await ModerationHelper.SendModerationWhisper(user, moderationReason); return; } } await base.PerformInternal(user, arguments, token); }
private async Task <ChatMessageViewModel> AddMessage(ChatMessageEventModel messageEvent) { UserViewModel user = await this.AddUser(messageEvent); if (user != null && !this.userEntranceCommands.Contains(user.ID)) { this.userEntranceCommands.Add(user.ID); if (user.Data.EntranceCommand != null) { await user.Data.EntranceCommand.Perform(user); } } ChatMessageViewModel message = new ChatMessageViewModel(messageEvent, user); if (this.Messages.ContainsKey(message.ID)) { return(null); } this.Messages[message.ID] = message; if (this.DisableChat && !message.ID.Equals(Guid.Empty)) { await this.DeleteMessage(message.ID); return(message); } string moderationReason = await message.ShouldBeModerated(); if (!string.IsNullOrEmpty(moderationReason)) { await this.DeleteMessage(message.ID); await ModerationHelper.SendModerationWhisper(user, moderationReason); return(message); } if (!string.IsNullOrEmpty(ChannelSession.Settings.NotificationChatTaggedSoundFilePath) && message.IsUserTagged) { await ChannelSession.Services.AudioService.Play(ChannelSession.Settings.NotificationChatTaggedSoundFilePath, 100); } if (!string.IsNullOrEmpty(ChannelSession.Settings.NotificationChatWhisperSoundFilePath) && message.IsWhisper) { await ChannelSession.Services.AudioService.Play(ChannelSession.Settings.NotificationChatWhisperSoundFilePath, 100); } if (!await this.CheckMessageForCommandAndRun(message)) { if (message.IsWhisper && ChannelSession.Settings.TrackWhispererNumber && !message.IsStreamerOrBot()) { await this.whisperNumberLock.WaitAsync(); if (!whisperMap.ContainsKey(message.User.ID)) { whisperMap[message.User.ID] = whisperMap.Count + 1; } message.User.WhispererNumber = whisperMap[message.User.ID]; this.whisperNumberLock.Release(); await ChannelSession.Chat.Whisper(message.User.UserName, $"You are whisperer #{message.User.WhispererNumber}.", false); } } return(message); }