Ejemplo n.º 1
0
        /// <summary>
        /// Edits the <c>SocialGroup</c> and applies the given options
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="description"> Description of the group </param>
        /// <param name="access"> Access restrictions of the group determining who can see- or who can enter the group </param>
        /// <param name="settings"> Additional options that can be set  </param>
        public void Edit <TUser>(AuthenticatedSession <TUser> session, string description, Access access, Options settings) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("Group ID must not be zero");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/group.php?do=doedit",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "doedit"),
                new KeyValuePair <string, string>("groupid", ID.ToString()),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("url", "https://www.elitepvpers.com/forum/groups/" + ID.ToString() + "--.html"),
                new KeyValuePair <string, string>("socialgroupcategoryid", "1"),
                new KeyValuePair <string, string>("groupdescription", description),
                new KeyValuePair <string, string>("grouptype", access.ToString()),
                new KeyValuePair <string, string>("options[enable_group_albums]", settings.HasFlag(Options.EnableGroupAlbums) ? "1" : "0"),
                new KeyValuePair <string, string>("options[enable_group_messages]", settings.HasFlag(Options.EnableGroupMessages) ? "1" : "0"),
                new KeyValuePair <string, string>("options[owner_mod_queue]", settings.HasFlag(Options.ApproveGroupMessages) ? "1" : "0"),
                new KeyValuePair <string, string>("options[join_to_view]", settings.HasFlag(Options.JoinToView) ? "1" : "0"),
                new KeyValuePair <string, string>("options[only_owner_discussions]", settings.HasFlag(Options.OnlyOwnerDiscussions) ? "1" : "0"),
            });

            Description = description;
            AccessMode  = access;
            Settings    = settings;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a <c>SectionThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="section"> Section under which the <c>SectionThread</c> is listed </param>
        /// <param name="startPost"> Represents the content and title of the <c>SectionThread</c> </param>
        /// <param name="settings"> Additional options that can be set </param>
        /// <param name="closed"> If true, the thread state is closed meaning that no one (except the staff) can answer to this thread </param>
        /// <returns> Freshly created <c>SectionThread</c> </returns>
        public static SectionThread Create <TUser>(AuthenticatedSession <TUser> session, Section section, SectionPost startPost,
                                                   SectionPost.Settings settings = SectionPost.Settings.ParseUrl | SectionPost.Settings.ShowSignature,
                                                   bool closed = false)
            where TUser : User
        {
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/newthread.php?do=postthread&f=" + section.ID,
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("subject", String.IsNullOrEmpty(startPost.Title) ? "-" : startPost.Title),
                new KeyValuePair <string, string>("message", startPost.Content.ToString()),
                new KeyValuePair <string, string>("wysiwyg", "0"),
                new KeyValuePair <string, string>("taglist", String.Empty),
                new KeyValuePair <string, string>("iconid", "0"),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("f", section.ID.ToString()),
                new KeyValuePair <string, string>("do", "postthread"),
                new KeyValuePair <string, string>("posthash", "74532335f4d3a9f352db6af1b1c257f7"),
                new KeyValuePair <string, string>("poststarttime", "1389309192"),
                new KeyValuePair <string, string>("loggedinuser", session.User.ID.ToString()),
                new KeyValuePair <string, string>("sbutton", "Submit New Thread"),
                new KeyValuePair <string, string>("signature", settings.HasFlag(SectionPost.Settings.ShowSignature) ? "1" : "0"),
                new KeyValuePair <string, string>("parseurl", settings.HasFlag(SectionPost.Settings.ParseUrl) ? "1" : "0"),
                new KeyValuePair <string, string>("parseame", "1"),
                new KeyValuePair <string, string>("vbseo_retrtitle", "1"),
                new KeyValuePair <string, string>("vbseo_is_retrtitle", "1"),
                new KeyValuePair <string, string>("emailupdate", "9999"),
                new KeyValuePair <string, string>("polloptions", "4")
            });

            return(new SectionThread(0, section));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a <c>SocialGroupThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="socialGroup"> SocialGroup where to create the <c>SocialGroupThread</c></param>
        /// <param name="startPost"> Represents the content and title of the <c>SocialGroupThread</c> </param>
        /// <param name="settings"> Additional options that can be set </param>
        /// <returns> Freshly created <c>SocialGroupThread</c></returns>
        public static SocialGroupThread Create <TUser>(AuthenticatedSession <TUser> session, SocialGroup socialGroup, SocialGroupPost startPost,
                                                       Message.Settings settings = Message.Settings.ParseUrl)
            where TUser : User
        {
            session.ThrowIfInvalid();

            session.Post("http://www.elitepvpers.com/forum/group.php?do=message",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("subject", startPost.Title),
                new KeyValuePair <string, string>("message", startPost.Content.ToString()),
                new KeyValuePair <string, string>("wysiwyg", "0"),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "message"),
                new KeyValuePair <string, string>("gmid", String.Empty),
                new KeyValuePair <string, string>("posthash", String.Empty),
                new KeyValuePair <string, string>("loggedinuser", session.User.ID.ToString()),
                new KeyValuePair <string, string>("groupid", socialGroup.ID.ToString()),
                new KeyValuePair <string, string>("discussionid", String.Empty),
                new KeyValuePair <string, string>("sbutton", "Nachricht+speichern"),
                new KeyValuePair <string, string>("parseurl", settings.HasFlag(Message.Settings.ParseUrl) ? "1" : "0"),
                new KeyValuePair <string, string>("parseame", "1"),
            });

            var socialGroupThread = new SocialGroupThread(0, socialGroup)
            {
                Creator = session.User, Deleted = false
            };

            socialGroupThread.Posts.Insert(0, startPost);
            return(socialGroupThread);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deletes the <c>SocialGroup</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        public void Delete <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            if (session.User.GetHighestRank() < Usergroup.GlobalModerator && session.User != Maintainer)
            {
                throw new InsufficientAccessException("You don't have enough access rights to delete this group");
            }

            if (ID == 0)
            {
                throw new ArgumentException("Group ID must not be zero");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/group.php?do=delete",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("do", "dodelete"),
                new KeyValuePair <string, string>("groupid", ID.ToString()),
                new KeyValuePair <string, string>("pictureid", String.Empty),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("url", "https%3A%2F%2Fwww.elitepvpers.com%2Fforum%2Fgroups%2F" + ID.ToString() + "--.html"),
                new KeyValuePair <string, string>("confirm", "++Yes++")
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sends a <c>VisitorMessage</c> using the given session
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="settings"> Additional options that can be set </param>
        /// <remarks>
        /// The ID of the recipient has to be given in order to send the message
        /// </remarks>
        public void Send <TUser>(AuthenticatedSession <TUser> session, Settings settings = Settings.ParseUrl) where TUser : User
        {
            if (Receiver.ID == 0)
            {
                throw new ArgumentException("Receiver ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("http://www.elitepvpers.com/forum/visitormessage.php?do=message",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("ajax", "1"),
                new KeyValuePair <string, string>("wysiwyg", "0"),
                new KeyValuePair <string, string>("styleid", "0"),
                new KeyValuePair <string, string>("fromquickcomment", "1"),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "message"),
                new KeyValuePair <string, string>("u", Receiver.ID.ToString()),
                new KeyValuePair <string, string>("u2", String.Empty),
                new KeyValuePair <string, string>("loggedinuser", String.Empty),
                new KeyValuePair <string, string>("parseurl", (settings & Settings.ParseUrl).ToString()),
                new KeyValuePair <string, string>("lastcomment", "1381528657"),
                new KeyValuePair <string, string>("allow_ajax_qc", "1"),
                new KeyValuePair <string, string>("fromconverse", String.Empty),
                new KeyValuePair <string, string>("message", Content.Elements.ToString()),
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the <c>Treasure</c> and makes it public
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        public void Create <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            session.ThrowIfInvalid();
            if (Content.Length < 4)
            {
                throw new ArgumentException("The content is too short (4 characters minimum)");
            }
            if (Title.Length < 4)
            {
                throw new ArgumentException("The title is too short (4 characters minimum)");
            }
            if (Cost < 1)
            {
                throw new ArgumentException("The price is too low (at least 1 elite*gold)");
            }

            session.Post("http://www.elitepvpers.com/theblackmarket/treasures/",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("title", Title),
                new KeyValuePair <string, string>("content", Content),
                new KeyValuePair <string, string>("cost", Cost.ToString()),
                new KeyValuePair <string, string>("createtreasure", "Submit")
            });

            CreationDate = DateTime.Now;
            Seller       = session.User;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Deletes the <c>SectionThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="reason"> Reason for the deletion </param>
        /// <remarks>
        /// Not tested yet!
        /// </remarks>
        public void Delete <TUser>(AuthenticatedSession <TUser> session, string reason) where TUser : User
        {
            if (session.User.GetHighestRank() < Usergroup.GlobalModerator)
            {
                throw new InsufficientAccessException("You don't have enough access rights to delete this thread");
            }
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/postings.php",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("t", ID.ToString()),
                new KeyValuePair <string, string>("do", "dodeletethread"),
                new KeyValuePair <string, string>("deletetype", "1"),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("deletereason", reason),
            });

            Deleted = true;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a <c>SocialGroup</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="name"> Name of the group </param>
        /// <param name="description"> Description of the group </param>
        /// <param name="access"> Access restrictions of the group determining who can see- or who can enter the group </param>
        /// <param name="settings"> Additional options that can be set  </param>
        /// <returns> The just created SocialGroup </returns>
        public static SocialGroup Create <TUser>(AuthenticatedSession <TUser> session, string name, string description,
                                                 Access access    = Access.Public,
                                                 Options settings = Options.EnableGroupAlbums | Options.EnableGroupMessages)
            where TUser : User
        {
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/group.php?do=docreate",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "docreate"),
                new KeyValuePair <string, string>("groupid", String.Empty),
                new KeyValuePair <string, string>("url", "https%3A%2F%2Fwww.elitepvpers.com%2Fforum%2Fgroups%2F"),
                new KeyValuePair <string, string>("socialgroupcategoryid", "1"),
                new KeyValuePair <string, string>("groupname", name),
                new KeyValuePair <string, string>("groupdescription", description),
                new KeyValuePair <string, string>("grouptype", access.ToString()),
                new KeyValuePair <string, string>("options%5Benable_group_albums%5D", settings.HasFlag(Options.EnableGroupAlbums) ? "1" : "0"),
                new KeyValuePair <string, string>("options%5Benable_group_messages%5D", settings.HasFlag(Options.EnableGroupMessages) ? "1" : "0")
            });

            return(new SocialGroup(0));
        }
        /// <summary>
        /// Sends a <c>PrivateMessage</c> using the given session
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="settings"> Additional options that can be set </param>
        /// <remarks>
        /// The names of the recipients have to be given in order to send the message.
        /// Messages with a blank title will not be send. Therefore, '-' will be used as title if nothing was specified.
        /// Certain requirements must be fulfilled in order to send messages automatically without entering a captcha:
        /// - More than 20 posts OR the <c>User.Usergroup.Premium</c> rank OR the <c>User.Usergroup.EliteGoldTrader</c> rank
        /// </remarks>
        public void Send <TUser>(AuthenticatedSession <TUser> session, Settings settings = Settings.ParseUrl | Settings.ShowSignature) where TUser : User
        {
            session.ThrowIfInvalid();
            if (session.User.Posts <= 20 && !session.User.HasRank(Usergroup.Premium) && !session.User.HasRank(Usergroup.EliteGoldTrader))
            {
                throw new InsufficientAccessException("More than 20 posts or the premium / elite*gold trader badge is required for sending private messages without captchas");
            }

            foreach (var splittedRecipientList in Recipients.Split(5))
            {
                var recipients = String.Join(";", splittedRecipientList.Select(recipient => recipient.Name));

                session.Post("https://www.elitepvpers.com/forum/private.php?do=insertpm&pmid=",
                             new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("recipients", recipients),
                    new KeyValuePair <string, string>("bccrecipients", String.Empty),
                    new KeyValuePair <string, string>("title", String.IsNullOrEmpty(Title) ? "-" : Title),
                    new KeyValuePair <string, string>("message", Content.ToString()),
                    new KeyValuePair <string, string>("wysiwyg", "0"),
                    new KeyValuePair <string, string>("iconid", "0"),
                    new KeyValuePair <string, string>("s", String.Empty),
                    new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                    new KeyValuePair <string, string>("do", "insertpm"),
                    new KeyValuePair <string, string>("pmid", String.Empty),
                    new KeyValuePair <string, string>("forward", String.Empty),
                    new KeyValuePair <string, string>("sbutton", "submit"),
                    new KeyValuePair <string, string>("savecopy", settings.HasFlag(Settings.SaveCopy) ? "1" : "0"),
                    new KeyValuePair <string, string>("signature", settings.HasFlag(Settings.ShowSignature) ? "1" : "0"),
                    new KeyValuePair <string, string>("parseurl", settings.HasFlag(Settings.ParseUrl) ? "1" : "0")
                });
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Deletes the <c>SocialGroupThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="reason"> Reason for the deletion </param>
        public void Delete <TUser>(AuthenticatedSession <TUser> session, string reason) where TUser : User
        {
            if (session.User.GetHighestRank() < Usergroup.GlobalModerator && session.User != SocialGroup.Maintainer)
            {
                throw new InsufficientAccessException("You don't have enough access rights to delete this social group post");
            }
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("http://www.elitepvpers.com/forum/group_inlinemod.php?gmids=",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("groupid", SocialGroup.ID.ToString()),
                new KeyValuePair <string, string>("messageids", ID.ToString()),
                new KeyValuePair <string, string>("do", "doinlinedelete"),
                new KeyValuePair <string, string>("url", "http://www.elitepvpers.com/forum/groups/" + SocialGroup.ID.ToString() + "--.html"),
                new KeyValuePair <string, string>("inline_discussion", "1"),
                new KeyValuePair <string, string>("deletetype", "1"),
                new KeyValuePair <string, string>("deletereason", reason)
            });
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Sets the Secret word
        /// </summary>
        /// <param name="session">Session used for sending the request</param>
        /// <param name="newSecretWord"> The new secret word that will be set </param>
        public void SetSecretWord(AuthenticatedSession <TUser> session, string newSecretWord)
        {
            session.ThrowIfInvalid();

            session.Post("http://www.elitepvpers.com/theblackmarket/api/secretword/",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("secretword", newSecretWord)
            });
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the current Secret word
        /// </summary>
        /// <param name="session">Session used for sending the request</param>
        /// <returns> Current Secret word as string </returns>
        public string GetSecretWord(AuthenticatedSession <TUser> session)
        {
            session.ThrowIfInvalid();

            var res = session.Get("http://www.elitepvpers.com/theblackmarket/api/secretword/");
            var doc = new HtmlDocument();

            doc.LoadHtml(res);

            return(doc.DocumentNode.Descendants().GetElementsByNameXHtml("secretword").FirstOrDefault().Attributes["value"].Value);
        }
Ejemplo n.º 13
0
            /// <summary>
            /// Sends a message to the channel
            /// </summary>
            /// <param name="session"> Session used for sending the request </param>
            /// <param name="message"> The message text to send </param>
            public void Send <TUser>(AuthenticatedSession <TUser> session, string message) where TUser : User
            {
                session.ThrowIfInvalid();

                session.Post("http://www.elitepvpers.com/forum/mgc_cb_evo_ajax.php",
                             new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("do", "ajax_chat"),
                    new KeyValuePair <string, string>("channel_id", ID.ToString()),
                    new KeyValuePair <string, string>("chat", message),
                    new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                    new KeyValuePair <string, string>("s", String.Empty)
                });
            }
