Exemple #1
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));
        }
Exemple #2
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;
        }
        /// <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++")
            });
        }
Exemple #4
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)
            });
        }
Exemple #5
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);
        }
        /// <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));
        }
Exemple #7
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;
        }
        /// <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")
                });
            }
        }
        /// <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;
        }
Exemple #10
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()),
            });
        }
Exemple #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)
            });
        }
Exemple #12
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")
            });
        }
Exemple #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)
                });
            }
        /// <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())
            });
        }
Exemple #15
0
        /// <summary>
        /// Logs in the user
        /// </summary>
        /// <param name="session">Session used for sending the request</param>
        /// <param name="md5Password"> Hashed (MD5) password of the session user </param>
        /// <remarks>
        /// In order for this function to work, either the real username or the e-mail address has to be set in the <c>User</c> property
        /// </remarks>
        public void Login(AuthenticatedSession <TUser> session, string md5Password)
        {
            session.Post("http://www.elitepvpers.com/forum/login.php?do=login&langid=1",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("vb_login_username", User.Name),
                new KeyValuePair <string, string>("cookieuser", "1"),
                new KeyValuePair <string, string>("s", String.Empty),
                new KeyValuePair <string, string>("securitytoken", "guest"),
                new KeyValuePair <string, string>("do", "login"),
                new KeyValuePair <string, string>("vb_login_md5password", md5Password),
                new KeyValuePair <string, string>("vb_login_md5password_utf", md5Password)
            });

            session.Update();
        }
        /// <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())
            });
        }
Exemple #17
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())
            });
        }
        /// <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"),
            });
        }
        /// <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),
            });
        }
        /// <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++")
            });
        }
Exemple #21
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;
        }
Exemple #22
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")
            });
        }
Exemple #23
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;
        }
Exemple #24
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>());
        }
Exemple #25
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"),
            });
        }
Exemple #26
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")
            });
        }
        /// <summary>
        /// Publishes the <c>Blog.Entry</c> in the logged-in user's blog at the given time (automatically)
        /// </summary>
        /// <param name="session"> Session used for sending the request </param>
        /// <param name="publishDate"> Date and time when the entry will go live </param>
        /// <param name="settings"> Additional options that can be set </param>
        public void Publish <TUser>(AuthenticatedSession <TUser> session, DateTime publishDate, Settings settings = Settings.ParseUrl | Settings.AllowComments)
            where TUser : User
        {
            session.ThrowIfInvalid();

            Date = publishDate;
            var tags = Tags.Aggregate("", (current, tag) => current + (tag + (Tags.Last() != tag ? "," : "")));

            session.Post("https://www.elitepvpers.com/forum/blog_post.php?do=updateblog&blogid=",
                         new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("title", Title),
                new KeyValuePair <string, string>("message", 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", "updateblog"),
                new KeyValuePair <string, string>("b", String.Empty),
                new KeyValuePair <string, string>("posthash", String.Empty),
                new KeyValuePair <string, string>("poststarttime", Extensions.UnixTimestamp().ToString()),
                new KeyValuePair <string, string>("loggedinuser", session.User.ID.ToString()),
                new KeyValuePair <string, string>("u", String.Empty),
                new KeyValuePair <string, string>("taglist", tags),
                new KeyValuePair <string, string>("allowcomments", Convert.ToUInt32(settings.HasFlag(Settings.AllowComments)).ToString()),
                new KeyValuePair <string, string>("moderatecomments", Convert.ToUInt32(settings.HasFlag(Settings.ModerateComments)).ToString()),
                new KeyValuePair <string, string>("private", Convert.ToUInt32(settings.HasFlag(Settings.Private)).ToString()),
                new KeyValuePair <string, string>("status", (publishDate.Compare(DateTime.Now)) ? "publish_now" : "publish_on"),
                new KeyValuePair <string, string>("publish[month]", Date.Month.ToString()),
                new KeyValuePair <string, string>("publish[day]", Date.Day.ToString()),
                new KeyValuePair <string, string>("publish[year]", Date.Year.ToString()),
                new KeyValuePair <string, string>("publish[hour]", Date.Hour.ToString()),
                new KeyValuePair <string, string>("publish[minute]", Date.Minute.ToString()),
                new KeyValuePair <string, string>("parseurl", Convert.ToUInt32(settings.HasFlag(Settings.ParseUrl)).ToString()),
                new KeyValuePair <string, string>("parseame", "1"),
                new KeyValuePair <string, string>("emailupdate", "none"),
                new KeyValuePair <string, string>("sbutton", "Submit")
            });
        }
