void Msgr_MessageReceived(object sender, MessageEventArgs e) { using (ConsoleExt.WithColor(eventColor)) Console.WriteLine("Server message from {0}", e.SenderNickname); }
async void IMSession_MessageReceived(object sender, MessageEventArgs e) { var imSession = (IMSession)sender; if (e.Message.Headers.ContainsKey("TypingUser") && ParrotMode) { e.Message.Headers["TypingUser"] = Msgr.LocalUser.LoginName; await imSession.SendMessageAsync(e.Message, MessageOption.NoAcknoweldgement); return; } if (e.Message.ContentType != "text/plain; charset=UTF-8") return; using (ConsoleExt.WithColor(eventColor)) Console.WriteLine("{0}: {1}", e.Sender.Nickname ?? e.Sender.LoginName, Encoding.UTF8.GetString(e.Message.Body)); if (!ParrotMode) return; if (RandomColor) { MessageFormatter mf = new MessageFormatter(); mf.SetRandomColor(); mf.ApplyFormat(e.Message); } await imSession.SendMessageAsync(e.Message, MessageOption.NoAcknoweldgement); }
void OnMessageReceived(MessageEventArgs e) { EventHandler<MessageEventArgs> handler = MessageReceived; if (handler != null) handler(this, e); }