예제 #1
0
        public static string FakeInvite(string strTargetName, string strConnectString)
        {
            int iFriendCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate);

            for (int a = 0; a < iFriendCount; a++)
            {
                CSteamID FriendID = SteamFriends.GetFriendByIndex(a, EFriendFlags.k_EFriendFlagImmediate);

                string strFriendName = SteamFriends.GetFriendPersonaName(FriendID);
                if (strFriendName.Equals(strTargetName))
                {
                    EPersonaState EState = SteamFriends.GetFriendPersonaState(FriendID);
                    if (EState == EPersonaState.k_EPersonaStateOffline || EState == EPersonaState.k_EPersonaStateSnooze)
                    {
                        return("The specified user was either Offline, or on Snooze.\n");
                    }

                    bool bTest = SteamFriends.InviteUserToGame(FriendID, strConnectString);
                    if (bTest)
                    {
                        return("Invite sent with specified launch parameters.\n");
                    }
                    else
                    {
                        return("Failed to send invite with specified launch parameters.\n");
                    }
                }
            }
            return("Failed to find friend, ensure you have them added, and you're supplying the correct name.\n");
        }
예제 #2
0
파일: Users.cs 프로젝트: mdkozlowski/RohBot
        private static string GetStatusString(EPersonaState status)
        {
            switch (status)
            {
            case EPersonaState.Offline:
                return("Offline");

            case EPersonaState.Online:
                return("Online");

            case EPersonaState.Busy:
                return("Busy");

            case EPersonaState.Away:
                return("Away");

            case EPersonaState.Snooze:
                return("Snooze");

            case EPersonaState.LookingToTrade:
                return("Looking to Trade");

            case EPersonaState.LookingToPlay:
                return("Looking to Play");

            default:
                return("");
            }
        }
예제 #3
0
 /// <summary>
 /// Creates a SteamNerd user that contains user information.
 /// </summary>
 /// <param name="steamNerd">The SteamNerd instance.</param>
 /// <param name="steamID">The user's SteamID.</param>
 /// <param name="name">The user's persona name.</param>
 /// <param name="personaState">The user's persona state.</param>
 public User(SteamNerd steamNerd, SteamID steamID, string name, EPersonaState personaState)
 {
     _steamNerd   = steamNerd;
     SteamID      = steamID;
     Name         = name;
     PersonaState = personaState;
 }
예제 #4
0
파일: Friend.cs 프로젝트: bmk10/hl2sb-src-1
        public string GetStatus()
        {
            try
            {
                if (this.IsInGame())
                {
                    return("In-Game");
                }

                EPersonaState state = SteamContext.ClientFriends.GetFriendPersonaState(this.SteamID);

                switch (state)
                {
                case EPersonaState.k_EPersonaStateAway:
                    return("Away");

                case EPersonaState.k_EPersonaStateBusy:
                    return("Busy");

                case EPersonaState.k_EPersonaStateOnline:
                    return("Online");

                case EPersonaState.k_EPersonaStateSnooze:
                    return("Snooze");
                }

                return("Offline");
            }
            catch
            {
                return("Offline");
            }
        }
예제 #5
0
        public FriendCollection GetFriends()
        {
            EFriendFlags flags = (
                EFriendFlags.k_EFriendFlagImmediate |
                EFriendFlags.k_EFriendFlagRequestingFriendship |
                EFriendFlags.k_EFriendFlagFriendshipRequested
                );
            int friendCount            = SteamFriends.GetFriendCount(flags);
            List <FriendGamer> friends = new List <FriendGamer>(friendCount);

            for (int i = 0; i < friendCount; i += 1)
            {
                CSteamID            id           = SteamFriends.GetFriendByIndex(i, flags);
                EFriendRelationship relationship = SteamFriends.GetFriendRelationship(id);
                EPersonaState       state        = SteamFriends.GetFriendPersonaState(id);
                FriendGameInfo_t    whoCares;
                friends.Add(new FriendGamer(
                                id,
                                SteamFriends.GetFriendPersonaName(id),
                                SteamFriends.GetPlayerNickname(id),
                                state != EPersonaState.k_EPersonaStateOffline,
                                SteamFriends.GetFriendGamePlayed(id, out whoCares),
                                state == EPersonaState.k_EPersonaStateAway,
                                state == EPersonaState.k_EPersonaStateBusy,
                                relationship == EFriendRelationship.k_EFriendRelationshipRequestRecipient,
                                relationship == EFriendRelationship.k_EFriendRelationshipRequestInitiator
                                ));
            }
            return(new FriendCollection(friends));
        }