Exemple #28
0
            /// <summary>
            /// Updates the most recent shouts usually displayed when loading the main page
            /// </summary>
            /// <param name="session"> Session used for sending the request </param>
            public List <Shout> Shouts <TUser>(AuthenticatedSession <TUser> session) where TUser : User
            {
                session.ThrowIfInvalid();

                var res = session.Post("http://www.elitepvpers.com/forum/mgc_cb_evo_ajax.php",
                                       new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("do", "ajax_refresh_chat"),
                    new KeyValuePair <string, string>("status", "open"),
                    new KeyValuePair <string, string>("channel_id", ID.ToString()),
                    new KeyValuePair <string, string>("location", "inc"),
                    new KeyValuePair <string, string>("first_load", "0"),
                    new KeyValuePair <string, string>("securitytoken", session.SecurityToken),
                    new KeyValuePair <string, string>("securitytoken", session.SecurityToken),                            // for some reason, the security token is send twice
                    new KeyValuePair <string, string>("s", String.Empty),
                });

                var shouts = new List <Shout>();

                try
                {
                    var doc = new HtmlDocument();
                    doc.LoadHtml(res);

                    // every shoutbox entry got 3 td nodes. One for the time, one for the username and one for the actual messages
                    // the target nodes are identified by their unique valign: top attribute
                    var tdNodes       = new List <HtmlNode>(doc.DocumentNode.Descendants("td"));
                    var shoutboxNodes = new List <HtmlNode>(tdNodes.Where(node => node.Attributes.Any(attribute => attribute.Name == "valign" && attribute.Value == "top")));

                    var shoutboxNodeGroups = shoutboxNodes.Split(3);
                    foreach (var shoutboxNodeGroup in shoutboxNodeGroups)
                    {
                        if (shoutboxNodeGroup.Count != 3)
                        {
                            continue;                               // every node group needs to have exactly 3 nodes in order to be valid
                        }
                        var parsedShout = new Shout();

                        var time     = new DateTime();
                        var timeNode = shoutboxNodeGroup.ElementAt(0).SelectSingleNode(@"span[1]/span[1]");

                        if (timeNode != null)
                        {
                            Match  match       = new Regex(@"\s*(\S+)&nbsp;").Match(timeNode.InnerText);
                            string matchedTime = match.Groups.Count > 1 ? match.Groups[1].Value : String.Empty;
                            DateTime.TryParse(matchedTime, out time);
                        }

                        parsedShout.Date = time;

                        var userNameNode = shoutboxNodeGroup.ElementAt(1).SelectSingleNode(@"span[1]/a[1]/span[1]") ??
                                           shoutboxNodeGroup.ElementAt(1).SelectSingleNode(@"span[1]/a[1]"); // users with black names do not have the span element

                        if (userNameNode == null)
                        {
                            continue;
                        }
                        parsedShout.Sender.Name = userNameNode.InnerText;
                        new UserParser.NamecolorParser(parsedShout.Sender).Execute(userNameNode);

                        var userLinkNode = shoutboxNodeGroup.ElementAt(1).SelectSingleNode(@"span[1]/a[1]");
                        parsedShout.Sender.ID = (userLinkNode != null) ? userLinkNode.Attributes.Contains("href") ? User.FromUrl(userLinkNode.Attributes["href"].Value) : 0 : 0;

                        var messageNode = shoutboxNodeGroup.ElementAt(2).SelectSingleNode(@"span[1]");
                        // strip the leading and trailing whitespaces of every shout
                        messageNode.InnerHtml = messageNode.InnerHtml.Strip();

                        new ContentParser(parsedShout.Content.Elements).Execute(messageNode);

                        shouts.Add(parsedShout);
                    }
                }
                catch (HtmlWebException exception)
                {
                    throw new ParsingFailedException("Parsing recent shouts from response content failed", exception);
                }

                return(shouts);
            }