Exemplo n.º 1
0
        public void AddModerator(RedditUser user)
        {
            var request = WebAgent.CreatePost(AddModeratorUrl);

            WebAgent.WritePostBody(request.GetRequestStream(), new
            {
                api_type = "json",
                uh       = Reddit.User.Modhash,
                r        = Name,
                type     = "moderator",
                name     = user.Name
            });
            var response = request.GetResponse();
            var result   = WebAgent.GetResponseString(response.GetResponseStream());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Revoke an outstanding contributor invite.
        /// </summary>
        /// <param name="user">reddit user.</param>
        public async Task <bool> RevokeContributorInviteAsync(RedditUser user)
        {
            var request = WebAgent.CreateRequest(RevokeContributorInviteUrl, "POST");

            WebAgent.WritePostBody(request, new
            {
                api_type = "json",
                id       = RedditUser.KindPrefix + user.Id
            });
            var response = await WebAgent.GetResponseAsync(request).ConfigureAwait(false);

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Revoke an outstanding contributor invite.
        /// </summary>
        /// <param name="name">reddit username</param>
        public void RevokeContributorInvite(RedditUser user)
        {
            if (Reddit.User == null)
            {
                throw new AuthenticationException("No user logged in.");
            }

            var request = WebAgent.CreatePost(String.Format(RevokeContributorInviteUrl, Name));
            var stream  = request.GetRequestStream();

            WebAgent.WritePostBody(stream, new
            {
                api_type = "json",
                id       = user.Kind + "_" + user.Id,
                uh       = Reddit.User.Modhash
            });
            stream.Close();
            var response = request.GetResponse();
            var data     = WebAgent.GetResponseString(response.GetResponseStream());
        }
Exemplo n.º 4
0
 private void CommonInit(Reddit reddit, JToken json, IWebAgent webAgent)
 {
     base.Init(json);
     Author = new RedditUser().Init(reddit, json["author"], webAgent);
 }
Exemplo n.º 5
0
 /// <inheritdoc />
 protected internal WikiPageRevision(IWebAgent agent, JToken json) : base(agent, json)
 {
     Author = new RedditUser(agent, json["author"]);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Set permissions on a contributor who has been invited but has not accepted.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="permissions">Permissions to set.</param>
 public void SetInvitedContributorPermissions(RedditUser user, LiveUpdateEventPermission permissions)
 {
     SetInvitedContributorPermissions(user.Name, permissions);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Set permissions on a contributor who has been invited but has not accepted.
 /// </summary>
 /// <param name="user"></param>
 /// <param name="permissions">Permissions to set.</param>
 public async Task <bool> SetInvitedContributorPermissionsAsync(RedditUser user, LiveUpdateEventPermission permissions)
 {
     return(await SetInvitedContributorPermissionsAsync(user.Name, permissions).ConfigureAwait(false));
 }
Exemplo n.º 8
0
        /// <summary>
        /// Revoke an outstanding contributor invite.
        /// </summary>
        /// <param name="name">reddit username</param>
        public async Task <bool> RevokeContributorInviteAsync(string name)
        {
            var redditUser = await RedditUser.GetUserAsync(WebAgent, name);

            return(await RevokeContributorInviteAsync(redditUser).ConfigureAwait(false));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Remove a contributor from the live thread.
        /// </summary>
        /// <param name="userName">reddit username.</param>
        public async Task <bool> RemoveContributorAsync(string userName)
        {
            var redditUser = await RedditUser.GetUserAsync(WebAgent, userName);

            return(await RemoveContributorAsync(redditUser).ConfigureAwait(false));
        }
Exemplo n.º 10
0
 private void CommonInit(Reddit reddit, JToken json, IWebAgent webAgent)
 {
     base.Init(json);
     Author = new RedditUser().Init(reddit, json["author"], webAgent);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Author of the item against which this moderation action was performed.
 /// </summary>
 //TODO discuss
 public Task <RedditUser> GetTargetAuthorAsync() =>
 RedditUser.GetUserAsync(WebAgent, TargetAuthorName);
Exemplo n.º 12
0
        public static List <ArchiveLink> ArchivePostLinks(List <string> FoundLinks, Regex[] exclusions, RedditSharp.Things.RedditUser user)
        {
            List <ArchiveLink> ArchivedLinks = new List <ArchiveLink>();

            for (int i = 0, i2 = 1; i < FoundLinks.Count && i2 <= FoundLinks.Count; i++, i2++)
            {
                string link = FoundLinks[i];
                ArchivedLinks.Add(new ArchiveLink(link, i2));
                new RedditUserProfileSqlite(user).AddUrlUsed(link);
                if (exclusions.Sum(a => a.IsMatch(link) ? 1 : 0) != 0)
                {
                    ArchiveLink link2 = ArchivedLinks[ArchivedLinks.Count - 1];
                    link2.IsExcluded = true;
                    ArchivedLinks[ArchivedLinks.Count - 1] = link2;
                    i--;
                }
            }
            for (int i = 0; i < ArchivedLinks.Count; i++)
            {
                if (ArchivedLinks[i].IsExcluded)
                {
                    continue;
                }
                string link  = ArchivedLinks[i].OriginalLink;
                string check = service.Save(link);
                for (int i2 = 0; i2 < 10 && !service.Verify(check); check = service.Save(check), i2++)
                {
                    System.Threading.Thread.Sleep(5000);
                }
                ArchiveLink l = ArchivedLinks[i];
                l.SetArchivedLink(check);
                ArchivedLinks[i] = l;
            }
            ArchivedLinks.Sort();
            return(ArchivedLinks);
        }