예제 #6
0
 /// <summary>
 /// Convert an <see cref="EPersonaState" /> to a string.
 /// </summary>
 /// <param name="state">The state to convert.</param>
 /// <param name="pretty">If <c>true</c>, capitalize the first letter of the string.</param>
 /// <returns>The string representation of the <see cref="EPersonaState" />.</returns>
 internal static string StateToStatus(EPersonaState state, bool pretty = false)
 {
     string status;
     switch (state)
     {
         case EPersonaState.k_EPersonaStateAway:
             status = "away";
             break;
         case EPersonaState.k_EPersonaStateBusy:
             status = "busy";
             break;
         case EPersonaState.k_EPersonaStateMax: // What is this?
             status = "max";
             break;
         case EPersonaState.k_EPersonaStateOffline:
             status = "offline";
             break;
         case EPersonaState.k_EPersonaStateOnline:
             status = "online";
             break;
         case EPersonaState.k_EPersonaStateSnooze:
             status = "snooze";
             break;
         default:
             status = "undefined";
             break;
     }
     if (pretty)
     {
         char[] a = status.ToCharArray();
         a[0] = char.ToUpper(a[0]);
         return new string(a);
     }
     return status;
 }
    // Use this for initialization
    void Start()
    {
        if (SteamManager.Initialized)
        {
            //get My steam name
            if (labelUser)
            {
                labelUser.text = "Current Steam User: " + SteamFriends.GetPersonaName();
            }

            dropdownSteamFriends.ClearOptions();
            int friendCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate);

            for (int i = 0; i < friendCount; ++i)
            {
                CSteamID      friendSteamId = SteamFriends.GetFriendByIndex(i, EFriendFlags.k_EFriendFlagImmediate);
                string        friendName    = SteamFriends.GetFriendPersonaName(friendSteamId);
                EPersonaState friendState   = SteamFriends.GetFriendPersonaState(friendSteamId);

                Dropdown.OptionData option = new Dropdown.OptionData();
                option.text = friendName;
                if (friendState != EPersonaState.k_EPersonaStateOffline)
                {
                    dropdownSteamFriends.options.Add(option);
                    friendSteamIDs.Add(friendSteamId);
                }
            }
        }
    }
        public override void LoadFriendsList()
        {
            gameServiceFriendsList = new List <GameServiceUserInfo>();

            int friendCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate);

            for (int i = 0; i < friendCount; ++i)
            {
                CSteamID         friendSteamId = SteamFriends.GetFriendByIndex(i, EFriendFlags.k_EFriendFlagImmediate);
                string           friendName    = SteamFriends.GetFriendPersonaName(friendSteamId);
                EPersonaState    friendState   = SteamFriends.GetFriendPersonaState(friendSteamId);
                FriendGameInfo_t currentGame;


                if (SteamFriends.GetFriendGamePlayed(friendSteamId, out currentGame))
                {
                    if (currentGame.m_gameID == m_GameID)
                    {
                        GameServiceUserInfo friend = new GameServiceUserInfo();
                        friend.NickName = friendName;
                        friend.PlayerId = friendSteamId.GetAccountID().m_AccountID.ToString();
                        friend.Status   = Status.Available;
                        friend.SetAvatarFromTexture2D(GetSmallAvatar(friendSteamId, false));
                        gameServiceFriendsList.Add(friend);
                    }
                }
            }

            RaiseGameServiceEvent(new GameServiceEvent(GameServiceEventType.FriendsListReady));
        }
예제 #9
0
파일: User.cs 프로젝트: bakerj76/SteamNerd
 /// <summary>
 /// Creates a SteamNerd user that contains user information.
 /// </summary>
 /// <param name="steamNerd">The SteamNerd instance.</param>
 /// <param name="steamID">The user's SteamID.</param>
 /// <param name="name">The user's persona name.</param>
 /// <param name="personaState">The user's persona state.</param>
 public User(SteamNerd steamNerd, SteamID steamID, string name, EPersonaState personaState)
 {
     _steamNerd = steamNerd;
     SteamID = steamID;
     Name = name;
     PersonaState = personaState;
 }
