protected void btnFollowAll_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool friendsChanged = false;

                TwitterAuthenticate();
                try {
                    foreach (Twitter.User user in ListUsers)
                    {
                        twdata = new Twitter(user, Twitter.TwitterType.Friends);
                        if (!ListFriends.Contains(user))
                        {
                            ListFriends.Add(user);
                            friendsChanged = true;
                        }
                        ListUsers.Remove(user);
                    }
                    ListUsers.Clear();
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                    }

                    Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.NotFollowing.ToString());
                    Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
                    BindData();
                } catch (WebException wex) {
                    BindData();
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", string.Format("alert('{0}');", "No internet connection: " + wex.Message.Replace("'", string.Empty)), true);
                } catch (Exception ex) {
                    //do nothing
                }
            }
        }
        protected void btnFollow_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool usersChanged   = false;
                bool friendsChanged = false;

                TwitterAuthenticate();
                try {
                    foreach (GridViewRow row in gvUsers.Rows)
                    {
                        Control ctrl = row.FindControl("cbxDelete");
                        if (ctrl != null)
                        {
                            CheckBox cbx = (CheckBox)ctrl;
                            if (cbx.Checked)
                            {
                                Control lblctrl = row.FindControl("lblUserId");
                                if (lblctrl != null)
                                {
                                    Label lbl  = (Label)lblctrl;
                                    var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                                    if (user != null)
                                    {
                                        twdata = new Twitter(user, Twitter.TwitterType.Friends);
                                        if (!ListFriends.Contains(user))
                                        {
                                            ListFriends.Add(user);
                                            friendsChanged = true;
                                        }
                                        ListUsers.Remove(user);
                                        usersChanged = true;
                                    }
                                }
                            }
                        }
                    }
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                    }
                    if (usersChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.NotFollowing.ToString());
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
                    }
                    BindData();
                } catch (WebException wex) {
                    BindData();
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", string.Format("alert('{0}');", "No internet connection: " + wex.Message.Replace("'", string.Empty)), true);
                } catch (Exception ex) {
                    //do nothing
                }
            }
        }
Esempio n. 3
0
        public static void LoadFriends() //https://github.com/waylaidwanderer/Mist/tree/master/SteamBot
        {
            ListFriends.Clear();
            List <SteamID> steamIdList = new List <SteamID>();

            Console.WriteLine("[" + Program.BOTNAME + "] - Loading all friends...");
            for (int index = 0; index < steamFriends.GetFriendCount(); ++index)
            {
                steamIdList.Add(steamFriends.GetFriendByIndex(index));
                Thread.Sleep(25);
            }
            for (int index = 0; index < steamIdList.Count; ++index)
            {
                SteamID steamId = steamIdList[index];
                if (steamFriends.GetFriendRelationship(steamId) == EFriendRelationship.Friend)
                {
                    string friendPersonaName = steamFriends.GetFriendPersonaName(steamId);
                    string Relationship      = steamFriends.GetFriendRelationship(steamId).ToString();
                    string status            = steamFriends.GetFriendPersonaState(steamId).ToString();
                    ListFriends.Add(friendPersonaName, (ulong)steamId, Relationship, status);
                }
            }
            foreach (ListFriends listFriends in ListFriends.Get(false))
            {
                if (ListFriendRequests.Find(listFriends.SID))
                {
                    Console.WriteLine("[" + Program.BOTNAME + "] - Found friend {0} in list of friend requests, so let's remove the user.", (object)listFriends.Name);
                    ListFriendRequests.Remove(listFriends.SID);
                }
            }
            foreach (ListFriendRequests listFriendRequests in ListFriendRequests.Get())
            {
                if (listFriendRequests.Name == "[unknown]")
                {
                    string friendPersonaName = steamFriends.GetFriendPersonaName((SteamID)listFriendRequests.SteamID);
                    ListFriendRequests.Remove(listFriendRequests.SteamID);
                    ListFriendRequests.Add(friendPersonaName, listFriendRequests.SteamID, "Offline");
                }
                if (listFriendRequests.Name == "")
                {
                    string friendPersonaName = steamFriends.GetFriendPersonaName((SteamID)listFriendRequests.SteamID);
                    ListFriendRequests.Remove(listFriendRequests.SteamID);
                    ListFriendRequests.Add(friendPersonaName, listFriendRequests.SteamID, "Offline");
                }
            }
            Console.WriteLine("[" + Program.BOTNAME + "] - Done! {0} friends.", (object)ListFriends.Get(false).Count);
            FriendsLoaded = true;
        }
