public override void HandleCommand(IrcLine line, Nick nick, Channel channel) { try { Seen seen = Seen.Fetch(nick); DateTime checkTime = DateTime.Now; checkTime.AddDays(-7); if (seen.FirstSeenAt == DateTime.MinValue || seen.FirstSeenAt > checkTime) { conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but you aren't allowed to use the mugshots functions yet. :(", nick.DisplayName)); return; } Mugshot mugshot = Mugshot.Fetch(nick.Account); if (mugshot == null) { conn.SendPrivmsg(nick.Name, "You don't have a mugshot in the database to clear! :o"); return; } nick.Account.MostRecentNick = nick; mugshot.IsDeleted = true; mugshot.Save(); conn.SendPrivmsg(nick.Name, "Your mugshot has been cleared. :("); } catch (Exception e) { logger.Error(e); conn.SendPrivmsg(nick.Name, "Oof… I've got indigestion or something, I can't do that right now. :("); } }
public BTEnemy(Agent ownerBrain) : base(ownerBrain) { rootSelector = new Selector(); enemyCheck = new Sequence(); patrolSequence = new Sequence(); suspiciousSequence = new Sequence(); ChaseSequence = new Sequence(); DistractionSequence = new Sequence(); parallelDetection = new Parallel(); checkInverter = new Inverter(); turnToPoint = new TurnToPoint(GetOwner()); patrol = new Patrol(GetOwner()); wait = new Wait(GetOwner()); detection = new Detection(GetOwner()); distraction = new Distraction(GetOwner()); suspicious = new Suspicious(GetOwner()); suspiciousAlert = new SuspiciousAlert(GetOwner()); moveToLKP = new MoveToLKP(GetOwner()); seen = new Seen(GetOwner()); chase = new Chase(GetOwner()); //Root -> Patrol and Check rootSelector.AddChild(parallelDetection); parallelDetection.AddChild(checkInverter); //A parallel to check for the player checkInverter.AddChild(detection); //Patrol alongside checking for the player parallelDetection.AddChild(patrolSequence); patrolSequence.AddChild(patrol); patrolSequence.AddChild(wait); patrolSequence.AddChild(turnToPoint); //Root -> Adding sequences rootSelector.AddChild(suspiciousSequence); rootSelector.AddChild(ChaseSequence); rootSelector.AddChild(DistractionSequence); //Distraction State DistractionSequence.AddChild(distraction); DistractionSequence.AddChild(wait); //Suspicious state suspiciousSequence.AddChild(suspicious); suspiciousSequence.AddChild(suspiciousAlert); suspiciousSequence.AddChild(moveToLKP); suspiciousSequence.AddChild(wait); //Chase state ChaseSequence.AddChild(seen); ChaseSequence.AddChild(chase); ChaseSequence.AddChild(wait); }
private Tree BuildPartner(Node node, bool fartherChild) { if (Family.Members[node.Key].Refs.TryGetPartner( out Member partner, Settings.At, Settings.CanBeDead )) { if (fartherChild && Seen.Add(partner.Id)) { node.Partner = new Node( partner.Id, partner.FullName.Value(Settings.At) ) { PartnerReference = node.Key }; BuildRecurrent(node.Partner); } else { node.PartnerReference = partner.Id; } } return(this); }
public static async Task MessageCreatedEvent(DiscordClient c, MessageCreateEventArgs a) { if (a.Message.Content.StartsWith(Settings.Default.commandChar + "quit", StringComparison.OrdinalIgnoreCase)) { await CheckForQuitEvent(a).ConfigureAwait(false); } else if (a.Message.Content.StartsWith(Settings.Default.commandChar)) { await CheckForCustomCommand(a).ConfigureAwait(false); } else if (a.Message.Content.StartsWith(SekiMain.BotName + ",", StringComparison.OrdinalIgnoreCase) || a.Message.Content.EndsWith(SekiMain.BotName, StringComparison.OrdinalIgnoreCase)) { await CheckForCleverBot(a).ConfigureAwait(false); } await Waifunator(a.Message).ConfigureAwait(false); // Update "last seen" for user that sent the message if (a.Guild.Members.TryGetValue(a.Message.Author.Id, out DiscordMember member)) { string username = member.DisplayName; Seen.MarkUserSeen(username); // Ping users, leave this last cause it's sloooooooow await PingUser.SendPings(a).ConfigureAwait(false); } }
public async Task<IActionResult> PatientForm(string code) { if (code == null) return NotFound(); var patientForm = _context.PatientForm.Single(x => x.Code.Equals(code)); if (patientForm == null) return NotFound(); var tracking = _context.Tracking.Single(x => x.Code.Equals(code)); var activity = _context.Activity.Single(x => x.Code.Equals(code) && x.Status.Equals(_status.Value.REFERRED)); if (!activity.Status.Equals(_status.Value.REFERRED)) activity.Status = _status.Value.REFERRED; tracking.DateSeen = DateTime.Now; activity.DateSeen = DateTime.Now; _context.Update(tracking); _context.Update(activity); var seen = new Seen(); seen.FacilityId = UserFacility(); seen.TrackingId = _context.Tracking.Single(x => x.Code.Equals(patientForm.Code)).Id; seen.UpdatedAt = DateTime.Now; seen.CreatedAt = DateTime.Now; seen.UserMd = UserId(); _context.Add(seen); await _context.SaveChangesAsync(); return PartialView(patientForm); }
public async Task<IActionResult> PregnantForm(string code) { var form = await _context.PregnantForm.SingleAsync(x => x.Code.Equals(code)); Baby baby = null; if (form.PatientBabyId != null) baby = await _context.Baby.SingleOrDefaultAsync(x => x.BabyId.Equals(form.PatientBabyId)); var pregnantForm = new PregnantViewModel(form, baby); var tracking = _context.Tracking.Single(x => x.Code.Equals(code)); var activity = _context.Activity.Single(x => x.Code.Equals(code) && x.Status.Equals(_status.Value.REFERRED)); if (!activity.Status.Equals(_status.Value.REFERRED)) activity.Status = _status.Value.REFERRED; tracking.DateSeen = DateTime.Now; activity.DateSeen = DateTime.Now; _context.Update(tracking); _context.Update(activity); var seen = new Seen { FacilityId = UserFacility(), TrackingId = _context.Tracking.Single(x => x.Code.Equals(form.Code)).Id, UpdatedAt = DateTime.Now, CreatedAt = DateTime.Now, UserMd = UserId() }; await _context.AddAsync(seen); await _context.SaveChangesAsync(); return PartialView(pregnantForm); }
public override void HandleCommand(IrcLine line, Nick nick, Channel channel) { try { Seen seen = Seen.Fetch(nick); DateTime checkTime = DateTime.Now; checkTime.AddDays(-7); if (seen.FirstSeenAt == DateTime.MinValue || seen.FirstSeenAt > checkTime) { conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but you aren't allowed to use the mugshots functions yet. :(", nick.DisplayName)); return; } Regex r = new Regex(@"^!setinfo ?"); line.Args = r.Replace(line.Args, "").Trim(); if (line.Args.Length <= 0) // Whaaaat?? { conn.SendPrivmsg(nick.Name, "Usage: !setinfo <your message here>"); } else { nick.Account.MostRecentNick = nick; Info info = Info.FetchOrCreate(nick.Account); info.InfoTxt = line.Args; info.IsActive = true; info.IsDeleted = false; info.Save(); conn.SendPrivmsg(nick.Name, "Your info has been saved! :D"); } } catch (Exception e) { logger.Error(e); conn.SendPrivmsg(nick.Name, "Oof… My neck is killing me, I can't do that right now. :("); } }
private Tree BuildRecurrent(Node actual) { foreach (Member child in UseChildren(actual)) { if (Seen.Add(child.Id)) { Node childNode = new Node( child.Id, child.FullName.Value(Settings.At) ); actual.AddChild(childNode); if (Settings.CanBeFromFartherGeneration) { BuildRecurrent(childNode).BuildPartner( childNode, actual.Key != Root.Key ); } } else { actual.AddChildReference(child.Id); } } return(this); }
public async Task <IActionResult> PutSeen(int id, Seen seen) { if (id != seen.Id) { return(BadRequest()); } _context.Entry(seen).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeenExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private List <Seen> MergeLastSeen(List <Player> players) { List <Seen> ret = new List <Seen>(); foreach (var player in players) { if (ret.Count == 0) { ret.AddRange(player.Seen); continue; } foreach (var s in player.Seen) { Seen seen = ret.Find(S => S.System == s.System); if (seen == null) { ret.Add(s); } else { seen.Count += s.Count; if (seen.Time < s.Time) { seen.Time = s.Time; } } } } return(ret); }
public ActionResult DeleteConfirmed(int id) { Seen seen = db.MarkedAsRead.Find(id); db.MarkedAsRead.Remove(seen); db.SaveChanges(); return(RedirectToAction("Index")); }
public SeenForm(Poteryashka poteryashka) { InitializeComponent(); Seen = new Seen() { Who = poteryashka }; }
public ActionResult Edit([Bind(Include = "SeenID,HasSeen")] Seen seen) { if (ModelState.IsValid) { db.Entry(seen).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seen)); }
public async Task <ActionResult <Seen> > PostSeen(Seen seen) { //if (_context.Movie.Find().Id == seen.Id) // Console.WriteLine("KAZKAAAS"); _context.Seen.Add(seen); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSeen", new { id = seen.Id }, seen)); }
public void ActionInTheBcl() // Base Class Library (as opposed to frameworks) { //You will find Action used within the BCL, often when iterating over a container string greeting = "Hello world"; Seen s = new Seen(); Array.ForEach(greeting.ToCharArray(), s.Look); Assert.Equal("Hello world", s.Letters); }
public async Task HaveSeenPoteryashkaAsync(Seen seen) { var client = GetClient(); var postUrl = url + "haveseenpoteryashka/"; var responce = await client.PostAsync(postUrl, new StringContent( JsonConvert.SerializeObject(seen), Encoding.UTF8, "application/json")); }
public void ActionInTheBcl() { //You will find Action used within the BCL, often when iterating over a container string greeting = "Hello world"; Seen s = new Seen(); Array.ForEach(greeting.ToCharArray(), s.Look); Assert.Equal(FILL_ME_IN, s.Letters); }
public void ActionInTheBcl() { //You will find Action used within the BCL, often when iterating over a container string greeting = "Hello world"; Seen s = new Seen(); Array.ForEach(greeting.ToCharArray(), s.Look); Assert.Equal("Hello world", s.Letters); }
public ActionResult Create([Bind(Include = "SeenID,HasSeen")] Seen seen) { if (ModelState.IsValid) { db.MarkedAsRead.Add(seen); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seen)); }
public void ActionInTheBcl() { //You will find Action used within the Base Class Library, often when iterating over a container. // E.g. the second argument of Array.ForEach is Action<T>, for which we can use any method that takes a T. // In this example we have a Array<char>, so we need a Action<char>, to which we can assign a string greeting = "Hello world"; Seen s = new Seen(); Array.ForEach(greeting.ToCharArray(), s.Look); Assert.Equal(FILL_ME_IN, s.Letters); }
public void ActionInTheBcl() { //You will find Action used within the Base Class Library, often when iterating over a container. // E.g. the second argument of Array.ForEach is Action<T>, for which we can use any method that takes a T. // In this example we have a Array<char>, so we need a Action<char>, to which we can assign a string greeting = "Hello world"; Seen s = new Seen(); Array.ForEach(greeting.ToCharArray(), s.Look); Assert.AreEqual(FILL_ME_IN, s.Letters); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seen seen = db.MarkedAsRead.Find(id); if (seen == null) { return(HttpNotFound()); } return(View(seen)); }
/* better algorithm * there are only three status ; not seen, seen once and seen multiple */ public static string FindFirstChar2(String str) { Dictionary <int, object> table = new Dictionary <int, object> (); object SeenOnce = new object(); object SeenMulti = new object(); object Seen; int length = str.Length; object value; for (int i = 0; i < length;) { int cp = Char.ConvertToUtf32(str, i); i += Char.IsSurrogatePair(str, i) ? 2 : 1; Console.Write("U+{0:X4}->{1}", cp, str[i - 1]); table.TryGetValue(cp, out value); Seen = value; if (Seen == null) { table.Add(cp, SeenOnce); Console.WriteLine("->fail"); } else { if (Seen.Equals(SeenOnce)) { table.Remove(cp); table.Add(cp, SeenMulti); Console.WriteLine("->success"); } } // Console.WriteLine(table[0]); //String s = table[cp].ToString(); //Console.WriteLine (Seen); } for (int i = 0; i < length;) { int cp = Char.ConvertToUtf32(str, i); i += Char.IsSurrogatePair(str, i) ? 2 : 1; if (SeenOnce.Equals(table[cp])) { return(Char.ConvertFromUtf32(cp)); } } return(null); }
public static void Post(string guid, string key) { //Check if there is already a Seen by the user if (!CheckExistence(guid, key)) { //post new Seen Seen Seen = new Seen { Owner_Guid = key, Confess_Guid = guid }; Seen.Id = Logical.Setter(Seen.Id); contextLite.Seen.Insert(Seen); // context.Seen.InsertOne(Seen); } }
public void TakeDirection(int NextStepX, int NextStepY, int Inaccuracy, int ChangeX, int ChangeY, int Diagonal) { if (Math.Abs(NextStepX - X) < Inaccuracy && Math.Abs(NextStepY - Y) < Inaccuracy) { PositionObject = Seen.P0; } else if (Math.Abs(NextStepX - X) < Inaccuracy && NextStepY < Y) { ChangeXY(0, -Diagonal); PositionObject = Seen.P90; } else if (Math.Abs(NextStepX - X) < Inaccuracy && NextStepY > Y) { ChangeXY(0, Diagonal); PositionObject = Seen.P270; } else if (NextStepX > X && Math.Abs(NextStepY - Y) < Inaccuracy) { ChangeXY(Diagonal, 0); PositionObject = Seen.P0; } else if (NextStepX < X && Math.Abs(NextStepY - Y) < Inaccuracy) { ChangeXY(-Diagonal, 0); PositionObject = Seen.P180; } else if (NextStepX > X && NextStepY > Y) { ChangeXY(ChangeX, ChangeY); PositionObject = Seen.P315; } else if (NextStepX < X && NextStepY < Y) { ChangeXY(-ChangeX, -ChangeY); PositionObject = Seen.P135; } else if (NextStepX > X && NextStepY < Y) { ChangeXY(ChangeX, -ChangeY); PositionObject = Seen.P45; } else if (NextStepX < X && NextStepY > Y) { ChangeXY(-ChangeX, ChangeY); PositionObject = Seen.P225; } }
public void UpdateLastSeen(string channel, string user, string message) { var seenData = _Db.Seen.FirstOrDefault(s => s.User == user); if (seenData == null) { seenData = new Seen() { User = user }; _Db.Seen.Add(seenData); } seenData.Message = message; seenData.Channel = channel; seenData.Timestamp = DateTime.UtcNow; _Db.SaveChanges(); }
/// <summary> /// Applies the setting. /// </summary> /// <param name="setting">The setting.</param> public void ApplySetting(ControlSettings setting) { if (!string.IsNullOrEmpty(setting.HelpMessage)) { this.HelpMessage = setting.HelpMessage; } Help.ApplySetting(setting.Help); Seen.ApplySetting(setting.Seen); Files.ApplySetting(setting.Files); Stick.ApplySetting(setting.Stick); SeenGroup.ApplySetting(setting.SeenGroup); SeenModerator.ApplySetting(setting.SeenModerator); Moderator.ApplySetting(setting.Moderator); Hours.ApplySetting(setting.Hours); Punish.ApplySetting(setting.Punish); SelfGroup.ApplySetting(setting.SelfGroup); }
private void MarkAsSeen(Announcement announcement) { // Mark announcement as 'Seen' string currentUserID = User.Identity.GetUserId(); ApplicationUser currentUser = db.Users.FirstOrDefault(x => x.Id == currentUserID); Seen view = db.MarkedAsRead.FirstOrDefault(x => x.Announcement.AnnouncementID == announcement.AnnouncementID && x.User.Id == currentUserID); if (view == null) { Seen viewed = new Seen(); announcement.MarkedAsRead = new List <ApplicationUser>(); viewed.Announcement = announcement; viewed.User = currentUser; viewed.HasSeen = true; db.MarkedAsRead.Add(viewed); announcement.MarkedAsRead.Add(currentUser); db.SaveChanges(); } }
/// <summary> /// Discern whether a user has exceeded command-querying limit /// </summary> /// <returns>true: user timeout</returns> public bool GetTimeout() { bool doTimeout = false; if (Attempts.Equals(4)) { if (Seen.AddMinutes(1) < DateTime.UtcNow) { Attempts = 0; // if so, reset their attempts to 0 } else { doTimeout = true; // if not, timeout is true } } else if (Access > 1) // if user isn't admin/op, increment their attempts { Attempts++; } return(doTimeout); }
public void DoSeenPlugin(IrcConnection conn, IrcLine line) { // :[email protected] JOIN #channel // :Nick!~User@unaffiliated/Nick JOIN #channel // :Nick!~User@unaffiliated/Nick PART #channel // :Nick!~User@unaffiliated/Nick PART #channel :"screw you" // :[email protected] QUIT :Quit: Quit! // :[email protected] NICK :FourHalfWorms // :[email protected] PRIVMSG Lumbricus :!info Nick2 Channel channel = null; IrcCommand ircCommand = (IrcCommand)Enum.Parse(typeof(IrcCommand), line.IrcCommand); switch (ircCommand) { case IrcCommand.JOIN: case IrcCommand.PART: case IrcCommand.PRIVMSG: if (line.IrcCommandArgsRaw.StartsWith("#")) { channel = conn.GetChannel(line.IrcCommandArgsRaw); } goto case IrcCommand.NICK; case IrcCommand.NICK: case IrcCommand.NOTICE: case IrcCommand.QUIT: Nick nick = Nick.FetchOrCreate(line.Nick, conn.Server); if (nick == null) { throw new Exception(String.Format("Unable to fetch or create nick `{0}`", nick)); } Seen.Update(conn.Server, nick, nick.Account, channel); break; } }
public override void HandleCommand(IrcLine line, Nick nick, Channel channel) { try { if (nick.Account == null) { conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but you need to be identified with services to clear your info.", nick.DisplayName)); return; } Seen seen = Seen.Fetch(nick); DateTime checkTime = DateTime.Now; checkTime.AddDays(-7); if (seen.FirstSeenAt == DateTime.MinValue || seen.FirstSeenAt > checkTime) { conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but you aren't allowed to use the mugshots functions yet. :(", nick.DisplayName)); return; } Info info = Info.Fetch(nick.Account); if (info == null) { conn.SendPrivmsg(nick.Name, "You don't have any info in the database to clear! :o"); return; } nick.Account.MostRecentNick = nick; info.IsDeleted = true; info.Save(); conn.SendPrivmsg(nick.Name, "Your info has been cleared. :("); } catch (Exception e) { logger.Error(e); conn.SendPrivmsg(nick.Name, "Oof… I banged my knee and it don't half hurt, I can't do that right now. :("); } }
static void ProcessLine(string line) { string logNick = null; string logTime = null; string logDate = null; string message = null; IrcCommand ircCommand = IrcCommand.UNKNOWN; Regex r; Match m; switch (type) { case LogType.znc: logDate = (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : null); r = new Regex(@"^\[(?<time>\d\d:\d\d:\d\d)\] <(?<nick>[^>]+)> (?<message>.*)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.PRIVMSG; message = m.Groups["message"].Value; } r = new Regex(@"^\[(?<time>\d\d:\d\d:\d\d)\] (?<message>\* (?<nick>[^ ]+) .*)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.PRIVMSG; message = m.Groups["message"].Value; } r = new Regex(@"^\[(?<time>\d\d:\d\d:\d\d)\] \*\*\* Joins: (?<nick>[^ ]+) ", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.JOIN; message = null; } r = new Regex(@"^\[(?<time>\d\d:\d\d:\d\d)\] \*\*\* Quits: (?<nick>[^ ]+) \(.*\) \(Quit: (?<message>.*)\)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.QUIT; message = m.Groups["message"].Value; } r = new Regex("^\\[(?<time>\\d\\d:\\d\\d:\\d\\d)\\] \\*\\*\\* Parts: (?<nick>[^ ]+) \\(.*\\) \\(\"?(?<message>.*)\"?\\)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.PART; message = m.Groups["message"].Value; } if (logNick == null || logTime == null) { // F**k-all to do here! return; } break; case LogType.irssi: // Irssi uses a spastic date format: // --- Log opened Wed Jun 20 16:11:34 2012 r = new Regex(@"^--- Log opened ([^ ]+) (?<month>[^ ]+) (?<day>[^ ]+) (?<time>[^ ]+) (?<year>.*)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { string lineDate = string.Format("{0} {1} {2} {3}", m.Groups["day"].Value, m.Groups["month"].Value, m.Groups["year"].Value, m.Groups["time"].Value); date = DateTime.Parse(lineDate); return; } r = new Regex(@"^--- Day changed ([^ ]+) (?<month>[^ ]+) (?<day>[^ ]+) (?<time>[^ ]+) (?<year>.*)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { string lineDate = string.Format("{0} {1} {2} {3}", m.Groups["day"].Value, m.Groups["month"].Value, m.Groups["year"].Value, m.Groups["time"].Value); date = DateTime.Parse(lineDate); return; } if (date != null) { logDate = date.Value.ToString("yyyy-MM-dd"); } if (string.IsNullOrWhiteSpace(logDate)) { throw new Exception("Date not yet set, unable to continue processing log file."); } r = new Regex(@"^(?<time>\d\d:\d\d) <.(?<nick>[^>]+)> (?<message>.*)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value + ":00"; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.PRIVMSG; message = m.Groups["message"].Value; } r = new Regex(@"^(?<time>\d\d:\d\d) (?<message>\* (?<nick>[^ ]+)> .*)$", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value + ":00"; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.PRIVMSG; message = m.Groups["message"].Value; } r = new Regex(@"^(?<time>\d\d:\d\d) -!- (?<nick>[^ ]+) .* has joined #", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value + ":00"; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.JOIN; message = null; } r = new Regex(@"^(?<time>\d\d:\d\d) -!- (?<nick>[^ ]+) .* has quit \[Quit: (?<message>.*)\]", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value + ":00"; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.QUIT; message = m.Groups["message"].Value; } r = new Regex("^(?<time>\\d\\d:\\d\\d) -!- (?<nick>[^ ]+) .* has left #([^ ]+) \\[\"?(?<message>.*)\"?\\]", RegexOptions.ExplicitCapture); m = r.Match(line); if (m.Success) { logTime = m.Groups["time"].Value + ":00"; logNick = m.Groups["nick"].Value; ircCommand = IrcCommand.PART; message = m.Groups["message"].Value; } if (logNick == null || logTime == null) { // F**k-all to do here! return; } break; default: throw new Exception(string.Format("Unknown log type `{0}`", type)); } Nick nick = Nick.FetchOrCreate(logNick, server); Account account = nick.Account; Seen seen = Seen.Fetch(nick) ?? new Seen(); DateTime logDateTime = DateTime.Parse(logDate + " " + logTime); if (seen.Nick == null) { seen.Nick = nick; } if (seen.Account == null) { seen.Account = account; } if (seen.Channel == null) { seen.Channel = channel; } if (seen.Server == null) { seen.Server = server; } if (seen.FirstSeenAt == DateTime.MinValue || logDateTime < seen.FirstSeenAt) { seen.FirstSeenAt = logDateTime; } if (seen.LastSeenAt == DateTime.MaxValue || logDateTime > seen.LastSeenAt) { seen.LastSeenAt = logDateTime; } seen.Save(); Log log = Log.Create(server); log.Nick = nick; log.Account = account; log.Channel = channel; log.IrcCommand = ircCommand; log.LoggedAt = logDateTime; log.Trail = message; log.Line = line; log.Save(); }