コード例 #1
0
ファイル: Bot.cs プロジェクト: windykiss/SteamGrouper
 public static void DoInvite(StreamReader file, ulong currentSID, string groupID, string group, TextBox text_log, Label label_invite)
 {
     InviteToGroup(currentSID, groupID, group, text_log, label_invite);
     if (!Interface.MinMax)
     {
         Interface.AppendText(text_log, "\r\nWaiting " + Interface.inviteSpeed + " seconds...\n");
         for (int count = Interface.inviteSpeed; count > 0; --count)
         {
             Interface.UpdateLabel(label_invite, "State: Waiting " + count + " seconds...\n");
             Thread.Sleep(1000);
         }
         Interface.UpdateLabel(label_invite, "State: Waiting 0 seconds...\n");
     }
     else
     {
         Random rnd  = new Random();
         int    wait = rnd.Next(Interface.inviteSpeedMin, Interface.inviteSpeedMax);
         Interface.AppendText(text_log, "\r\nWaiting " + wait + " seconds...\n");
         for (int count = wait; count > 0; --count)
         {
             Interface.UpdateLabel(label_invite, "State: Waiting " + count + " seconds...\n");
             Thread.Sleep(1000);
         }
         Interface.UpdateLabel(label_invite, "State: Waiting 0 seconds...\n");
     }
 }
コード例 #2
0
ファイル: Bot.cs プロジェクト: windykiss/SteamGrouper
        public static void InviteToGroup(ulong invitee, string gid, string groupname, TextBox text_log, Label label_invite)
        {
            CookieContainer cookies = new CookieContainer();

            cookies.Add(new Cookie("sessionid", Bot.sessionId, String.Empty, "steamcommunity.com"));
            cookies.Add(new Cookie("steamLogin", Bot.token, String.Empty, "steamcommunity.com"));
            var data = new NameValueCollection();

            data.Add("type", "groupInvite");
            data.Add("inviter", Bot.SteamUser.SteamID.ConvertToUInt64().ToString());
            data.Add("invitee", invitee.ToString());
            data.Add("group", gid);
            data.Add("sessionID", Bot.sessionId);
            try
            {
                HttpWebResponse webResponse = SteamWeb.Request("http://steamcommunity.com/actions/GroupInvite", "POST", data, cookies, false);
                Stream          response    = null;
                response = webResponse.GetResponseStream();
                StreamReader reader = new StreamReader(response);
                string       result = reader.ReadToEnd();
                if (result.Contains("![CDATA[OK]]"))
                {
                    Interface.AppendText(text_log, "\r\nSuccess!\n");
                    Console.WriteLine("Success.");
                    blacklist(invitee, groupname);
                    successfulInvite++;
                }
                else
                {
                    int    start  = result.IndexOf("![CDATA[");
                    int    stop   = result.IndexOf("]]");
                    string output = result.Substring(start + 8, stop - start - 8);
                    Interface.AppendText(text_log, "\r\nError: " + output + "\n");
                    Console.WriteLine("Error: " + output);
                    blacklist(invitee, groupname);
                }
            }
            catch
            {
                Interface.UpdateLabel(label_invite, "Failed to get response; retrying...");
                InviteToGroup(invitee, gid, groupname, text_log, label_invite);
            }
        }
コード例 #3
0
ファイル: Bot.cs プロジェクト: windykiss/SteamGrouper
        public static void invite(string groupFrom, string group, TextBox text_log, Button button_invite, Label label_invite)
        {
            successfulInvite = 0;
            int    counter = 0;
            string line    = "";
            string path    = "http://steamcommunity.com/groups/" + group + "/memberslistxml/?xml=1e";

            retry = 0;
            string groupID = getGroupID(group, path);

            if (groupID != "")
            {
                Interface.AppendText(text_log, "\r\nProcessing gather list... This may take a few minutes if you have large list. Please be patient.\n");
                // Read from the gather list
                System.IO.StreamReader file = new System.IO.StreamReader("lists/gl_" + groupFrom.ToLower());
                while ((line = file.ReadLine()) != null)
                {
                    if (Interface.subExInMinutes <= 0 && !Welcome.trial)
                    {
                        Console.WriteLine("Subscription expired.");
                        break;
                    }
                    if (!Interface.inviting)
                    {
                        Console.WriteLine("Inviting cancelled.");
                        break;
                    }
                    else
                    {
                        Interface.currentSID = Convert.ToUInt64(line);
                        // Check if user has already been invited
                        bool invited = false;
                        if (!File.Exists("lists/bl_" + group.ToLower()))
                        {
                            using (StreamWriter sw = File.CreateText("lists/bl_" + group.ToLower()))
                            {
                                sw.Close();
                            }
                        }
                        System.IO.StreamReader blacklist = new System.IO.StreamReader("lists/bl_" + group.ToLower());
                        string compare;
                        while ((compare = blacklist.ReadLine()) != null)
                        {
                            if (Interface.currentSID.ToString() == compare)
                            {
                                //Console.Write("User " + currentSID + " already invited.      \r");
                                invited = true;
                                break;
                            }
                        }
                        blacklist.Close();
                        if (!invited && Interface.inviteOffline)
                        {
                            if (successfulInvite % 250 == 0 && successfulInvite != 0 && Welcome.trial)
                            {
                                MessageBox.Show("For uninterrupted inviting, please consider buying a subscription! Visit http://www.steamgrouper.com/",
                                                "Trial Mode",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information,
                                                MessageBoxDefaultButton.Button1);
                            }
                            counter++;
                            Interface.AppendText(text_log, "\r\nInviting user #" + counter + ": " + Interface.currentSID);
                            DoInvite(file, Interface.currentSID, groupID, group, text_log, label_invite);
                        }
                        else if (!invited && !Interface.inviteOffline)
                        {
                            if (successfulInvite % 250 == 0 && successfulInvite != 0 && Welcome.trial)
                            {
                                MessageBox.Show("For uninterrupted inviting, please consider buying a subscription! Visit http://www.steamgrouper.com/",
                                                "Trial Mode",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information,
                                                MessageBoxDefaultButton.Button1);
                            }
                            string playerURL     = "http://steamcommunity.com/profiles/" + Interface.currentSID + "?xml=1";
                            string playerProfile = SteamGrouper.Util.HTTPRequest(playerURL);
                            string status        = "online";
                            if (playerProfile != "")
                            {
                                status = SteamGrouper.Util.ParseBetween(playerProfile, "<onlineState>", "</onlineState>");
                            }
                            if (status != "offline")
                            {
                                counter++;
                                Interface.AppendText(text_log, "\r\nInviting user #" + counter + ": " + Interface.currentSID);
                                DoInvite(file, Interface.currentSID, groupID, group, text_log, label_invite);
                            }
                        }
                    }
                }
                file.Close();
                Interface.AppendText(text_log, "\r\nDone. Invited " + counter + " members to your group.");
                Interface.UpdateLabel(label_invite, "State: Idle");
                Interface.UpdateButton(button_invite, "Invite");
                if (Interface.subExInMinutes <= 0 && !Welcome.trial)
                {
                    MessageBox.Show("We're sorry, but your subscription has just expired. To continue using the full version of SteamGrouper, please add more time to your subscription at http://www.steamgrouper.com/choose-a-subscription/",
                                    "Subscription Expired",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation,
                                    MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                MessageBox.Show("Failed to get groupID. Please try again.",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation,
                                MessageBoxDefaultButton.Button1);
            }
        }