Esempio n. 4
0
File: Bot.cs Progetto: xaustinx/Mist
        public void LoadFriends()
        {
            ListFriends.Clear();
            var steamListFriends = new List <SteamID>();

            Console.WriteLine("Loading all friends...");
            for (int count = 0; count < SteamFriends.GetFriendCount(); count++)
            {
                steamListFriends.Add(SteamFriends.GetFriendByIndex(count));
                Thread.Sleep(25);
            }
            for (int count = 0; count < steamListFriends.Count; count++)
            {
                var friendID = steamListFriends[count];
                if (SteamFriends.GetFriendRelationship(friendID) == EFriendRelationship.Friend)
                {
                    var friendName     = SteamFriends.GetFriendPersonaName(friendID);
                    var friendNickname = PlayerNicknames.ContainsKey(friendID) ? "(" + PlayerNicknames[friendID] + ")" : "";
                    var friendState    = SteamFriends.GetFriendPersonaState(friendID).ToString();
                    ListFriends.Add(friendName, friendID, friendNickname, friendState);
                }
            }
            foreach (var item in ListFriends.Get())
            {
                if (ListFriendRequests.Find(item.SID))
                {
                    Console.WriteLine("Found friend {0} in list of friend requests, so let's remove the user.", item.Name);
                    // Not a friend request, so let's remove it
                    ListFriendRequests.Remove(item.SID);
                }
            }
            foreach (var item in ListFriendRequests.Get())
            {
                if (item.Name == "[unknown]")
                {
                    string name = SteamFriends.GetFriendPersonaName(item.SteamID);
                    ListFriendRequests.Remove(item.SteamID);
                    ListFriendRequests.Add(name, item.SteamID);
                }
                if (item.Name == "")
                {
                    string name = SteamFriends.GetFriendPersonaName(item.SteamID);
                    ListFriendRequests.Remove(item.SteamID);
                    ListFriendRequests.Add(name, item.SteamID);
                }
            }
            Console.WriteLine("Done! {0} friends.", ListFriends.Get().Count);
        }
Esempio n. 5
0
        public void LoadFriends()
        {
            ListFriends.Clear();
            Console.WriteLine("Loading all friends...");
            for (int count = 0; count < SteamFriends.GetFriendCount(); count++)
            {
                var friendID    = SteamFriends.GetFriendByIndex(count);
                var friendName  = SteamFriends.GetFriendPersonaName(friendID);
                var friendState = SteamFriends.GetFriendPersonaState(friendID).ToString();
                if (friendState.ToString() != "Offline" && SteamFriends.GetFriendRelationship(friendID) == EFriendRelationship.Friend)
                {
                    string friend_name = friendName + " (" + friendID + ")" + Environment.NewLine + friendState;
                    ListFriends.Add(friendName, friendID, friendState);
                }
                Thread.Sleep(25);
            }
            for (int count = 0; count < SteamFriends.GetFriendCount(); count++)
            {
                var friendID    = SteamFriends.GetFriendByIndex(count);
                var friendName  = SteamFriends.GetFriendPersonaName(friendID);
                var friendState = SteamFriends.GetFriendPersonaState(friendID).ToString();
                if (friendState.ToString() == "Offline" && SteamFriends.GetFriendRelationship(friendID) == EFriendRelationship.Friend)
                {
                    ListFriends.Add(friendName, friendID, friendState);
                }
                Thread.Sleep(25);
            }
            bool newFriend = true;

            foreach (var item in ListFriends.Get())
            {
                if (ListFriendRequests.Find(item.SID))
                {
                    Console.WriteLine("Found friend {0} in list of friend requests, so let's remove the user.", item.Name);
                    // Not a friend request, so let's remove it
                    ListFriendRequests.Remove(item.SID);
                    newFriend = false;
                }
            }
            foreach (var item in ListFriendRequests.Get())
            {
                if (item.Name == "[unknown]")
                {
                    string name = SteamFriends.GetFriendPersonaName(item.SteamID);
                    ListFriendRequests.Remove(item.SteamID);
                    ListFriendRequests.Add(name, item.SteamID);
                }
                if (item.Name == "")
                {
                    string name = SteamFriends.GetFriendPersonaName(item.SteamID);
                    ListFriendRequests.Remove(item.SteamID);
                    ListFriendRequests.Add(name, item.SteamID);
                }
            }
            if (newFriend && ListFriendRequests.Get().Count != 0)
            {
                Console.WriteLine("Notifying about new friend request.");
                showFriends.NotifyFriendRequest();
                showFriends.list_friendreq.SetObjects(ListFriendRequests.Get());
            }
            Console.WriteLine("Done!");
        }