예제 #10
0
        public static Dictionary <CSteamID, string[]> GetOnlineFriends()
        {
            var friends = new Dictionary <CSteamID, string[]>(); if (!SteamManager.Initialized)

            {
                Logger.Error("CONNECTION FAILED");
                return(friends);
            }
            try
            {
                int friendCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate);
                for (int i = 0; i < friendCount; ++i)
                {
                    CSteamID      friendSteamId = SteamFriends.GetFriendByIndex(i, EFriendFlags.k_EFriendFlagImmediate);
                    string        friendName    = SteamFriends.GetFriendPersonaName(friendSteamId);
                    EPersonaState friendState   = SteamFriends.GetFriendPersonaState(friendSteamId);
                    if (friendState != EPersonaState.k_EPersonaStateOffline)
                    {
                        var  fgi = new FriendGameInfo_t();
                        bool ret = SteamFriends.GetFriendGamePlayed(friendSteamId, out fgi);
                        friends.Add(friendSteamId, new string[] { friendName, "" + fgi.m_gameID });
                    }
                }
            } catch (Exception e)
            {
                Logger.Error(e);
            }
            return(friends);
        }
예제 #11
0
        internal void Update(User requester = null)
        {
            if (requester != null)
            {
                this._Requester = requester;
            }
            requester = this._Requester;

            string        name   = requester.Name;
            EPersonaState state  = requester.State;
            string        game   = requester.Game;
            BitmapImage   source = requester.Avatar;

            this.IMAvatar.Source = source;

            this.TBName.Text = name;
            if (game != null)
            {
                this.TBState.Text = $"Playing {game}";
                this.RCState.Fill = Brushes.Green;
            }
            else
            {
                this.TBState.Text = state.ToString();
                this.RCState.Fill = FriendControl.StateToColor(state);
            }
        }
예제 #12
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (Items.Count == 0)
            {
                base.OnDrawItem(e);
                return;
            }

            if (Items[e.Index] is Friend)
            {
                Friend friendObj = ( Friend )Items[e.Index];

                this.DrawMode = DrawMode.OwnerDrawFixed;

                e.DrawBackground();

                e.DrawFocusRectangle();

                EPersonaState state = SteamContext.SteamFriends.GetFriendPersonaState(friendObj.SteamID);

                if (state == EPersonaState.k_EPersonaStateOffline)
                {
                    e.Graphics.DrawString(friendObj.PersonaName, e.Font, new SolidBrush(Color.Red), e.Bounds);
                }
                else
                {
                    e.Graphics.DrawString(friendObj.PersonaName, e.Font, new SolidBrush(Color.Green), e.Bounds);
                }
            }
        }
예제 #13
0
        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            base.OnListItemClick(l, v, position, id);

            EPersonaState state = stateAdapter.GetItem(position);

            SteamService.GetClient().Friends.SetPersonaState(state);
        }
예제 #14
0
        public static bool Msg_Condition(EPersonaState personaState, SteamID steamID)
        {
            string state = personaState.ToString();

            dynamic friendsList = readFriendsList();

            string condition = "online";

            if (friendsList["steamID"][steamID.ToString()] == null)
            {
                friendsList = dumpFriendslist();
            }

            condition = friendsList["steamID"][steamID.ToString()]["Message_Conditions"];

            switch (condition.ToLower())
            {
            case null:
                if (state == "Online")
                {
                    return(true);
                }
                return(false);

            case "non":
                return(false);

            case "all":
                if (state != "Offline")
                {
                    return(true);
                }
                return(false);

            case "busy":
                if (state != "Away" && state != "Offline")
                {
                    return(true);
                }
                return(false);

            case "away":
                if (state != "Busy" && state != "Offline")
                {
                    return(true);
                }
                return(false);

            case "online":
                if (state == "Online")
                {
                    return(true);
                }
                return(false);
            }
            return(true);
        }
예제 #15
0
        /// <summary>
        /// Adds a user to the manager.
        /// </summary>
        /// <param name="steamID">The user's SteamID.</param>
        /// <param name="name">The user's name.</param>
        /// <param name="personaState">The user's persona state.</param>
        /// <returns></returns>
        public User AddUser(SteamID steamID, string name, EPersonaState personaState)
        {
            Console.WriteLine("Adding user {0}", name);
            var user = new User(_steamNerd, steamID, name, personaState);
            user.IsAdmin = IsAdmin(user);
            _users[user.SteamID] = user;

            return user;
        }
