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; }
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); }
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!"); }