void OnMessageReceived(NightlyCode.Twitch.Chat.ChatMessage message) { if (FilterMessage(message)) { return; } if (ScanForAttachements(message)) { return; } ChatMessage?.Invoke(this, CreateChatMessage(message)); }
bool ScanForAttachements(NightlyCode.Twitch.Chat.ChatMessage message) { Match[] links = linkparser.Matches(message.Message).Cast <Match>().ToArray(); if (links.Length == 0) { return(false); } Logger.Info(this, "Found possible attachements in message", string.Join("\r\n", links.Select(l => l.Value))); ChatMessage chatmessage = CreateChatMessage(message); chatmessage.Attachements = CreateAttachements(links.Select(l => l.Value)).ToArray(); chatmessage.Message = ReplaceAttachementText(chatmessage.Message, chatmessage.Attachements.Where(a => a.Type == AttachmentType.Image), "Image"); ChatMessage?.Invoke(this, chatmessage); return(true); }