예제 #16
0
        //
        // Local Persona
        //

        public void OnAccountInfo(SteamUser.AccountInfoCallback callback)
        {
            EPersonaState PersonaState = setup.steamFriends.GetPersonaState();

            if (PersonaState == EPersonaState.Offline)
            {
                Console.WriteLine("Setting personastate to Online");
                setup.steamFriends.SetPersonaState(EPersonaState.Online);
            }
        }
예제 #17
0
        /// <summary>
        /// Sets the local user's persona state and broadcasts it over the network.
        /// </summary>
        /// <param name="state">The state.</param>
        public void SetPersonaState( EPersonaState state )
        {
            cache.LocalUser.PersonaState = state;

            var stateMsg = new ClientMsgProtobuf<CMsgClientChangeStatus>( EMsg.ClientChangeStatus );
            stateMsg.Body.persona_state = ( uint )state;
            stateMsg.Body.player_name = cache.LocalUser.Name;

            this.Client.Send( stateMsg );
        }
예제 #18
0
        /// <summary>
        /// Sets the local user's persona state and broadcasts it over the network.
        /// </summary>
        /// <param name="state">The state.</param>
        public void SetPersonaState(EPersonaState state)
        {
            cache.LocalUser.PersonaState = state;

            var stateMsg = new ClientMsgProtobuf <CMsgClientChangeStatus>(EMsg.ClientChangeStatus);

            stateMsg.Body.persona_state = ( uint )state;

            this.Client.Send(stateMsg);
        }
예제 #19
0
        /// <summary>
        /// Adds a user to the manager.
        /// </summary>
        /// <param name="steamID">The user's SteamID.</param>
        /// <param name="name">The user's name.</param>
        /// <param name="personaState">The user's persona state.</param>
        /// <returns></returns>
        public User AddUser(SteamID steamID, string name, EPersonaState personaState)
        {
            Console.WriteLine("Adding user {0}", name);
            var user = new User(_steamNerd, steamID, name, personaState);

            user.IsAdmin         = IsAdmin(user);
            _users[user.SteamID] = user;

            return(user);
        }
