示例#1
0
            public void OnFriendsList(SteamFriends.FriendsListCallback e)
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in e.FriendList)
                {
                    if (Bot.Admins.Contains(friend.SteamID))
                    {
                        Bot.SteamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, "Hello, sir.");
                        Log.Info("Sent admin startup message to admin '{0}'.", Bot.SteamFriends
                                 .GetFriendPersonaName(friend.SteamID));
                    }

                    switch (friend.SteamID.AccountType)
                    {
                    case EAccountType.Clan:
                        if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (Bot._getUserHandler(friend.SteamID).OnGroupAdd())
                            {
                                Bot.AcceptGroupInvite(friend.SteamID);
                                Log.Success("Accepted group invite from {0}.", friend.SteamID);
                            }
                            else
                            {
                                Bot.DeclineGroupInvite(friend.SteamID);
                                Log.Info("Declined group invite from {0}.", friend.SteamID);
                            }
                        }
                        break;

                    default:
                        Bot._createFriendsListIfNecessary();
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            Log.Warn("Friend already removed. Removing friend {0}.", friend.SteamID);
                            Bot._friends.Remove(friend.SteamID);
                            Bot._getUserHandler(friend.SteamID).OnFriendRemove();
                            Bot.RemoveUserHandler(friend.SteamID);
                        }
                        else if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (Bot._getUserHandler(friend.SteamID).OnFriendAdd())
                            {
                                if (!Bot._friends.Contains(friend.SteamID))
                                {
                                    Bot._friends.Add(friend.SteamID);
                                }
                                else
                                {
                                    Log.Error("Friend was added who was already in friends list: " + friend.SteamID);
                                }
                                Bot.SteamFriends.AddFriend(friend.SteamID);
                            }
                            else
                            {
                                Log.Warn("Friend add failed. Removing friend {0}.", friend.SteamID);
                                Bot.SteamFriends.RemoveFriend(friend.SteamID);
                                Bot.RemoveUserHandler(friend.SteamID);
                            }
                        }
                        break;
                    }
                }
            }