예제 #1
0
        private void UpdateList()
        {
            if (!AccountStorage.Contains(_selectedScreenName))
            {
                return;
            }
            var acc = AccountStorage.Get(_selectedScreenName);

            IsListLoading = true;
            Task.Factory.StartNew(() =>
            {
                try
                {
                    var lists = acc.GetFollowingListsAll(_selectedScreenName);
                    if (lists != null)
                    {
                        lists.ForEach(l => acc.RegisterFollowingList(l));
                    }
                    RaisePropertyChanged(() => ListItems);
                }
                catch
                {
                    this.Messenger.Raise(new InformationMessage("リスト情報を取得できません。",
                                                                "リストロードエラー", System.Windows.MessageBoxImage.Error, "WarningMessage"));
                }
                finally
                {
                    IsListLoading = false;
                }
            });
        }
예제 #2
0
        internal void NotifyNewTweetReceived(TimelineListCoreViewModel timelineListCoreViewModel, TimelineChild.TweetViewModel tweetViewModel)
        {
            if (AccountStorage.Contains(tweetViewModel.Status.User.ScreenName) || !this.IsAlive)
            {
                return;
            }

            // 正直謎設定だし、スタックトップTLの新着を伝えるってあんまり直感的じゃないから
            // 設定じゃなくて固定にしてよかったかもしれない
            if (Setting.Instance.NotificationProperty.NotifyStackTopTimeline ?
                this.CurrentForegroundTimeline.CoreViewModel == timelineListCoreViewModel :
                this.BaseTimeline.CoreViewModel == timelineListCoreViewModel)
            {
                // NewTweetsCountはプロパティが良きに計らってくれるので
                // _人人人人人人人人人人人人人人人_
                // >  インクリしていってね!!!<
                //  ̄YYYYYYYYYYYYYYY ̄
                this.NewTweetsCount++;

                if (this.TabProperty.IsNotifyEnabled)
                {
                    if (String.IsNullOrEmpty(this.TabProperty.NotifySoundPath))
                    {
                        NotificationCore.QueueNotify(tweetViewModel);
                    }
                    else
                    {
                        NotificationCore.QueueNotify(tweetViewModel, this.TabProperty.NotifySoundPath);
                    }
                }
            }
        }
예제 #3
0
        public bool Match(string haystack, string needle)
        {
            if (needle == "*")
            {
                return(AccountStorage.Contains(haystack));
            }
            else
            {
                bool startsWith = false;
                bool endsWith   = false;

                if (needle.StartsWith("\\/"))
                {
                    // 先頭のスラッシュエスケープを削除
                    needle = needle.Substring(1);
                }

                if (needle.StartsWith("^"))
                {
                    startsWith = true;
                    needle     = needle.Substring(1);
                }
                else if (needle.StartsWith("\\^"))
                {
                    needle = needle.Substring(1);
                }

                if (needle.EndsWith("$"))
                {
                    if (needle.EndsWith("\\$"))
                    {
                        needle = needle.Substring(0, needle.Length - 2) + "$";
                    }
                    else
                    {
                        endsWith = true;
                        needle   = needle.Substring(0, needle.Length - 1);
                    }
                }
                var unescaped = needle.UnescapeFromQuery();
                if (startsWith && endsWith)
                {
                    // complete
                    return(haystack.Equals(needle, StringComparison.CurrentCultureIgnoreCase));
                }
                else if (startsWith)
                {
                    return(haystack.StartsWith(needle, StringComparison.CurrentCultureIgnoreCase));
                }
                else if (endsWith)
                {
                    return(haystack.EndsWith(needle, StringComparison.CurrentCultureIgnoreCase));
                }
                else
                {
                    return(haystack.IndexOf(needle, StringComparison.CurrentCultureIgnoreCase) >= 0);
                }
            }
        }
