private void PostFilterProcessTimelineStatus(object sender, TimelineStatusEventArgs e) { if (IgnoreIds.Contains(e.Status.Id)) return; foreach (var item in Configuration.Items) { if (!ListsMembers.ContainsKey(item.Slug)) ListsMembers.Add(item.Slug, new HashSet<Int64>()); // マッチするか if (item.IsMatch(e.Status)) { HashSet<Int64> members = ListsMembers[item.Slug]; if (members.Contains(e.Status.User.Id)) continue; // すでにListsに含まれている members.Add(e.Status.User.Id); // 適当に非同期で投げまくる ThreadPool.QueueUserWorkItem( new WaitCallback(ProcessMember), new ProcessMemberArgs() { Item = item, Status = e.Status }); } } }
void CurrentSession_PreProcessTimelineStatus(object sender, TimelineStatusEventArgs e) { lock (_dataContext) { var status = new Status { Id = e.Status.Id, CreatedAt = e.Status.CreatedAt, ScreenName = e.Status.User.ScreenName, Text = e.Status.Text, UserId = (e.Status.User.Id == 0) ? null : (Int32?)e.Status.User.Id }; if (!_dataContext.Status.Contains(status)) { using (var ctx = new TwitterIrcGatewayDataContext()) { try { ctx.Status.InsertOnSubmit(status); ctx.SubmitChanges(); } catch (DuplicateKeyException dupE) { } catch (SqlException sqlE) { // キー制約 if (sqlE.Number == 2627) return; throw; } } } } }
private void Session_PostFilterProcessTimelineStatus(object sender, TimelineStatusEventArgs e) { e.Text = (Config.EnableResolveShortenUrl) ? Resolve(e.Text) : e.Text; }