Ejemplo n.º 14
0
        /// <summary>
        /// Updates the user by requesting the profile
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        public void Update <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("User ID must not be 0");
            }
            session.ThrowIfInvalid();
            var res = session.Get(GetUrl());

            var doc = new HtmlDocument();

            doc.LoadHtml(res);
            new UserParser(this, (this == session.User)).Execute(doc);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Deletes the <c>Treasure</c> permanently
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        public void Delete <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            session.ThrowIfInvalid();
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be zero");
            }

            session.Post(GetUrl(),
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("deletetreasure", "1")
            });
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Report the private message
        /// </summary>
        /// <param name="session"> The session which will be used for the report </param>
        /// <param name="reason"> The resion for the report </param>
        public void Report <TUser>(AuthenticatedSession <TUser> session, string reason) where TUser : User
        {
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/private.php?do=sendemail",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("reason", reason),
                new KeyValuePair <string, string>("pmid", ID.ToString()),
                new KeyValuePair <string, string>("do", "sendemail"),
                new KeyValuePair <string, string>("url", "https://www.elitepvpers.com/forum/private.php?do=showpm&pmid=" + ID.ToString())
            });
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Retrieves information about the messages such as title, content and sender
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        public void Update <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            session.ThrowIfInvalid();
            if (ID == 0)
            {
                throw new System.ArgumentException("ID must not be emtpy");
            }

            var res = session.Get("https://www.elitepvpers.com/forum/private.php?do=showpm&pmid=" + ID.ToString());
            var doc = new HtmlDocument();

            doc.LoadHtml(res);

            new PrivateMessageParser.SenderParser(Sender).Execute(doc.GetElementbyId("post"));
            new PrivateMessageParser.ContentParser(this).Execute(doc.GetElementbyId("td_post_"));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Retrieves all open <c>Trades</c>s that are requested or received using the logged-in user account
        /// </summary>
        /// <param name="session">Session used for sending the request</param>
        /// <param name="queryStatus">
        /// Type of <c>Trade</c> to query. Either <c>Trade.Query.Received</c>
        /// for querying open trades that have been received or <c>Treasure.Query.Requested</c>
        /// for open trades that have been requested</param>
        /// <param name="pageCount"> Amount of pages to retrieve, one page may contain up to 15 trades </param>
        /// <param name="startIndex"> Index of the first page to request (1 for the first page, 2 for the second, ...) </param>
        /// <returns> List of all <c>Trades</c>s that could be retrieved </returns>
        public List <Trade> GetTrades(AuthenticatedSession <TUser> session, Trade.Query queryStatus /* = Trade.Query.Received*/, uint pageCount = 1, uint startIndex = 1)
        {
            session.ThrowIfInvalid();

            var listedTrades = new List <Trade>();

            for (var i = startIndex; i < (startIndex + pageCount); ++i)
            {
                var res = "";
                switch (queryStatus)
                {
                case Trade.Query.Received:
                    res = session.Get("https://www.elitepvpers.com/theblackmarket/trades/received/" + i);
                    break;

                case Trade.Query.Requested:
                    res = session.Get("https://www.elitepvpers.com/theblackmarket/trades/requested/" + i);
                    break;
                }

                var htmlDocument = new HtmlDocument();
                htmlDocument.LoadHtml(res);

                var rootFormNode = htmlDocument.GetElementbyId("contentbg");
                if (rootFormNode == null)
                {
                    continue;
                }

                var tableNode = rootFormNode.SelectSingleNode("table[1]/tr[1]/td[1]/table[1]/tr[2]/td[1]/div[1]/div[3]/table[1]");
                if (tableNode == null)
                {
                    continue;
                }

                // skip the first <tr> element since that is the table header
                foreach (var tradeListingNode in tableNode.ChildNodes.GetElementsByTagName("tr").Skip(1))
                {
                    var idNode = tradeListingNode.SelectSingleNode("td[1]");
                    var trade  = Trade.fromId(session, (idNode != null) ? idNode.InnerText.TrimStart('#').To <int>() : 0);

                    listedTrades.Add(trade);
                }
            }

            return(listedTrades);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Retrieves a list of all posts in the <c>SectionThread</c>
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        /// <param name="firstPage"> Index of the first page to fetch </param>
        /// <param name="pageCount"> Amount of pages to get replies from. The higher this count, the more data will be generated and received </param>
        /// <returns> List of <c>SectionPost</c>s representing the replies </returns>
        public List <SectionPost> Replies <TUser>(AuthenticatedSession <TUser> session, uint pageCount, uint firstPage) where TUser : User
        {
            session.ThrowIfInvalid();
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be empty");
            }

            var retrievedReplies = new List <SectionPost>();

            for (uint i = firstPage; i < (firstPage + pageCount); ++i)
            {
                var res          = session.Get(GetUrl(i));
                var htmlDocument = new HtmlDocument();
                htmlDocument.LoadHtml(res);

                var postsRootNode = htmlDocument.GetElementbyId("posts");
                if (postsRootNode == null)
                {
                    continue;
                }

                // for some reason, the lastpost container contains nothing and needs to be filtered out
                foreach (var postContainerNode in postsRootNode.ChildNodes.GetElementsByTagName("div").Where(element => element.Id != "lastpost"))
                {
                    // skip deleted posts, parsing them doesn't work (yet)
                    if (postContainerNode.SelectSingleNode("div[1]/div[1]/div[1]/table[1]/tr[1]/td[1]/a[1]/img[1]") == null)
                    {
                        continue;
                    }

                    var parsedPost = new SectionPost(0, this);
                    new SectionPostParser(parsedPost).Execute(postContainerNode);
                    retrievedReplies.Add(parsedPost);
                }

                // store the starting post and
                // remove it after storing since it is no reply
                if (i == 1 && retrievedReplies.Count != 0)
                {
                    InitialPost = retrievedReplies.First();
                    retrievedReplies.Remove(retrievedReplies.First());
                }
            }

            return(retrievedReplies);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Reports the <c>SectionPost</c> using the built-in report function
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="reason"> Reason of the report </param>
        /// <remarks>
        /// The ID of the <c>SectionPost</c> has to be given in order to report the post
        /// </remarks>
        public void Report <TUser>(AuthenticatedSession <TUser> session, string reason) where TUser : User
        {
            if (ID == 0)
            {
                throw new System.ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/report.php?do=sendemail",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("reason", reason),
                new KeyValuePair <string, string>("postid", ID.ToString()),
                new KeyValuePair <string, string>("do", "sendemail"),
                new KeyValuePair <string, string>("url", "showthread.php?p=" + ID.ToString() + "#post" + ID.ToString())
            });
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Cancels a pending invite to the <c>SocialGroup</c> for another user
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="user"> User whose invite will be cancelled </param>
        public void CancelInvite <TUser>(AuthenticatedSession <TUser> session, User user) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("Group ID must not be zero");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/group.php?do=pendingmembers",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("do", "cancelinvites"),
                new KeyValuePair <string, string>("groupid", ID.ToString()),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("ids[" + user.ID.ToString() + "]", user.ID.ToString())
            });
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Requests a ownership transfer for the <c>SocialGroup</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="user"> User that will be requested to be the new owner </param>
        public void RequestTransfer <TUser>(AuthenticatedSession <TUser> session, User user) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("Group ID must not be zero");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/group.php?do=dotransfer&groupid=" + ID.ToString(),
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("do", "dotransfer"),
                new KeyValuePair <string, string>("groupid", ID.ToString()),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("url", String.Empty),
                new KeyValuePair <string, string>("targetusername", user.Name),
            });
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Accepts a pending ownership transfer if any for the <c>SocialGroup</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        public void AcceptTransfer <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("Group ID must not be zero");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/groups/" + ID.ToString() + "--.html",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("do", "doaccepttransfer"),
                new KeyValuePair <string, string>("groupid", ID.ToString()),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("url", "https://www.elitepvpers.com/forum/private.php?do=showpm&pmid=99999999"),
                new KeyValuePair <string, string>("confirm", "Yes"),
            });
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Leaves the <c>SocialGroup</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        public void Leave <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("Group ID must not be zero");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/group.php?do=doleave",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("do", "doleave"),
                new KeyValuePair <string, string>("groupid", ID.ToString()),
                new KeyValuePair <string, string>("pictureid", String.Empty),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("url", "http%3A%2F%2Fwww.elitepvpers.com%2Fforum%2Fgroups%2F" + ID.ToString() + "--.hml"),
                new KeyValuePair <string, string>("confirm", "++Yes++")
            });
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Rates a <c>SectionThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="rating"> Represents the rate value (0-5) </param>
        public void Rate <TUser>(AuthenticatedSession <TUser> session, uint rating) where TUser : User
        {
            if (ID == 0)
            {
                throw new System.ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/threadrate.php",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("ajax", "1"),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("vote", rating.ToString()),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("t", ID.ToString()),
                new KeyValuePair <string, string>("pp", "10"),
                new KeyValuePair <string, string>("page", "1")
            });
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Opens or closes the <c>SectionThread</c>, depends on the current status.
        /// If the thread is opened, it will be closed. If it is closed, it will be opened
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        public void ToggleStatus <TUser>(AuthenticatedSession <TUser> session) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/postings.php",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("t", ID.ToString()),
                new KeyValuePair <string, string>("do", "openclosethread"),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("pollid", String.Empty),
            });

            Closed = true;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Deletes the <c>SectionPost</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="reason"> Reason for the deletion </param>
        /// <remarks>
        /// Not tested yet!
        /// </remarks>
        public void Delete <TUser>(AuthenticatedSession <TUser> session, string reason) where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/editpost.php",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("do", "deletepost"),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("postid", ID.ToString()),
                new KeyValuePair <string, string>("deletepost", "delete"),
                new KeyValuePair <string, string>("reason", reason),
            });

            Deleted = true;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Performs an user lookup request and searches for users with the specified name
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        /// <param name="name"> User name to search for </param>
        /// <returns> List of <c>User</c>s that were found </returns>
        public static IEnumerable <User> Search <TUser>(AuthenticatedSession <TUser> session, string name) where TUser : User
        {
            session.ThrowIfInvalid();
            var res = session.Post("http://www.elitepvpers.com/forum/ajax.php?do=usersearch",
                                   new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "usersearch"),
                new KeyValuePair <string, string>("fragment", name)
            });

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(res);
            var rootNode = htmlDocument.DocumentNode.SelectSingleNode("users");

            return((rootNode != null)
                    ? (from userNode in rootNode.ChildNodes.GetElementsByTagName("user")
                       where userNode.Attributes.Contains("userid")
                       select new User(userNode.InnerText, userNode.Attributes["userid"].Value.To <int>())).ToList()
                    : new List <User>());
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Replies to the <c>SocialGroupThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="settings"> Additional options that can be set </param>
        /// <param name="post"> Reply to post </param>
        public void Reply <TUser>(AuthenticatedSession <TUser> session, SocialGroupPost post, Message.Settings settings = Message.Settings.ParseUrl) where TUser : User
        {
            session.ThrowIfInvalid();

            session.Post("http://www.elitepvpers.com/forum/group.php?do=message",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("message", post.Content.ToString()),
                new KeyValuePair <string, string>("wysiwyg", "0"),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "message"),
                new KeyValuePair <string, string>("gmid", String.Empty),
                new KeyValuePair <string, string>("posthash", String.Empty),
                new KeyValuePair <string, string>("loggedinuser", session.User.ID.ToString()),
                new KeyValuePair <string, string>("groupid", SocialGroup.ID.ToString()),
                new KeyValuePair <string, string>("discussionid", ID.ToString()),
                new KeyValuePair <string, string>("sbutton", "Post+Message"),
                new KeyValuePair <string, string>("parseurl", (settings & Message.Settings.ParseUrl).ToString()),
                new KeyValuePair <string, string>("parseame", "1"),
            });
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Replies to the <c>SectionThread</c>
        /// </summary>
        /// <param name="session"> Session that is used for sending the request </param>
        /// <param name="post"> Reply to post </param>
        /// <param name="settings"> Additional options that can be set </param>
        /// <remarks>
        /// The ID of the thread has to be given in order to reply
        /// </remarks>
        public void Reply <TUser>(AuthenticatedSession <TUser> session, SectionPost post,
                                  SectionPost.Settings settings = SectionPost.Settings.ParseUrl | SectionPost.Settings.ShowSignature)
            where TUser : User
        {
            if (ID == 0)
            {
                throw new ArgumentException("ID must not be empty");
            }
            session.ThrowIfInvalid();

            session.Post("https://www.elitepvpers.com/forum/newreply.php?do=postreply&t=" + ID,
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("title", String.IsNullOrEmpty(post.Title) ? "-" : post.Title),
                new KeyValuePair <string, string>("message", post.Content.ToString()),
                new KeyValuePair <string, string>("wysiwyg", "0"),
                new KeyValuePair <string, string>("iconid", post.Icon.ToString()),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                new KeyValuePair <string, string>("do", "postreply"),
                new KeyValuePair <string, string>("t", ID.ToString()),
                new KeyValuePair <string, string>("p", String.Empty),
                new KeyValuePair <string, string>("specifiedpost", "0"),
                new KeyValuePair <string, string>("posthash", "6fd3840e9b2ed6a8dcc9d9d0432abb14"),
                new KeyValuePair <string, string>("poststarttime", String.Empty),
                new KeyValuePair <string, string>("loggedinuser", session.User.ID.ToString()),
                new KeyValuePair <string, string>("multiquoteempty", String.Empty),
                new KeyValuePair <string, string>("sbutton", "Submit Reply"),
                new KeyValuePair <string, string>("signature", settings.HasFlag(SectionPost.Settings.ShowSignature) ? "1" : "0"),
                new KeyValuePair <string, string>("parseurl", settings.HasFlag(SectionPost.Settings.ParseUrl) ? "1" : "0"),
                new KeyValuePair <string, string>("parseame", "1"),
                new KeyValuePair <string, string>("vbseo_retrtitle", "1"),
                new KeyValuePair <string, string>("vbseo_is_retrtitle", "1"),
                new KeyValuePair <string, string>("emailupdate", "9999"),
                new KeyValuePair <string, string>("rating", "0"),
                new KeyValuePair <string, string>("openclose", "0")
            });
        }