예제 #4
0
        public static bool IsMuted(TwitterStatusBase status)
        {
            var tweet = status as TwitterStatus;

            return((Setting.Instance.TimelineFilteringProperty.MuteFilterCluster != null &&
                    Setting.Instance.TimelineFilteringProperty.MuteFilterCluster.Filter(status) &&
                    !AccountStorage.Contains(status.User.ScreenName)) ||
                   IsMuted(status.User) ||
                   (tweet != null && tweet.RetweetedOriginal != null && IsMuted(tweet.RetweetedOriginal.User)));
        }
예제 #5
0
        public static bool IsMentionOfMe(TwitterStatusBase status)
        {
            var tweet = status as TwitterStatus;

            // DMではなくて、リツイートでもないことを確認する
            if (tweet != null && tweet.RetweetedOriginal == null)
            {
                // リツイートステータス以外で、自分への返信を探す
                var matches = RegularExpressions.AtRegex.Matches(status.Text);
                if (matches.Count > 0 && matches.Cast <Match>().Select(m => m.Value)
                    .Where(s => AccountStorage.Contains(s)).FirstOrDefault() != null)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #6
0
 private void CheckFollower(UserViewModel userViewModel, string receiver)
 {
     try
     {
         // 自分からのフォローなら無視
         if (AccountStorage.Contains(userViewModel.TwitterUser.NumericId) ||
             AccountStorage.Contains(userViewModel.TwitterUser.ScreenName))
         {
             return;
         }
         // 自分がフォローしている相手なら無視
         if (TwitterHelper.IsFollowingAny(userViewModel))
         {
             return;
         }
         // 直近ツイートを取得
         var ai = AccountStorage.GetRandom(i => i.IsFollowedBy(userViewModel.TwitterUser.NumericId), true);
         if (ai == null)
         {
             return;
         }
         var tl = ai.GetUserTimeline(userId: userViewModel.TwitterUser.NumericId, count: 50);
         if (tl == null)
         {
             return;
         }
         var checkresult = GetRules()
                           .Where(r => r.Check(userViewModel, tl)).ToArray();
         if (checkresult.Length > 0)
         {
             ShowR4SCandidateDialog(userViewModel, receiver, String.Join(", ", checkresult.Select(r => r.Description)));
         }
     }
     catch (Exception ex)
     {
         ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "MapleMagicでの照合に失敗しました。", () => CheckFollower(userViewModel, receiver));
     }
 }
예제 #7
0
        private void AddAccount()
        {
            var auth = new AuthenticateViewModel();
            var msg  = new TransitionMessage(auth, "ShowAuth");

            this.Messenger.Raise(msg);
            var ainfo = auth.GetAccountInfo();

            if (auth.Success && ainfo != null)
            {
                if (AccountStorage.Contains(ainfo.ScreenName))
                {
                    this.Messenger.Raise(new InformationMessage("アカウント @" + ainfo.ScreenName + " は既に存在します。", "アカウント追加エラー", System.Windows.MessageBoxImage.Error, "Information"));
                }
                else
                {
                    IsAccountModified = true;
                    ShowAccountConfig(ainfo);
                    AccountStorage.RegisterAccount(ainfo);
                    UserInformationManager.ReceiveInidividualInfo(ainfo);
                }
            }
        }
예제 #8
0
        public void SetInReplyTo(TweetViewModel tweet)
        {
            if (tweet == null)
            {
                // clear in reply to
                this.CurrentInputDescription.InReplyToId = 0;
            }
            else
            {
                // スクリーン名の取得
                var screen = tweet.Status.User.ScreenName;
                var sid    = tweet.Status.Id;
                var ts     = tweet.Status as TwitterStatus;
                if (!Setting.Instance.InputExperienceProperty.OfficialRetweetInReplyToRetweeter &&
                    ts != null && ts.RetweetedOriginal != null)
                {
                    screen = ts.RetweetedOriginal.User.ScreenName;
                    sid    = ts.RetweetedOriginal.Id;
                }
                if (this.CurrentInputDescription.InputText.StartsWith(".@"))
                {
                    // multi replication mode
                    string remain;
                    var    screens = SplitTweet(this.CurrentInputDescription.InputText, out remain);
                    if (screens.FirstOrDefault(s => s.Equals(screen, StringComparison.CurrentCultureIgnoreCase)) != null)
                    {
                        // 選択ユーザーのスクリーン名だけ抜く
                        this.CurrentInputDescription.InputText = "." +
                                                                 screens.Where(s => !s.Equals(screen, StringComparison.CurrentCultureIgnoreCase))
                                                                 .Select(s => "@" + s)
                                                                 .JoinString(" ") + " " +
                                                                 remain;
                    }
                    else
                    {
                        this.CurrentInputDescription.InputText = "." +
                                                                 screens.Select(s => "@" + s).JoinString(" ") + " " +
                                                                 "@" + screen + " " +
                                                                 remain;
                        this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length);
                    }
                    this.CurrentInputDescription.InReplyToId = 0;
                }
                else if (this.CurrentInputDescription.InReplyToId != 0 && this.CurrentInputDescription.InputText.StartsWith("@"))
                {
                    // single reply mode -> muliti reply mode
                    string remain;
                    var    screens = SplitTweet(this.CurrentInputDescription.InputText, out remain);
                    this.CurrentInputDescription.InputText = "." +
                                                             screens.Select(s => "@" + s).Concat(new[] { "@" + screen }).Distinct().JoinString(" ")
                                                             + " " + remain;
                    this.CurrentInputDescription.InReplyToId = 0;
                    this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length);
                    this.overrideTargets = null;
                }
                else
                {
                    // single reply mode
                    this.CurrentInputDescription.InReplyToId = sid;
                    if (tweet.Status is TwitterDirectMessage)
                    {
                        this.OverrideTarget(new[] { AccountStorage.Get(((TwitterDirectMessage)tweet.Status).Recipient.ScreenName) });
                        this.CurrentInputDescription.InputText = "d @" + screen + " ";
                        this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length);
                    }
                    else
                    {
                        var mentions = RegularExpressions.AtRegex.Matches(tweet.TweetText);
                        var sns = new[] { "@" + screen }.Concat(mentions.Cast <Match>().Select(m => m.Value))
                        .Distinct().Where(s => !AccountStorage.Contains(s)).ToArray();

                        /*
                         * if (tweet.Status is TwitterStatus && AccountStorage.Contains(((TwitterStatus)tweet.Status).InReplyToUserScreenName))
                         *  sns = sns.Except(new[] { "@" + ((TwitterStatus)tweet.Status).InReplyToUserScreenName }).ToArray();
                         */
                        if (sns.Length > 1)
                        {
                            this.CurrentInputDescription.InputText = sns.JoinString(" ") + " ";
                            this.SetInputCaretIndex(sns[0].Length + 1, sns.JoinString(" ").Length - sns[0].Length);
                        }
                        else
                        {
                            this.CurrentInputDescription.InputText = "@" + screen + " ";
                            this.SetInputCaretIndex(this.CurrentInputDescription.InputText.Length);
                        }
                        if (tweet.Status is TwitterStatus && AccountStorage.Contains(((TwitterStatus)tweet.Status).InReplyToUserScreenName))
                        {
                            var ainfo = AccountStorage.Get(((TwitterStatus)tweet.Status).InReplyToUserScreenName);
                            if (ainfo != null && Setting.Instance.InputExperienceProperty.FallbackBackTracking)
                            {
                                ainfo = FallbackBackTracking(ainfo);
                            }
                            this.OverrideTarget(new[] { ainfo });
                        }
                    }
                }
            }
        }
예제 #9
0
 private bool CanReportForSpam()
 {
     return(!AccountStorage.Contains(this.TargetUser.TwitterUser.ScreenName) ||
            Setting.Instance.TimelineExperienceProperty.CanBlockMyself);
 }
예제 #10
0
 public static bool IsMuted(TwitterUser user)
 {
     return(Setting.Instance.TimelineFilteringProperty.MuteBlockedUsers &&
            AccountStorage.Accounts.Any(a => a.IsBlocking(user.NumericId) &&
                                        !AccountStorage.Contains(user.ScreenName)));
 }