예제 #20
0
        private void StateChange(PersonaStateChange_t change)
        {
            IClient cl;

            if (change.m_nChangeFlags == EPersonaChange.k_EPersonaChangeComeOnline)
            {
                cl = new SteamClient(change.m_ulSteamID);
                clients.Add(cl);
                Database.GetDatabase().GetChannel("Friends").AddClient(cl);
            }
            else if (change.m_nChangeFlags == EPersonaChange.k_EPersonaChangeGoneOffline)
            {
                cl = GetSteamClient(change.m_ulSteamID);
                if (cl != null)
                {
                    cl.Dispose();
                }
            }
            else if (change.m_nChangeFlags == EPersonaChange.k_EPersonaChangeName)
            {
                cl = GetSteamClient(change.m_ulSteamID);

                if (cl != null)
                {
                    cl.RealName = clientFriends.GetFriendPersonaName(change.m_ulSteamID);

                    if (!clientList.Clients.ContainsKey(change.m_ulSteamID))
                    {
                        cl.AddMessage(IRCMessage.GetStatic().CreateMessage(cl, "NICK " + StripString(cl.RealName)));
                    }
                    //Server.GetChannel("Friends").SendMessage(Message.CreateMessage(cl, cl.UserString, "NICK", new string[] { StripString(cl.RealName) }));
                    //cl.NickName = StripString(cl.RealName);
                }
            }
            else if (change.m_nChangeFlags == EPersonaChange.k_EPersonaChangeStatus)
            {
                EPersonaState st = clientFriends.GetFriendPersonaState(change.m_ulSteamID);
                cl = GetSteamClient(change.m_ulSteamID);

                if (cl != null)
                {
                    if (st == EPersonaState.k_EPersonaStateOffline)
                    {
                        cl.Dispose();
                    }
                    else
                    {
                        cl.AddMessage(IRCMessage.GetStatic().CreateMessage(cl, cl.UserString, "AWAY", new string[] { (st == EPersonaState.k_EPersonaStateOnline ? "" : st.ToString().Remove(0, 15)) }));
                    }
                }
                //cl.AwayMsg = (st == EPersonaState.k_EPersonaStateOnline ? "" : st.ToString().Remove(0, 15));
            }
        }
 static SolidColorBrush StateToBrush(EPersonaState state, bool inGame)
 {
     switch (state)
     {
         case EPersonaState.Offline:
             return (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF636363"));
         default:
             if (inGame)
                 return (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF7DBA35"));
             return (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF509BB8"));
     }
 }
예제 #22
0
 internal User(User user)
 {
     this._Name        = user._Name;
     this._SteamID     = user._SteamID;
     this._Avatar      = user._Avatar;
     this._SteamID64   = user._SteamID64;
     this._AccountID   = user._AccountID;
     this._State       = user._State;
     this._Game        = user._Game;
     this._Messages    = user._Messages;
     this._NewMessages = user._NewMessages;
     this._Extra       = null;
 }
예제 #23
0
 public Friend(SteamID steamID, byte[] avatarHash, string nickname, EPersonaState state)
 {
     this.steamID = steamID;
     Nickname     = nickname;
     OnlineStatus = state;
     AvatarHash   = avatarHash;
     if (avatarHash != null)
     {
         AvatarUrl = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" +
                     Utilities.ByteArrayToHexString(avatarHash).Substring(0, 2).ToLower() + "/" +
                     Utilities.ByteArrayToHexString(avatarHash).ToLower() + "_full.jpg";
     }
 }
예제 #24
0
        private void OnPersonaState(SteamFriends.PersonaStateCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            SteamID       steamID       = callback.FriendID;
            SteamID       sourceSteamID = callback.SourceSteamID;
            string        steamNickname = callback.Name;
            EPersonaState personaState  = callback.State;
            EClanRank     clanRank      = (EClanRank)callback.ClanRank;
        }
예제 #25
0
        /// <summary>
        /// Sets the local user's persona state and broadcasts it over the network.
        /// Results are returned in a <see cref="PersonaChangeCallback"/> callback.
        /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="PersonaChangeCallback"/>.</returns>
        public AsyncJob <PersonaChangeCallback> SetPersonaState(EPersonaState state)
        {
            cache.LocalUser.PersonaState = state;

            var stateMsg = new ClientMsgProtobuf <CMsgClientChangeStatus>(EMsg.ClientChangeStatus);

            stateMsg.SourceJobID = Client.GetNextJobID();

            stateMsg.Body.persona_state = ( uint )state;

            this.Client.Send(stateMsg);

            return(new AsyncJob <PersonaChangeCallback>(this.Client, stateMsg.SourceJobID));
        }
예제 #26
0
        private void ChatResult(ChatMemberStateChange_t entry)
        {
            EChatMemberStateChange ch = entry.m_rgfChatMemberStateChange;

            if (ch == EChatMemberStateChange.k_EChatMemberStateChangeEntered)
            {
                IClient cl = GetSteamClient(entry.m_ulSteamIDUserChanged);

                if (cl == null)
                {
                    if (clientList.Clients.ContainsKey(entry.m_ulSteamIDUserChanged))
                    {
                        cl = clientList.Clients[entry.m_ulSteamIDUserChanged];
                    }
                    else
                    {
                        cl = new SteamClient(entry.m_ulSteamIDUserChanged);
                    }

                    EPersonaState st = clientFriends.GetFriendPersonaState(entry.m_ulSteamIDUserChanged);
                    cl.AwayMsg = (st == EPersonaState.k_EPersonaStateOnline ? "" : st.ToString().Remove(0, 15));
                    clients.Add(cl);
                }

                cl.AddMessage(IRCMessage.GetStatic().CreateMessage(cl, cl.UserString, "JOIN", new string[] { "&" + GetSteamChannel(entry.m_ulSteamIDChat).ChannelName }));

                /*Channel c = GetChannel(Server.StripString(clientFriends.GetChatRoomName(entry.m_ulSteamIDChat)));
                 * c.AddClient(cl);*/
            }
            else if (ch == EChatMemberStateChange.k_EChatMemberStateChangeLeft || ch == EChatMemberStateChange.k_EChatMemberStateChangeKicked || ch == EChatMemberStateChange.k_EChatMemberStateChangeDisconnected || ch == EChatMemberStateChange.k_EChatMemberStateChangeBanned)
            {
                IChannel c = GetSteamChannel(entry.m_ulSteamIDChat);

                IClient cl = GetSteamClient(entry.m_ulSteamIDUserChanged);

                if (cl == null || c == null)
                {
                    return;
                }

                string leaveMsg = entry.m_rgfChatMemberStateChange.ToString();

                if (leaveMsg.Length > 24)
                {
                    leaveMsg = leaveMsg.Remove(0, 24);
                }

                c.RemoveClient(cl, leaveMsg);
            }
        }
예제 #27
0
        /// <summary>
        /// Sets the local user's persona state and broadcasts it over the network.
        /// Results are returned in a <see cref="PersonaChangeCallback"/> callback.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="PersonaChangeCallback"/>.</returns>
        public JobID SetPersonaState(EPersonaState state)
        {
            cache.LocalUser.PersonaState = state;

            var stateMsg = new ClientMsgProtobuf <CMsgClientChangeStatus>(EMsg.ClientChangeStatus);

            stateMsg.SourceJobID = Client.GetNextJobID();

            stateMsg.Body.persona_state = ( uint )state;
            stateMsg.Body.player_name   = cache.LocalUser.Name;

            this.Client.Send(stateMsg);

            return(stateMsg.SourceJobID);
        }
예제 #28
0
    // LOGIC

    public void Refresh()
    {
        if (!SteamManager.initializedMain)
        {
            return;
        }

        string        personaName = SteamFriends.GetFriendPersonaName(m_SteamId);
        Sprite        icon        = SteamUtilities.GetMediumAvatar(m_SteamId);
        EPersonaState state       = SteamFriends.GetFriendPersonaState(m_SteamId);

        m_Name  = personaName;
        m_Icon  = icon;
        m_State = state;
    }
예제 #29
0
        static SolidColorBrush StateToBrush(EPersonaState state, bool inGame)
        {
            switch (state)
            {
            case EPersonaState.Offline:
                return((SolidColorBrush)(new BrushConverter().ConvertFrom("#FF636363")));

            default:
                if (inGame)
                {
                    return((SolidColorBrush)(new BrushConverter().ConvertFrom("#FF7DBA35")));
                }
                return((SolidColorBrush)(new BrushConverter().ConvertFrom("#FF509BB8")));
            }
        }
예제 #30
0
        public void UpdateValues(SteamFriends.PersonaStateCallback callback)
        {
            Name       = callback.Name;
            FriendID   = callback.FriendID;
            State      = callback.State;
            StateFlags = callback.StateFlags;

            GameID         = callback.GameID;
            GameName       = callback.GameName;
            GameServer     = callback.GameServerIP;
            GameServerPort = callback.GameServerPort;
            QueryPort      = callback.QueryPort;

            LastLogOff = callback.LastLogOff;
            LastLogOn  = callback.LastLogOn;
        }
예제 #31
0
        static void OnPersonaState(SteamFriends.PersonaStateCallback callback)
        {
            SteamID       friendID      = callback.FriendID;
            SteamID       sourceSteamID = callback.SourceSteamID.ConvertToUInt64();
            EClanRank     clanRank      = (EClanRank)callback.ClanRank;
            EPersonaState state         = callback.State;

            //ListFriends.UpdateName(friendId.ConvertToUInt64(), callback.Name); not yet
            //ListFriends.UpdateStatus(friendId.ConvertToUInt64(), state.ToString()); not yet

            if (friendID.ConvertToUInt64() == steamClient.SteamID)
            {
                if (sourceSteamID.IsClanAccount)
                {
                    switch (clanRank)
                    {
                    case EClanRank.Owner:
                        // case EClanRank.Officer:
                        //case EClanRank.Moderator:
                        if (!OfficerClanDictionary.ContainsKey(sourceSteamID))
                        {
                            OfficerClanDictionary.Add(sourceSteamID, friendID.ConvertToUInt64());
                        }
                        break;
                    }
                }

                //
                if (callback.GameID > 0)
                {
                    UserPlaying = true;
                }
                else
                {
                    UserPlaying = false;
                }
                if (steamFriends.GetPersonaState() != EPersonaState.Online) //detect when user goes afk
                {
                    //isAwayState = true;
                }
                else
                {
                    //isAwayState = false;
                }
            }
        }
 static string StateToText(EPersonaState state)
 {
     switch (state)
     {
         case EPersonaState.Offline:
             return "Offline";
         case EPersonaState.Online:
             return "Online";
         case EPersonaState.Away:
             return "Away";
         case EPersonaState.Busy:
             return "Busy";
         case EPersonaState.Snooze:
             return "Snooze";
     }
     return "Unknown state";
 }
예제 #33
0
        private int LoadSteam()
        {
            if (Steamworks.Load(true))
            {
                Console.WriteLine("Ok, Steam Works!");
            }
            else
            {
                MessageBox.Show("Failed, Steam Works!");
                Console.WriteLine("Failed, Steam Works!");

                return(-1);
            }

            steam006 = Steamworks.CreateSteamInterface <ISteam006>();

            steamclient     = Steamworks.CreateInterface <ISteamClient012>();
            pipe            = steamclient.CreateSteamPipe();
            user            = steamclient.ConnectToGlobalUser(pipe);
            steamuser       = steamclient.GetISteamUser <ISteamUser016>(user, pipe);
            steamfriends013 = steamclient.GetISteamFriends <ISteamFriends013>(user, pipe);
            steamfriends002 = steamclient.GetISteamFriends <ISteamFriends002>(user, pipe);
            CSteamID steamID = steamuser.GetSteamID();

            CurrentState = steamfriends002.GetFriendPersonaState(steamID);

            string ConvertTo64 = steamID.ConvertToUint64().ToString();

            txtBox_steamID.Text = ConvertTo64;
            steamid             = steamID;
            if (steam006 == null)
            {
                Console.WriteLine("steam006 is null !");
                return(-1);
            }
            if (steamclient == null)
            {
                Console.WriteLine("steamclient is null !");
                return(-1);
            }


            return(0);
        }
예제 #34
0
        public static void announceGathering(dynamic gatherInfo)
        {
            string current_state = gatherInfo["state"];

            gatherInfo = gatherInfo["gatherers"];
            int gatherers = gatherInfo.Count;

            SimpleLogger.SimpleLog.Info(String.Format(
                                            "Gather announcement initiated:\nCurrent state: {0}\nGatherers: {1}",
                                            current_state, gatherers.ToString()
                                            )
                                        );

            int friendCount = SteamBot.steamFriends.GetFriendCount();

            for (int x = 0; x < friendCount; x++)
            {
                SteamID steamIdFriend = SteamBot.steamFriends.GetFriendByIndex(x);
                //This allows bot to target users more intelligently.
                EPersonaState personaState = SteamBot.steamFriends.GetFriendPersonaState(steamIdFriend);
                bool          condition    = Json.Config.Msg_Condition(personaState, steamIdFriend);
                if (condition == false)
                {
                    continue;
                }

                string announcement = returnStatus(
                    current_state,
                    gatherers,
                    gatherInfo,
                    steamIdFriend,
                    true
                    );
                if (announcement == "")
                {
                    continue;
                }
                SteamBot.steamFriends.SendChatMessage(
                    steamIdFriend,
                    EChatEntryType.ChatMsg,
                    announcement
                    );
            }
        }
예제 #35
0
        /// <summary>
        /// Convert an <see cref="EPersonaState" /> to a string.
        /// </summary>
        /// <param name="state">The state to convert.</param>
        /// <param name="pretty">If <c>true</c>, capitalize the first letter of the string.</param>
        /// <returns>The string representation of the <see cref="EPersonaState" />.</returns>
        internal static string StateToStatus(EPersonaState state, bool pretty = false)
        {
            string status;

            switch (state)
            {
            case EPersonaState.k_EPersonaStateAway:
                status = "away";
                break;

            case EPersonaState.k_EPersonaStateBusy:
                status = "busy";
                break;

            case EPersonaState.k_EPersonaStateMax:                     // What is this?
                status = "max";
                break;

            case EPersonaState.k_EPersonaStateOffline:
                status = "offline";
                break;

            case EPersonaState.k_EPersonaStateOnline:
                status = "online";
                break;

            case EPersonaState.k_EPersonaStateSnooze:
                status = "snooze";
                break;

            default:
                status = "undefined";
                break;
            }
            if (pretty)
            {
                char[] a = status.ToCharArray();
                a[0] = char.ToUpper(a[0]);
                return(new string(a));
            }
            return(status);
        }
예제 #36
0
        public Task <SteamFriends.PersonaStateCallback> SetPersonaStateAsync(EPersonaState state)
        {
            _setPersonaStateTaskCompletionSource = new TaskCompletionSource <SteamFriends.PersonaStateCallback>();
            var oldState = PersonaState;

            Task.Run(() =>
            {
                _steamFriends.SetPersonaState(state);
                Messenger.Default.Send(new PersonaStateChangedMessage());
            });
            ThrowIfTimeout(_setPersonaStateTaskCompletionSource, () =>
            {
                Task.Run(() =>
                {
                    _steamFriends.SetPersonaState(oldState);
                    Messenger.Default.Send(new PersonaStateChangedMessage());
                });
            });
            return(_setPersonaStateTaskCompletionSource.Task);
        }
예제 #37
0
파일: Users.cs 프로젝트: Rohansi/RohBot
 private static string GetStatusString(EPersonaState status)
 {
     switch (status)
     {
         case EPersonaState.Offline:
             return "Offline";
         case EPersonaState.Online:
             return "Online";
         case EPersonaState.Busy:
             return "Busy";
         case EPersonaState.Away:
             return "Away";
         case EPersonaState.Snooze:
             return "Snooze";
         case EPersonaState.LookingToTrade:
             return "Looking to Trade";
         case EPersonaState.LookingToPlay:
             return "Looking to Play";
         default:
             return "";
     }
 }
예제 #38
0
        /// <summary>
        /// Sets the local user's persona state and broadcasts it over the network.
        /// Results are returned in a <see cref="PersonaChangeCallback"/> callback.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="PersonaChangeCallback"/>.</returns>
        public JobID SetPersonaState( EPersonaState state )
        {
            cache.LocalUser.PersonaState = state;

            var stateMsg = new ClientMsgProtobuf<CMsgClientChangeStatus>( EMsg.ClientChangeStatus );
            stateMsg.SourceJobID = Client.GetNextJobID();

            stateMsg.Body.persona_state = ( uint )state;
            stateMsg.Body.player_name = cache.LocalUser.Name;

            this.Client.Send( stateMsg );

            return stateMsg.SourceJobID;
        }
예제 #39
0
        // translates persona state to state combo box selection index
        int GetIndexFromState( EPersonaState state )
        {
            switch ( state )
            {
                case EPersonaState.Online:
                    return 0;

                case EPersonaState.Away:
                    return 1;

                case EPersonaState.Busy:
                    return 2;

                case EPersonaState.Snooze:
                    return 3;

                case EPersonaState.Offline:
                    return 4;
            }

            return 0;
        }
예제 #40
0
        public override void SetStatus(EPersonaState state)
        {
            if (Friends.chat_opened)
            {
                Bot.main.Invoke((Action)(() =>
                {
                    foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
                    {
                        if (tab.Text == Bot.SteamFriends.GetFriendPersonaName(OtherSID))
                        {
                            foreach (var item in tab.Controls)
                            {
                                Friends.chat.chatTab = (ChatTab)item;
                            }
                            tab.Invoke((Action)(() =>
                            {
                                Friends.chat.chatTab.steam_status.Text = state.ToString();
                            }));
                            return;
                        }
                    }

                }));
            }
        }
예제 #41
0
파일: UserHandler.cs 프로젝트: Jamyn/Mist
 public abstract void SetStatus(EPersonaState state);
예제 #42
0
파일: Steam.cs 프로젝트: wheybags/steamirc
 public idcache(String name, EPersonaState state){
     this.name = name;
     this.state = state;
 }
예제 #43
0
        private void UpdateKeys(EPersonaState state, bool ignoreState = false)
        {
            if (!_dispatcher.CheckAccess())
            {
                _dispatcher.Invoke(DispatcherPriority.Render, (VoidDelegate) (() => UpdateKeys(state, ignoreState)));
                return;
            }

            // _state is old state, state is new state

            // Do nothing if the state didn't change
            if (!ignoreState && EqualStates(state, _state)) // state == _state
                return;

            // Reset the previous key to the default images
            // EX: _state = online, state = away, reset online key to default image, set away to active image
            ResetKey(_state);

            var normalizedState = NormalizeState(state);

            _dynamicKeys[normalizedState].SetImage(ImageMap[normalizedState][2]);

            _state = state;
        }
예제 #44
0
        private void ResetKey(EPersonaState state)
        {
            state = NormalizeState(state);

            _dynamicKeys[state].SetImages(ImageMap[state][0], ImageMap[state][1]);
        }
예제 #45
0
 private static EPersonaState NormalizeState(EPersonaState state)
 {
     return StateMap.ContainsKey(state) ? StateMap[state] : state;
 }
예제 #46
0
 private static bool EqualStates(EPersonaState first, EPersonaState second)
 {
     return NormalizeState(first) == NormalizeState(second);
 }