public override void Process(CmdTrigger trigger) { var nick = trigger.Args.NextWord(); var messagetosend = trigger.Args.Remainder.Normalize(); if (string.IsNullOrEmpty(nick) || string.IsNullOrEmpty(messagetosend)) { trigger.Reply("Failed to parse input, please try again"); } else { using (var db = new MessagesContainer()) { var msg = new Message { DateLeft = DateTime.Now.ToString(), FromIrcNick = trigger.User.Nick, IrcNick = nick.ToLower(), MessageText = messagetosend.ToLower() }; db.Messages.AddObject(msg); db.SaveChanges(); trigger.Reply("Message saved"); return; } } }
protected override void OnUserEncountered(IrcUser user) { if (user == null || user.Nick == null) { return; } using (var db = new MessagesContainer()) { foreach (var message in db.Messages.Where(message => message.IrcNick.ToLower() == user.Nick.ToLower())) { CommandHandler.Msg(user.ToString(), "Date Left: " + message.DateLeft + "\nFrom Nick: " + message.FromIrcNick + "\nMessage Sent: " + message.MessageText); db.Messages.DeleteObject(message); db.SaveChanges(); } } }