Пример #1
0
 /// <summary>
 ///   Explicitly test to see if a user is shadow-banned,
 ///   which means the user is a known spammer.
 /// </summary>
 /// <remarks>
 ///   <para>
 ///     This is done by HTTP GET on /user/Foo . If that link returns a
 ///     404, then the user is shadow-banned.
 ///   </para>
 /// </remarks>
 public bool IsUserDead(string username)
 {
     if (!checkedUserCache.ContainsKey(username))
     {
         Data.Listing list = mGetUserRecentPosts(username);
         checkedUserCache[username] = (list != null && list.error != null);
     }
     return(checkedUserCache[username]);
 }
Пример #2
0
        /// <summary>
        ///   Report a user as a spammer, maybe.
        /// </summary>
        /// <remarks>
        ///   <para>
        ///     This method submits a user to /r/reportthespammers, maybe.
        ///   </para>
        ///   <para>
        ///     The method first queries the user. If the user is
        ///     already shadow-banned, this method does nothing further,
        ///     and returns.
        ///   </para>
        ///   <para>
        ///     If the user has an age of over 15 days, and has posted more than 3 items,
        //      and has a link karma below 20, then the account gets
        //      reported as a spammer.
        ///   </para>
        /// </remarks>
        public void MaybeReportUserAsSpammer(string username)
        {
            if (GetDeadUsers().Contains(username))
            {
                return;
            }

            Data.Listing list = mGetUserRecentPosts(username);
            if (list == null || list.error != null)
            {
                return;
            }

            Data.Account acct = mGetAccount(username);
            if (acct == null || acct.data == null)
            {
                return;
            }

            // report as spammer if....
            // .... account is older than 15 days
            // .... has link karma less than 20
            // .... has posted more than 3 items
            // .... has not been reported already
            var age = DateTime.Now - acct.data.createdTime;

            if (age > fifteenDays &&
                //!acct.data.is_mod &&
                acct.data.link_karma < 20 &&
                list.data.children.Count(x => x.kind.Equals("t3")) > 3 &&
                !reportedUsers.Contains(username) &&
                (!checkedUserCache.ContainsKey(username) ||
                 !checkedUserCache[username]))
            {
                ReportUserAsSpammer(username);
                reportedUsers.Add(username);
                if (ExternalDeadList != null)
                {
                    if (!ExternalDeadList.Contains(username))
                    {
                        ExternalDeadList.Add(username);
                    }
                }
                checkedUserCache[username] = true; // dead
            }
        }