void OnNotification( ClientGCMsgProtobuf<CMsgGCTFSpecificItemBroadcast> msg, uint gcAppId )
        {
            string itemName = GetItemName( msg.Body.item_def_index, gcAppId );

            if ( msg.Body.was_destruction )
            {
                IRC.Instance.SendToTag( "gc-tf2", "{0} GC item notification: {1} has destroyed their {2}!", Steam.Instance.GetAppName( gcAppId ), msg.Body.user_name, itemName );
            }
            else
            {
                IRC.Instance.SendToTag( "gc-tf2", "{0} GC item notification: {1} just received a {2}!", Steam.Instance.GetAppName( gcAppId ), msg.Body.user_name, itemName );
            }
        }
示例#2
0
        void OnNotification( ClientGCMsgProtobuf<CMsgGCTFSpecificItemBroadcast> msg )
        {
            string itemName = GetItemName( msg.Body.item_def_index );

            if ( msg.Body.was_destruction )
            {
                IRC.Instance.SendToTag( "tf2-gc", "Item notification: {0} has destroyed their {1}!", msg.Body.user_name, itemName );
            }
            else
            {
                IRC.Instance.SendToTag( "tf2-gc", "Item notification: {0} just received a {1}!", msg.Body.user_name, itemName );
            }
        }
示例#3
0
        void OnWelcome( ClientGCMsgProtobuf<CMsgClientWelcome> msg )
        {
            if ( msg.Body.version != lastGcVersion && lastGcVersion != 0 )
            {
                IRC.Instance.SendToTag( "gc", "New {0} GC session (version: {1}, previous version: {2})", Steam.Instance.GetAppName( Settings.Current.GCApp ), msg.Body.version, lastGcVersion );
            }
            else
            {
                IRC.Instance.SendToTag( "gc", "New {0} GC session (version: {1})", Steam.Instance.GetAppName( Settings.Current.GCApp ), msg.Body.version );
            }

            lastGcVersion = msg.Body.version;
        }
示例#4
0
        void OnItemSchema( ClientGCMsgProtobuf<CMsgUpdateItemSchema> msg )
        {
            if ( lastSchemaVersion != msg.Body.item_schema_version && lastSchemaVersion != 0 )
            {
                IRC.Instance.SendToTag( "gc", "New {0} GC item schema (version: {1:X4}): {2}", Steam.Instance.GetAppName( Settings.Current.GCApp ), lastSchemaVersion, msg.Body.items_game_url );
            }

            lastSchemaVersion = msg.Body.item_schema_version;

            using ( var webClient = new WebClient() )
            {
                webClient.DownloadFileAsync( new Uri( msg.Body.items_game_url ), Path.Combine( Application.StartupPath, "items_game.txt" ) );
            }
        }
示例#5
0
        void OnItemSchema( ClientGCMsgProtobuf<CMsgUpdateItemSchema> msg, uint gcAppId )
        {
            string ircTag = string.Format( "gc-{0}", Settings.Current.GetTagForGCApp( gcAppId ) );

            if ( lastSchemaVersion != msg.Body.item_schema_version && lastSchemaVersion != 0 )
            {
                IRC.Instance.SendToTag( ircTag, "New {0} GC item schema (version: {1:X4}): {2}", Steam.Instance.GetAppName( gcAppId ), lastSchemaVersion, msg.Body.items_game_url );
            }

            lastSchemaVersion = msg.Body.item_schema_version;

            using ( var webClient = new WebClient() )
            {
                string itemsGameFile = string.Format( "items_game_{0}.txt", gcAppId );

                webClient.DownloadFileAsync( new Uri( msg.Body.items_game_url ), Path.Combine( Application.StartupPath, itemsGameFile ) );
            }
        }
示例#6
0
        void OnWatchGame( IPacketGCMsg msg )
        {
            var response = new ClientGCMsgProtobuf<CMsgWatchGameResponse>( msg );

            if ( response.Body.watch_game_result == CMsgWatchGameResponse.WatchGameResult.PENDING )
            {
                DebugLog.WriteLine( "DotaGCClient", "STV details pending..." );
                return;
            }

            if ( response.Body.watch_game_result != CMsgWatchGameResponse.WatchGameResult.READY )
            {
                DebugLog.WriteLine( "DotaGCClient", "Unable to get STV details: {0}", response.Body.watch_game_result );
                return;
            }

            IPEndPoint server = new IPEndPoint(
                NetHelpers.GetIPAddress( response.Body.source_tv_public_addr ),
                ( int )response.Body.source_tv_port
            );

            DebugLog.WriteLine("DotaGCClient", "Got STV details: {0} ({1}) ({2})", server, response.Body.watch_tv_unique_secret_code, server);

            if ( FoundMatch != null )
            {
                FoundMatch( this, new FoundMatchEventArgs
                {
                    Server = server,
                    Password = response.Body.watch_tv_unique_secret_code.ToString(),
                } );
            }
        }
        private void OnClientConnectionStatus(IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgConnectionStatus>(packetMsg).Body;

            LastStatus = msg.status;

            Log.WriteInfo(Name, "Status: {0}", LastStatus);

            string message = string.Format("{0}{1}{2} GC status:{3} {4}", Colors.OLIVE, SteamProxy.GetAppName(AppID), Colors.NORMAL, Colors.OLIVE, LastStatus);

            IRC.SendAnnounce(message);

            if (LastStatus == GCConnectionStatus.GCConnectionStatus_NO_SESSION)
            {
                Timer.Interval = TimeSpan.FromSeconds(5).TotalMilliseconds;
                Timer.Start();
            }

            UpdateStatus(AppID, LastStatus.ToString());
        }
        private void OnWelcome(uint appID, IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgClientWelcome>(packetMsg).Body;

            var info = GetSessionInfo(appID);

            string message = string.Format("{0}{1}{2} new GC session", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL);

            if (info.Version == 0 || info.Version == msg.version)
            {
                message += string.Format(" {0}(version {1})", Colors.DARKGRAY, msg.version);
            }
            else
            {
                message += string.Format(" {0}(version changed from {1} to {2})", Colors.DARKGRAY, info.Version, msg.version);

                IRC.Instance.SendMain(message);
            }

            IRC.Instance.SendAnnounce(message);

            info.Version = msg.version;
            info.Status = GCConnectionStatus.GCConnectionStatus_HAVE_SESSION;
        }
示例#9
0
 void OnConnectionStatus( ClientGCMsgProtobuf<CMsgConnectionStatus> msg )
 {
     IRC.Instance.SendToTag( "gc", "{0} GC status: {1}", Steam.Instance.GetAppName( Settings.Current.GCApp ), msg.Body.status );
 }
示例#10
0
        /// <summary>
        ///     Abandon the current game
        /// </summary>
        public void AbandonGame()
        {
            var abandon = new ClientGCMsgProtobuf <CMsgAbandonCurrentGame>((uint)EDOTAGCMsg.k_EMsgGCAbandonCurrentGame);

            Send(abandon, 570);
        }
        private void OnItemSchemaUpdate(uint appID, IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgUpdateItemSchema>(packetMsg).Body;

            var info = GetSessionInfo(appID);

            if (info.SchemaVersion != 0 && info.SchemaVersion != msg.item_schema_version)
            {
                IRC.Instance.SendMain("{0}{1}{2} item schema updated: {3}{4}{5} -{6} {7}", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL, Colors.DARKGRAY, msg.item_schema_version.ToString("X4"), Colors.NORMAL, Colors.DARKBLUE, msg.items_game_url);
            }

            info.SchemaVersion = msg.item_schema_version;
        }
示例#12
0
        /// <summary>
        ///     Attempt to leave a party.
        /// </summary>
        public void LeaveParty()
        {
            var leaveParty = new ClientGCMsgProtobuf <CMsgLeaveParty>((uint)EGCBaseMsg.k_EMsgGCLeaveParty);

            Send(leaveParty);
        }
示例#13
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Checking for any VAC or game bans...");

                if (Titan.Instance.WebHandle.RequestBanInfo(_steamUser.SteamID.ConvertToUInt64(), out var banInfo))
                {
                    if (banInfo.VacBanned || banInfo.GameBanCount > 0)
                    {
                        _log.Warning("The account has a ban on record. " +
                                     "If the VAC/Game ban ban is from CS:GO, a {Mode} is not possible. " +
                                     "Proceeding with caution.", _reportInfo != null ? "report" :"commend");
                        Result = Result.AccountBanned;
                    }
                }

                _log.Debug("Registering that we're playing CS:GO...");

                _steamFriends.SetPersonaState(EPersonaState.Online);

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                if (_idleInfo != null)
                {
                    foreach (var gameID in _idleInfo.GameID)
                    {
                        var gamesPlayed = new CMsgClientGamesPlayed.GamePlayed
                        {
                            game_id = Convert.ToUInt64(gameID)
                        };

                        if (gameID == 0)
                        {
                            gamesPlayed.game_extra_info = Titan.Instance.UIManager.GetForm <General>(UIType.General)
                                                          .CustomGameName;
                        }

                        playGames.Body.games_played.Add(gamesPlayed);
                    }
                }
                else
                {
                    playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                    {
                        game_id = 730
                    });
                }
                _steamClient.Send(playGames);

                Thread.Sleep(5000);


                if (_idleInfo == null)
                {
                    _log.Debug("Successfully registered playing CS:GO. Sending client hello to CS:GO services.");

                    var clientHello =
                        new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);
                    _gameCoordinator.Send(clientHello, 730);
                }
                else
                {
                    Trigger = TriggerBuilder.Create()
                              .WithIdentity("Idle Trigger - " + JsonAccount.Username + " (Unprotected)", "Titan")
                              .StartNow()
                              .WithSimpleSchedule(x => x
                                                  .WithIntervalInMinutes(_idleInfo.Minutes)
                                                  .WithRepeatCount(1))
                              .Build();

                    Titan.Instance.Scheduler.ScheduleJob(Job, Trigger);

                    _idleInfo.StartTick = DateTime.Now.Ticks;

                    _log.Debug("Successfully registered idling in requested games. Starting scheduler.");
                }
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
            case EResult.AccountLogonDenied:
                _log.Debug("Two Factor Authentification is activated on this account. Please set " +
                           "Sentry to {true} in the accounts.json for this account.", true);

                Stop();

                IsRunning = false;
                Result    = Result.SentryRequired;
                break;

            case EResult.InvalidPassword:
            case EResult.NoConnection:
            case EResult.Timeout:
            case EResult.TryAnotherCM:
            case EResult.TwoFactorCodeMismatch:
            case EResult.ServiceUnavailable:
                _log.Error("Unable to connect to Steam: {Reason}. Retrying...", callback.ExtendedResult);

                break;

            case EResult.RateLimitExceeded:
                _log.Debug("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Stop();

                IsRunning = false;
                Result    = Result.RateLimit;
                break;

            case EResult.AccountDisabled:
                _log.Error("This account has been permanently disabled by the Steam network.");

                Stop();

                IsRunning = false;
                Result    = Result.AccountBanned;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);

                Stop();
                IsRunning = false;
                break;
            }
        }
示例#14
0
        private void HandleGuildData(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAGuildSDO>(obj);

            Client.PostCallback(new GuildDataResponse(resp.Body));
        }
示例#15
0
        private void HandleProfileCardResponse(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAProfileCard>(obj);

            Client.PostCallback(new ProfileCardResponse(resp.Body));
        }
示例#16
0
        private void HandleGuildCancelInviteResponse(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAGuildCancelInviteResponse>(obj);

            Client.PostCallback(new GuildCancelInviteResponse(resp.Body));
        }
示例#17
0
        private void HandleGuildAccountRoleResponse(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAGuildSetAccountRoleResponse>(obj);

            Client.PostCallback(new GuildSetRoleResponse(resp.Body));
        }
示例#18
0
        /// <summary>
        ///     GC tells us if there are tournaments running.
        /// </summary>
        /// <param name="obj"></param>
        private void HandleLiveLeageGameUpdate(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTALiveLeagueGameUpdate>(obj);

            Client.PostCallback(new LiveLeagueGameUpdate(resp.Body));
        }
        private void OnItemSchemaUpdate(IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgUpdateItemSchema>(packetMsg).Body;

            if (LastSchemaVersion != 0 && LastSchemaVersion != msg.item_schema_version)
            {
                Log.WriteInfo(Name, "Schema change from {0} to {1}", LastSchemaVersion, msg.item_schema_version);

                IRC.SendMain("{0}{1}{2} item schema updated: {3}{4}{5} -{6} {7}", Colors.OLIVE, SteamProxy.GetAppName(AppID), Colors.NORMAL, Colors.DARK_GRAY, msg.item_schema_version.ToString("X4"), Colors.NORMAL, Colors.DARK_BLUE, msg.items_game_url);
            }

            LastSchemaVersion = msg.item_schema_version;
        }
示例#20
0
        /// <summary>
        ///     Respond to a ping()
        /// </summary>
        public void Pong()
        {
            var pingResponse = new ClientGCMsgProtobuf <CMsgGCClientPing>((uint)EGCBaseClientMsg.k_EMsgGCPingResponse);

            Send(pingResponse);
        }
        public void Hello()
        {
            var clientHello = new ClientGCMsgProtobuf<CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            SteamGameCoordinator.Send(clientHello, AppID);
        }
示例#22
0
        /// <summary>
        /// Requests the entire pro team list.
        /// </summary>
        public void RequestProTeamList()
        {
            var req = new ClientGCMsgProtobuf <CMsgDOTAProTeamListRequest>((uint)EDOTAGCMsg.k_EMsgGCProTeamListRequest);

            Send(req);
        }
示例#23
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Checking for any VAC or game bans...");

                var banInfo = Titan.Instance.BanManager.GetBanInfoFor(_steamUser.SteamID.ConvertToUInt64());
                if (banInfo != null && (banInfo.VacBanned || banInfo.GameBanCount > 0))
                {
                    _log.Warning("The account has a ban on record. " +
                                 "If the VAC/Game ban ban is from CS:GO, a {Mode} is not possible. " +
                                 "Proceeding with caution.", _reportInfo != null ? "report" :"commend");
                    Result = Result.AccountBanned;
                }

                _log.Debug("Registering that we're playing CS:GO...");

                _steamFriends.SetPersonaState(EPersonaState.Online);

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = 730
                });
                _steamClient.Send(playGames);

                Thread.Sleep(5000);

                _log.Debug("Successfully registered playing CS:GO. Sending client hello to CS:GO services.");

                var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);
                _gameCoordinator.Send(clientHello, 730);
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
                _log.Information("Opening UI form to get the 2FA Steam Guard App Code...");

                if (_sgAccount != null)
                {
                    _log.Debug("A shared secret has been provided: automaticly generating it...");

                    _2FactorCode = _sgAccount.GenerateSteamGuardCode();
                }
                else
                {
                    Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                    UIType.TwoFactorAuthentification,
                                                    new TwoFactorAuthForm(Titan.Instance.UIManager, this, null)));

                    while (string.IsNullOrEmpty(_2FactorCode))
                    {
                        /* Wait until the Form inputted the 2FA code from the Steam Guard App */
                    }
                }

                _log.Information("Received 2FA Code: {Code}", _2FactorCode);
                break;

            case EResult.AccountLogonDenied:
                _log.Information("Opening UI form to get the Auth Token from EMail...");

                Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(UIType.TwoFactorAuthentification,
                                                                                    new TwoFactorAuthForm(Titan.Instance.UIManager, this, callback.EmailDomain)));

                while (string.IsNullOrEmpty(_authCode))
                {
                    /* Wait until the Form inputted the Auth code from the Email Steam sent */
                }

                _log.Information("Received Auth Token: {Code}", _authCode);
                break;

            case EResult.ServiceUnavailable:
                _log.Error("Steam is currently offline. Please try again later.");

                Stop();

                IsRunning = false;
                break;

            case EResult.RateLimitExceeded:
                _log.Debug("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Stop();

                IsRunning = false;
                Result    = Result.RateLimit;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);

                Stop();

                IsRunning = false;
                break;
            }
        }
示例#24
0
        /// <summary>
        ///     Flip the teams in the current lobby
        /// </summary>
        public void PracticeLobbyFlip()
        {
            var flip = new ClientGCMsgProtobuf <CMsgFlipLobbyTeams>((uint)EDOTAGCMsg.k_EMsgGCFlipLobbyTeams);

            Send(flip);
        }
        private void OnConnectionStatus(uint appID, IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgConnectionStatus>(packetMsg).Body;

            GetSessionInfo(appID).Status = msg.status;

            string extraInfo = string.Empty;

            if (msg.status == GCConnectionStatus.GCConnectionStatus_NO_SESSION_IN_LOGON_QUEUE)
            {
                extraInfo = string.Format(" {0}(queue: {1}/{2}, waited {3} of an estimated {4} seconds)",
                    Colors.DARKGRAY, msg.queue_position, msg.queue_size, msg.wait_seconds, msg.estimated_wait_seconds_remaining
                );
            }

            IRC.Instance.SendAnnounce("{0}{1}{2} status:{3} {4}{5}", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL, Colors.OLIVE, msg.status, extraInfo);
        }
示例#26
0
        /// <summary>
        ///     Requests information about all current guilds the client is in
        /// </summary>
        public void RequestGuildData()
        {
            var request = new ClientGCMsgProtobuf <CMsgDOTARequestGuildData>((uint)EDOTAGCMsg.k_EMsgGCRequestGuildData);

            Send(request);
        }
        private void OnSystemMessage(uint appID, IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgSystemBroadcast>(packetMsg).Body;

            IRC.Instance.SendMain("{0}{1}{2} system message:{3} {4}", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL, Colors.OLIVE, msg.message);
        }
示例#28
0
        private void HandleInvitationCreated(IPacketGCMsg obj)
        {
            var msg = new ClientGCMsgProtobuf <CMsgInvitationCreated>(obj);

            Client.PostCallback(new InvitationCreated(msg.Body));
        }
示例#29
0
 void OnSystemMessage( ClientGCMsgProtobuf<CMsgSystemBroadcast> msg )
 {
     IRC.Instance.SendToTag( "gc", "{0} GC system message: {1}", Steam.Instance.GetAppName( Settings.Current.GCApp ), msg.Body.message );
 }
示例#30
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Checking for any VAC or game bans...");

                var banInfo = Titan.Instance.BanManager.GetBanInfoFor(_steamUser.SteamID.ConvertToUInt64());
                if (banInfo != null && (banInfo.VacBanned || banInfo.GameBanCount > 0))
                {
                    _log.Warning("The account has a ban on record. " +
                                 "If the VAC/Game ban ban is from CS:GO, a {Mode} is not possible. " +
                                 "Proceeding with caution.", _reportInfo != null ? "report" :"commend");
                    Result = Result.AccountBanned;
                }

                _log.Debug("Registering that we're playing CS:GO...");

                _steamFriends.SetPersonaState(EPersonaState.Online);

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = 730
                });
                _steamClient.Send(playGames);

                Thread.Sleep(5000);

                _log.Debug("Successfully registered playing CS:GO. Sending client hello to CS:GO services.");

                var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);
                _gameCoordinator.Send(clientHello, 730);
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
            case EResult.AccountLogonDenied:
                _log.Debug("Two Factor Authentification is activated on this account. Please set " +
                           "Sentry to {true} in the accounts.json for this account.", true);

                Stop();

                IsRunning = false;
                Result    = Result.SentryRequired;
                break;

            case EResult.ServiceUnavailable:
                _log.Error("Steam is currently offline. Please try again later.");

                Stop();

                IsRunning = false;
                break;

            case EResult.RateLimitExceeded:
                _log.Debug("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Stop();

                IsRunning = false;
                Result    = Result.RateLimit;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);
                Stop();
                IsRunning = false;
                break;
            }
        }
示例#31
0
        private void HandleOtherLeftChannel(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAOtherLeftChatChannel>(obj);

            Client.PostCallback(new OtherLeftChannel(resp.Body));
        }
示例#32
0
        void OnGCClientWelcome(IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf <CMsgClientWelcome>(packetMsg);

            Logger.WriteLine("GC version: " + msg.Body.version);
        }
示例#33
0
        private void OnSystemMessage(uint appID, IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf <CMsgSystemBroadcast>(packetMsg).Body;

            IRC.Instance.SendMain("{0}{1}{2} system message:{3} {4}", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL, Colors.OLIVE, msg.message);
        }
示例#34
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Registering that we're playing app {id}...", GetAppID());

                _steamFriends.SetPersonaState(EPersonaState.Online);

                /*if (!Titan.Instance.Options.NoSteamGroup)
                 * {
                 *  LoginWebInterface(callback.ClientSteamID);
                 *  JoinSteamGroup(); // https://steamcommunity.com/groups/TitanReportBot
                 *  return;
                 * }*/

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = GetAppID()
                });
                _steamClient.Send(playGames);

                Thread.Sleep(TimeSpan.FromSeconds(2));

                _log.Debug("Successfully registered app {game}. Sending client hello to gc services.", GetAppID());

                switch (GetAppID())
                {
                case CSGO_APPID:
                {
                    var clientHello = new ClientGCMsgProtobuf <SteamKit2.GC.CSGO.Internal.CMsgClientHello>(
                        (uint)SteamKit2.GC.CSGO.Internal.EGCBaseClientMsg.k_EMsgGCClientHello
                        );

                    _gameCoordinator.Send(clientHello, GetAppID());
                    break;
                }

                case TF2_APPID:
                {
                    var clientInit = new ClientGCMsgProtobuf <CMsgTFClientInit>(
                        (uint)ETFGCMsg.k_EMsgGC_TFClientInit
                        )
                    {
                        Body =
                        {
                            client_version          = 4478108, // up2date as of 17th may 2018
                            client_versionSpecified = true,

                            language          =    0,// We are english
                            languageSpecified = true
                        }
                    };

                    _gameCoordinator.Send(clientInit, GetAppID());

                    var clientHello = new ClientGCMsgProtobuf <SteamKit2.GC.TF2.Internal.CMsgClientHello>(
                        (uint)SteamKit2.GC.TF2.Internal.EGCBaseClientMsg.k_EMsgGCClientHello
                        );

                    _gameCoordinator.Send(clientHello, GetAppID());
                    break;
                }
                }
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
            case EResult.AccountLogonDenied:
                _log.Error("Two Factor Authentification is activated on this account. Please set " +
                           "Sentry to {true} in the accounts.json for this account.", true);

                Result = Result.SentryRequired;
                Stop();
                break;

            case EResult.InvalidPassword:
                _log.Error("Unable to connect to Steam: {mismatch}. Please check your account details.",
                           "Invalid Password");

                Result = Result.Code2FAWrong;     // FIXME: Might want to specify a real result sometime
                Stop();
                break;

            case EResult.TwoFactorCodeMismatch:
            case EResult.NoConnection:
            case EResult.Timeout:
            case EResult.TryAnotherCM:
            case EResult.ServiceUnavailable:
                _log.Error("Unable to connect to Steam: {Reason}. Retrying...", callback.ExtendedResult);

                break;

            case EResult.RateLimitExceeded:
                _log.Debug("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Result = Result.RateLimit;
                Stop();
                break;

            case EResult.AccountDisabled:
                _log.Error("This account has been permanently disabled by the Steam network.");

                Result = Result.AccountBanned;
                Stop();
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result,
                           callback.ExtendedResult);

                Stop();
                break;
            }
        }
        private void OnClientWelcome(IPacketGCMsg packetMsg)
        {
            Timer.Stop();

            var msg = new ClientGCMsgProtobuf<CMsgClientWelcome>(packetMsg).Body;

            Log.WriteInfo(Name, "New GC session ({0} -> {1})", LastVersion, msg.version);

            string message = string.Format("New {0}{1}{2} GC session", Colors.OLIVE, SteamProxy.GetAppName(AppID), Colors.NORMAL);

            if (LastVersion == -1 || LastVersion == msg.version)
            {
                message += string.Format(" {0}(version {1})", Colors.DARK_GRAY, msg.version);
            }
            else
            {
                message += string.Format(" {0}(version changed from {1} to {2})", Colors.DARK_GRAY, LastVersion, msg.version);
            }

            if (LastVersion != -1 && (LastVersion != msg.version || LastStatus != GCConnectionStatus.GCConnectionStatus_HAVE_SESSION))
            {
                IRC.SendMain(message);
            }

            IRC.SendAnnounce(message);

            LastVersion = (int)msg.version;
            LastStatus = GCConnectionStatus.GCConnectionStatus_HAVE_SESSION;

            UpdateStatus(AppID, LastStatus.ToString());
        }
示例#36
0
        void OnSystemMessage(ClientGCMsgProtobuf <CMsgSystemBroadcast> msg, uint gcAppId)
        {
            string ircTag = string.Format("gc-{0}", Settings.Current.GetTagForGCApp(gcAppId));

            IRC.Instance.SendToTag(ircTag, "{0} GC system message: {1}", Steam.Instance.GetAppName(gcAppId), msg.Body.message);
        }
        private void OnSystemMessage(IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgSystemBroadcast>(packetMsg).Body;

            Log.WriteInfo(Name, "Message: {0}", msg.message);

            IRC.SendMain("{0}{1}{2} system message:{3} {4}", Colors.OLIVE, SteamProxy.GetAppName(AppID), Colors.NORMAL, Colors.OLIVE, msg.message);
        }
示例#38
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Registering that we're playing CS:GO...");

                _steamFriends.SetPersonaState(EPersonaState.Online);

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = GetAppID()
                });
                _steamClient.Send(playGames);

                Thread.Sleep(TimeSpan.FromSeconds(2));

                _log.Debug("Successfully registered playing CS:GO. Sending client hello to CS:GO services.");

                var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>(
                    (uint)EGCBaseClientMsg.k_EMsgGCClientHello
                    );

                _gameCoordinator.Send(clientHello, GetAppID());
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
                if (!string.IsNullOrWhiteSpace(JsonAccount.SharedSecret))
                {
                    _log.Debug("A shared secret has been provided: automatically generating it...");

                    _2FactorCode = _sharedSecretGenerator.GenerateCode();
                }
                else
                {
                    _log.Information("Opening UI form to get the 2FA Steam Guard App Code...");

                    Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                    UIType.TwoFactorAuthentification, new _2FAForm(this)
                                                    ));

                    while (string.IsNullOrEmpty(_2FactorCode))
                    {
                        /* Wait until we receive the Steam Guard code from the UI */
                    }
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received 2FA Code: {Code}", _2FactorCode);
                }
                break;

            case EResult.AccountLogonDenied:
                _log.Information("Opening UI form to get the Auth Token from EMail...");

                Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                UIType.TwoFactorAuthentification, new _2FAForm(this, callback.EmailDomain)
                                                ));

                while (string.IsNullOrEmpty(_authCode))
                {
                    /* Wait until we receive the Auth Token from the UI */
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received Auth Token: {Code}", _authCode);
                }
                break;

            case EResult.ServiceUnavailable:
                _log.Error("Steam is currently offline. Please try again later.");

                Stop();
                break;

            case EResult.RateLimitExceeded:
                _log.Error("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Result = Result.RateLimit;
                Stop();
                break;

            case EResult.TwoFactorCodeMismatch:
            case EResult.TwoFactorActivationCodeMismatch:
            case EResult.Invalid:
                _log.Error("Invalid Steam Guard code provided. Reasking after reconnecting.");

                _authCode    = null;
                _2FactorCode = null;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);

                Stop();
                break;
            }
        }
示例#39
0
        ////////////////////////////////////////////////////
        // PAYLOADS
        ////////////////////////////////////////////////////

        public IClientGCMsg GetReportPayload(int payloadID = 0)
        {
            switch (_reportInfo.AppID)
            {
            case CSGO_APPID:
            {
                var payload = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_ClientReportPlayer>(
                    (uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer
                    )
                {
                    Body =
                    {
                        account_id = _reportInfo.SteamID.AccountID,
                        match_id   = _reportInfo.MatchID,

                        rpt_aimbot     = Convert.ToUInt32(_reportInfo.AimHacking),
                        rpt_wallhack   = Convert.ToUInt32(_reportInfo.WallHacking),
                        rpt_speedhack  = Convert.ToUInt32(_reportInfo.OtherHacking),
                        rpt_teamharm   = Convert.ToUInt32(_reportInfo.Griefing),
                        rpt_textabuse  = Convert.ToUInt32(_reportInfo.AbusiveText),
                        rpt_voiceabuse = Convert.ToUInt32(_reportInfo.AbusiveVoice)
                    }
                };

                return(payload);
            }

            case TF2_APPID:
            {
                switch (payloadID)
                {
                case 0:
                {
                    var payload = new ClientGCMsgProtobuf <SteamKit2.GC.TF2.Internal.CMsgGCReportAbuse>(
                        (uint)SteamKit2.GC.TF2.Internal.EGCItemMsg.k_EMsgGC_ReportAbuse
                        )
                    {
                        Body =
                        {
                            target_steam_id                  = _reportInfo.SteamID.ConvertToUInt64(),
                            target_game_server_ipSpecified   = true,

                            abuse_type            =                                    10, // TODO: Find out this magic value
                            abuse_typeSpecified   = true,
                            content_type          =                                    13, // TODO: Find out this magic value
                            content_typeSpecified = true,

                            description          = StringUtil.GetRandomKisakQuote(), // Hope the guys at the TF2 Department will mock him for this
                            descriptionSpecified = true,

                            target_game_server_portSpecified = false,
                            gidSpecified                     = false
                        }
                    };

                    return(payload);
                }

                case 1:
                {
                    /*var payload = new ClientGCMsgProtobuf<CMsgGC_ReportPlayer>(
                     *  (uint) ETFGCMsg.k_EMsgGC_ReportPlayer
                     * )
                     * {
                     *  Body =
                     *  {
                     *      account_id_target = _reportInfo.SteamID.AccountID,
                     *      account_id_targetSpecified = true,
                     *
                     *      reason = _reportInfo.Reason,
                     *      reasonSpecified = true
                     *  }
                     * };
                     *
                     * return payload;*/
                    return(null);
                }
                }

                break;
            }
            }

            return(null);
        }
示例#40
0
 /// <summary>
 /// Handle when a cache is destroyed.
 /// </summary>
 /// <param name="obj">Message</param>
 public void HandleCacheDestroy(IPacketGCMsg obj)
 {
     var dest = new ClientGCMsgProtobuf<CMsgSOSingleObject>(obj);
     if (PartyInvite != null && dest.Body.type_id == (int) CSOTypes.PARTYINVITE)
     {
         PartyInvite = null;
         Client.PostCallback(new PartyInviteLeave(null));
     }
     else if (Lobby != null && dest.Body.type_id == (int) CSOTypes.LOBBY)
     {
         Lobby = null;
         Client.PostCallback(new PracticeLobbyLeave(null));
     }
     else if (Party != null && dest.Body.type_id == (int) CSOTypes.PARTY)
     {
         Party = null;
         Client.PostCallback(new PartyLeave(null));
     }
     else if (LobbyInvite != null && dest.Body.type_id == (int) CSOTypes.LOBBYINVITE)
     {
         LobbyInvite = null;
         Client.PostCallback(new LobbyInviteLeave(null));
     }
 }
示例#41
0
        private static void OnGetPlayerMatchHistoryResponse(ClientGCMsgProtobuf <CMsgDOTAGetPlayerMatchHistoryResponse> response)
        {
            var accountId = _currentHistoryRequest;

            try {
                var player = _lobbyMembers.Where(m => m.AccountId == _currentHistoryRequest.ToString()).SingleOrDefault();
                player.PlayerMatches = response.Body.matches.Select(m => new PlayerMatch()
                {
                    MatchId = m.match_id.ToString()
                }).ToList();
                _currentHistoryRequest = 0;
                //_logger.Info("Match history - Player: " + player.Name + " - Matches: " + player.PlayerMatches.Count);
                using (IRepository repository = new Repository(_dbOptions)) {
                    var account = repository.Accounts.Include(a => a.Bans).Where(m => m.AccountId == player.AccountId).FirstOrDefault();
                    var newUser = player.PlayerMatches.Count < _game.PlayerMinGamesRequired;
                    if (newUser && !_test)
                    {
                        var playerId = SteamHelper.ConvertIDToUint32(ulong.Parse(player.AccountId));
                        if (_lobbyMembersCount < _map.MaxPlayers)
                        {
                            player.Kicked = true;
                            SendChatMessage(String.Format(_game.NewAccountKickMessage, player.Name));
                            _dotaClient.KickLobbyMember(playerId);
                        }
                        _playersToKick.Add(playerId);
                    }
                    if (account == null)
                    {
                        account = new Account()
                        {
                            AccountId    = player.AccountId,
                            NewUser      = newUser,
                            AccountNames = new List <AccountName>()
                            {
                                new AccountName()
                                {
                                    Name = player.Name
                                }
                            },
                            Bans    = new List <Ban>(),
                            Matches = new List <AccountMatch>()
                        };
                        repository.AddAccount(account);
                        repository.SaveChanges();
                    }
                    else
                    {
                        var ban = account.Bans.Where(b => b.Expires > DateTime.UtcNow).OrderByDescending(b => b.Expires).FirstOrDefault();
                        if (ban != null && !_test)
                        {
                            var playerId = SteamHelper.ConvertIDToUint32(ulong.Parse(player.AccountId));
                            if (_lobbyMembersCount < _map.MaxPlayers)
                            {
                                player.Kicked = true;
                                SendChatMessage(String.Format(_game.BannedAccountKickMessage, player.Name, ban.Reason, ban.Expires.ToString("d") + " " + ban.Expires.ToString("t")));
                                _dotaClient.KickLobbyMember(playerId);
                            }
                            _playersToKick.Add(playerId);
                        }
                        if (account.NewUser && !newUser)
                        {
                            account.NewUser = false;
                            repository.SaveChanges();
                        }
                    }
                }
            } catch (Exception e) {
                _logger.Error("Error occurred while processing player history response - Account ID: " + accountId, e);
            }
        }
示例#42
0
 private void HandleCacheUnsubscribed(IPacketGCMsg obj)
 {
     var unSub = new ClientGCMsgProtobuf<CMsgSOCacheUnsubscribed>(obj);
     if (Lobby != null && unSub.Body.owner_soid.id == Lobby.lobby_id)
     {
         Lobby = null;
         Client.PostCallback(new PracticeLobbyLeave(unSub.Body));
     }
     else if (Party != null && unSub.Body.owner_soid.id == Party.party_id)
     {
         Party = null;
         Client.PostCallback(new PartyLeave(unSub.Body));
     }
     else if (PartyInvite != null && unSub.Body.owner_soid.id == PartyInvite.group_id)
     {
         PartyInvite = null;
         Client.PostCallback(new PartyInviteLeave(unSub.Body));
     }
     else
         Client.PostCallback(new CacheUnsubscribed(unSub.Body));
 }
        private void OnWelcome(uint appID, IPacketGCMsg packetMsg)
        {
            uint version = 0;

            switch (appID)
            {
                case 730:
                    version = new ClientGCMsgProtobuf<SteamKit2.GC.CSGO.Internal.CMsgClientWelcome>(packetMsg).Body.version;
                    break;

                case 440:
                    version = new ClientGCMsgProtobuf<SteamKit2.GC.TF2.Internal.CMsgClientWelcome>(packetMsg).Body.version;
                    break;

                default:
                    version = new ClientGCMsgProtobuf<CMsgClientWelcome>(packetMsg).Body.version;
                    break;
            }

            var info = GetSessionInfo(appID);

            string message = string.Format("{0}{1}{2} new GC session", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL);

            if (info.Version == 0 || info.Version == version)
            {
                message += string.Format(" {0}(version {1})", Colors.DARKGRAY, version);
            }
            else
            {
                message += string.Format(" {0}(version changed from {1} to {2})", Colors.DARKGRAY, info.Version, version);
            }

            IRC.Instance.SendAnnounce(message);

            info.Version = version;
            info.Status = GCConnectionStatus.GCConnectionStatus_HAVE_SESSION;
        }
示例#44
0
        static public async void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback == null)
            {
                return;
            }
            TwoFactorCode = null;
            AuthCode      = null;
            Authcodelegit = false;
            TwoFactorCode = null;

            switch (callback.Result)
            {
            case EResult.TwoFactorCodeMismatch:
            case EResult.AccountLoginDeniedNeedTwoFactor:
                if (Config.SteamLoginToken != null)
                {
                    SteamGuardAccount account = new SteamGuardAccount();
                    account.SharedSecret = Config.SteamLoginToken;
                    TwoFactorCode        = account.GenerateSteamGuardCode();
                    return;
                }
                TwoFactorCode = null;
                Authcodelegit = false;
                while (Authcodelegit == false)
                {
                    NeedSteamGuardKey = true;
                    informationsteam  = (String.Format("Введи Steam Guard Ключ который пришел на мобильный телефон: ", callback.EmailDomain));
                    if (mainform.SteamAuthCode != null)
                    {
                        TwoFactorCode     = mainform.SteamAuthCode;
                        Authcodelegit     = true;
                        NeedSteamGuardKey = false;
                    }
                }
                return;

            case EResult.AccountLogonDenied:
                AuthCode      = null;
                Authcodelegit = false;
                if (Config.emaillogin != "None")
                {
                    informationsteam = (String.Format("Получаем почту..."));
                    Thread.Sleep(10000);
                    AuthCode = getmsgemail(Config.SteamLogin);
                    if (AuthCode == null)
                    {
                        while (Authcodelegit == false)
                        {
                            NeedSteamGuardKey = true;
                            informationsteam  = (String.Format("Введи Steam Guard Ключ который пришел на Email {0}: ", callback.EmailDomain));
                            if (mainform.SteamAuthCode != null)
                            {
                                AuthCode          = mainform.SteamAuthCode;
                                Authcodelegit     = true;
                                NeedSteamGuardKey = false;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    while (Authcodelegit == false)
                    {
                        NeedSteamGuardKey = true;
                        informationsteam  = (String.Format("Введи Steam Guard Ключ который пришел на Email {0}: ", callback.EmailDomain));
                        if (mainform.SteamAuthCode != null)
                        {
                            AuthCode          = mainform.SteamAuthCode;
                            Authcodelegit     = true;
                            NeedSteamGuardKey = false;
                        }
                    }
                }
                return;

            case EResult.InvalidPassword:
                informationsteam = (String.Format("Unable to login to Steam: " + callback.Result));
                if (!File.Exists(SentryFileName) && !File.Exists(LoginKeyFileName))
                {
                    informationsteam = "Неверный Пароль";
                    errorlog(Config.SteamLogin + ":Неверный Пароль");
                }
                if (File.Exists(SentryFileName))
                {
                    informationsteam = (String.Format("Удаляю старый ключ..."));
                    File.Delete(SentryFileName);
                }

                if (File.Exists(LoginKeyFileName))
                {
                    informationsteam = (String.Format("Удаляю старый ключ..."));
                    File.Delete(LoginKeyFileName);
                }
                return;

            case EResult.OK:
                informationsteam = (String.Format("Успешно подключен!"));
                break;

            default:
                informationsteam = (String.Format("Немогу подключитьсья к стиму: {0} / {1}", callback.Result, callback.ExtendedResult));
                errorlog(Config.SteamLogin + String.Format(":Немогу подключитьсья к стиму: {0} / {1}", callback.Result, callback.ExtendedResult));
                return;
            }
            informationsteam = (String.Format("Запускаю CSGO..."));
            if (kicksession == true)
            {
                var kickSession = new ClientMsgProtobuf <CMsgClientKickPlayingSession>(EMsg.ClientKickPlayingSession);
                kickSession.Body.only_stop_game = false;
                SteamClient.Send(kickSession);
                AbandonCompGame();
                kicksession = false;
                isRunning   = false;
            }


            var request = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(730),
            });

            SteamClient.Send(request);

            await Task.Delay(5000).ConfigureAwait(false);

            var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            clientHello.Body.version = 328;
            SteamGameCoordinator.Send(clientHello, 730);
        }
示例#45
0
        /// <summary>
        ///     Cancel the queue for a match
        /// </summary>
        public void StopQueue()
        {
            var queue = new ClientGCMsgProtobuf <CMsgStopFindingMatch>((uint)EDOTAGCMsg.k_EMsgGCStopFindingMatch);

            Send(queue, 570);
        }
示例#46
0
        private void OnMessageCall(SteamGameCoordinator.MessageCallback callback)
        {
            Console.WriteLine(callback.EMsg.ToString());

            switch (callback.EMsg)
            {
            case (uint)EGCBaseClientMsg.k_EMsgGCClientHello:
            case (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome:
            {
                sw.Stop();

                var ClientHello = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_MatchmakingGC2ClientHello>((uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello);
                SteamGameCoordinator.Send(ClientHello, 730);

                break;
            }

            case (uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello:
            {
                var details = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_MatchmakingGC2ClientHello>(callback.Message);

                if (details.Body.vac_banned == 0)
                {
                    var penalty_seconds = Math.Abs(details.Body.penalty_seconds);
                    if (penalty_seconds > 0 && !AcknowledgedPenalty)
                    {
                        AcknowledgedPenalty = true;

                        Console.WriteLine("k_EMsgGCCStrike15_v2_AcknowledgePenalty");

                        var AcknowledgePenalty = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_AcknowledgePenalty>((uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_AcknowledgePenalty);
                        AcknowledgePenalty.Body.acknowledged = 1;

                        SteamGameCoordinator.Send(AcknowledgePenalty, 730);

                        Thread.Sleep(SLEEP);

                        var ClientHello = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_MatchmakingGC2ClientHello>((uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello);
                        SteamGameCoordinator.Send(ClientHello, 730);

                        return;
                    }

                    if (details.Body.penalty_reason == 18)
                    {
                        steamUser.LogOff();
                        return;
                    }

                    if (details.Body.penalty_reason == 10)
                    {
                        Console.WriteLine($"{username}: global cooldown");
                        steamUser.LogOff();
                        return;
                    }

                    if (details.Body.ranking == null || penalty_seconds > 0)
                    {
                        Console.WriteLine($"{username}: penalty_seconds > 0");
                        Console.WriteLine($"{username}: penalty_reason = {details.Body.penalty_reason}");

                        Thread.Sleep(SLEEP);

                        var ClientHello = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_MatchmakingGC2ClientHello>((uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello);
                        SteamGameCoordinator.Send(ClientHello, 730);

                        return;
                    }

                    var extra = extraData(steamid);

                    DataAccess.AddAccounts(extra.public_name, username, password, (int)details.Body.ranking.wins, details.Body.player_level, extra.profile_link, extra.profile_pic);
                    Debug.WriteLine("Account added to database");
                    accounts.Add(new AccountDetails()
                        {
                            public_name     = extra.public_name,
                            profile_url     = extra.profile_link,
                            profile_img_url = extra.profile_pic,
                            login           = $"{username}:{password}",
                            steam64id       = steamid,
                            penalty_reason  = (int)details.Body.penalty_reason,
                            penalty_seconds = (int)details.Body.penalty_seconds,
                            wins            = (int)details.Body.ranking.wins,
                            rank            = details.Body.player_level
                        });
                }
                steamUser.LogOff();
                break;
            }

            default: break;
            }
        }
        private void OnItemBroadcast(uint appID, IPacketGCMsg packetMsg)
        {
            if (appID != 440)
            {
                // This message should be TF2 specific, but just in case
                return;
            }

            var msg = new ClientGCMsgProtobuf<CMsgGCTFSpecificItemBroadcast>(packetMsg).Body;

            var itemName = GetItemName(441, msg.item_def_index);

            IRC.Instance.SendMain("{0}{1}{2} item notification: {3}{4}{5} {6} {7}{8}{9}!",
                Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL,
                Colors.BLUE, msg.user_name, Colors.NORMAL,
                msg.was_destruction ? "has destroyed their" : "just received a",
                Colors.OLIVE, itemName, Colors.NORMAL
            );
        }
示例#48
0
        static void OnChatMessage(SteamFriends.FriendMsgCallback callback)
        {
            string[] args;

            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                if (callback.Message.Length > 1)
                {
                    if (callback.Message.Remove(1) == "!")
                    {
                        string command = callback.Message;
                        if (callback.Message.Contains(" "))
                        {
                            command = callback.Message.Remove(callback.Message.IndexOf(' '));
                        }

                        switch (command)
                        {
                        case "!coder":
                            args = seperate(0, ' ', callback.Message);
                            Console.WriteLine("[i] Your Steamfriend {0} has used the command !coder", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Coder: Logan.");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Coded in: C#");

                            break;

                            #region Clear
                        case "!clear":
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, " ");
                            break;

                            #endregion
                        case "!send":
                            args = seperate(2, ' ', callback.Message);

                            if (args[0] == "-1")
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Correct Syntax: !send [Friend] [message]");
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Please write the name in lower cases!");
                                return;
                            }
                            Console.WriteLine("[i] Your Steamfriend {0} has orderd you to send " + args[1] + " " + args[2] + " !", steamFriends.GetFriendPersonaName(callback.Sender));
                            for (int i = 0; i < steamFriends.GetFriendCount(); i++)
                            {
                                SteamID friend = steamFriends.GetFriendByIndex(i);
                                if (steamFriends.GetFriendPersonaName(friend).ToLower().Contains(args[1]))
                                {
                                    steamFriends.SendChatMessage(friend, EChatEntryType.ChatMsg, args[2]);
                                }
                            }
                            break;

                        case "!help":
                            Console.WriteLine("[i] Your Steamfriend {0} has used the Command !help", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Welcome friend. So you need help? Type !ger for german help or !eng for english help.");
                            break;

                        case "!ger":
                            Console.WriteLine("[i] Your Steamfriend {0} has used the Command !ger", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Hallo, Du hast die ehre mit dem wundervollen Steambot von mir zu schreiben! Achtung: Ich bin KEIN Tradebot. Ich mach diesen BOT an wenn ich den Account gerade nicht benutze / AFK bin. Also kannst du dich mit ihm unterhalten :) Benutze !commands für eine volle commands liste. Viel Spaß :)");
                            break;

                        case "!eng":
                            Console.WriteLine("[i] Your Steamfriend {0} has used the Command !eng", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Nothing to see here. Wait for an Update! :)");
                            break;

                        case "!steamID":
                            Console.WriteLine("[i] Your Steamfriend {0} has used the Command !steamID", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Your SteamID is: " + callback.Sender);

                            break;

                        case "!friends":
                            Console.WriteLine("[i] Your Steamfriend {0} has used !friends", steamFriends.GetFriendPersonaName(callback.Sender));
                            for (int i = 0; i < steamFriends.GetFriendCount(); i++)
                            {
                                SteamID friend = steamFriends.GetFriendByIndex(i);
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Friend: " + steamFriends.GetFriendPersonaName(friend) + " State: " + steamFriends.GetFriendPersonaState(friend));
                            }
                            break;

                        case "!music":
                            Console.WriteLine("[i] Your Steamfriend {0} has used !music", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The music I often listen to:");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "https://www.youtube.com/watch?v=GSWJ21L4SfQ");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "https://www.youtube.com/watch?v=O81P0dWo6yg");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "https://www.youtube.com/watch?v=cEU1NV3efDo");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "https://www.youtube.com/watch?v=09wdQP1FFR0");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "https://www.youtube.com/watch?v=_y8p6uQDH4s");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "https://www.youtube.com/watch?v=pVLmZMjxfjw");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Stay tuned for updates :)");

                            break;

                        case "!teamspeak":
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "XXXXXXXXX");
                            break;

                        case "!imp":
                            args = seperate(1, ' ', callback.Message);
                            for (int i = 0; i < steamFriends.GetFriendCount(); i++)
                            {
                                SteamID friend = steamFriends.GetFriendByIndex(i);
                                if (args[0] == "-1")
                                {
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Correct Syntax: !imp [message]");
                                    return;
                                }
                                if (steamFriends.GetFriendPersonaName(friend).Contains("Logan"))
                                {
                                    steamFriends.SendChatMessage(friend, EChatEntryType.ChatMsg, "Important message from: " + steamFriends.GetFriendPersonaName(callback.Sender) + ": " + args[1]);
                                    Console.Beep();
                                }
                            }
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Message sent succesfully!");
                            Console.WriteLine("\n\n==============================================================");
                            Console.WriteLine("IMPORTANT: You have recieved an IMPORTANT message from {0}", steamFriends.GetFriendPersonaName(callback.Sender));
                            Console.WriteLine("{0}: " + args[1], steamFriends.GetFriendPersonaName(callback.Sender));
                            Console.WriteLine("[i] End of message.");
                            Console.WriteLine("==============================================================\n");
                            break;

                        case "!commands":
                            Console.WriteLine("[i] I listed some commands to {0}", steamFriends.GetFriendPersonaName(callback.Sender));
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Commandlist:");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!help - For more help");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!ger - Help in german");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!eng - Help in english");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!steamID - Get your SteamID");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!friends - Get my Friendslist");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!music - Get my fav. music atm");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!coder - Get the coder of this bot");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!send - Send any friend of mine a message");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!teamspeak - Get my teamspeak IP");
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "!commands - Get the full command list");
                            break;

                        case "!rename":
                            args = seperate(1, ' ', callback.Message);

                            steamFriends.SetPersonaName(args[1]);
                            break;

                        case "!news":
                            News();

                            break;

                        case "!dev":
                            ClientMsgProtobuf <CMsgClientGamesPlayed> msg  = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                            CMsgClientGamesPlayed.GamePlayed          item = new CMsgClientGamesPlayed.GamePlayed
                            {
                                game_id = (ulong)new GameID(730)
                            };
                            msg.Body.games_played.Add(item);
                            steamClient.Send(msg);
                            Thread.Sleep(5000);
                            ClientGCMsgProtobuf <CMsgClientHello> Servus = new ClientGCMsgProtobuf <CMsgClientHello>(4006, 64);
                            gameCoordinator.Send(Servus, 730);
                            break;
                        }
                    }

                    string rLine;
                    string trimmed = callback.Message;
                    char[] trim    = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '[', ']', '{', '}', '\\', '|', ';', ':', '"', '\'', ',', '<', '.', '>', '/', '?' };
                    for (int i = 0; i < 30; i++)
                    {
                        trimmed = trimmed.Replace(trim[i].ToString(), "");
                    }
                    StreamReader sReader = new StreamReader("chat.txt");
                    while ((rLine = sReader.ReadLine()) != null)
                    {
                        string text     = rLine.Remove(rLine.IndexOf('|') - 1);
                        string response = rLine.Remove(0, rLine.IndexOf('|') + 2);

                        if (callback.Message.Contains(text))
                        {
                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, response);
                            sReader.Close();
                            return;
                        }
                    }
                }
            }
        }
        private void OnSessionTick(object sender, ElapsedEventArgs e)
        {
            if (!Steam.Instance.Client.IsConnected)
            {
                return;
            }

            foreach (var appID in Settings.Current.GameCoordinatorIdlers)
            {
                var info = GetSessionInfo(appID);

                if (info.Status == GCConnectionStatus.GCConnectionStatus_NO_SESSION
                ||  info.Status == GCConnectionStatus.GCConnectionStatus_GC_GOING_DOWN)
                {
                    var hello = new ClientGCMsgProtobuf<CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

                    if (info.AppID == 570)
                    {
                        hello.Body.engine = ESourceEngine.k_ESE_Source2;
                    }

                    SteamGameCoordinator.Send(hello, appID);
                }
            }
        }
		public async Task<byte[]> DownloadReplay(ulong matchId, CancellationToken cancellationToken)
		{
			return await Task.Run<byte[]>(async () =>
			{
				CMsgDOTAMatch matchDetails = null;

				// get the GC handler, which is used for messaging DOTA
				var gcHandler = this.SteamClient.GetHandler<SteamGameCoordinator>();

				// register a few callbacks we're interested in
				var cbManager = new CallbackManager(this.SteamClient);
				
				var sub = cbManager.Subscribe<SteamGameCoordinator.MessageCallback>((SteamGameCoordinator.MessageCallback callback) =>
				{
					cancellationToken.ThrowIfCancellationRequested();

					if (callback.EMsg == (uint)EDOTAGCMsg.k_EMsgGCMatchDetailsResponse)
					{
						var msg = new ClientGCMsgProtobuf<CMsgGCMatchDetailsResponse>(callback.Message);
						matchDetails = msg.Body.match;
					}
				});

				// Send Request
				var request = new ClientGCMsgProtobuf<CMsgGCMatchDetailsRequest>((uint)EDOTAGCMsg.k_EMsgGCMatchDetailsRequest);
				request.Body.match_id = matchId;
				gcHandler.Send(request, APPID);

				while (matchDetails == null)
				{
					cancellationToken.ThrowIfCancellationRequested();

					// in order for the callbacks to get routed, they need to be handled by the manager
					cbManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
				}

				var url = string.Format("http://replay{0}.valve.net/{1}/{2}_{3}.dem.bz2", matchDetails.cluster, APPID, matchDetails.match_id, matchDetails.replay_salt);
				var webClient = new WebClient();

				var compressedMatchData = await webClient.DownloadDataTaskAsync(url);
				var uncompressedMatchData = CompressionFactory.BZip2.Decompress(compressedMatchData);

				return uncompressedMatchData;
			});
		}
        private void OnVersionUpdate(uint appID, IPacketGCMsg packetMsg)
        {
            var msg = new ClientGCMsgProtobuf<CMsgGCClientVersionUpdated>(packetMsg).Body;

            var info = GetSessionInfo(appID);

            IRC.Instance.SendMain("{0}{1}{2} client version changed:{3} {4} {5}(from {6})", Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL, Colors.BLUE, msg.client_version, Colors.DARKGRAY, info.Version);

            info.Version = msg.client_version;
        }
示例#52
0
        // this message arrives when the GC welcomes a client
        // this happens after telling steam that we launched dota (with the ClientGamesPlayed message)
        // this can also happen after the GC has restarted (due to a crash or new version)
        void OnClientWelcome( IPacketGCMsg packetMsg )
        {
            // in order to get at the contents of the message, we need to create a ClientGCMsgProtobuf from the packet message we recieve
            // note here the difference between ClientGCMsgProtobuf and the ClientMsgProtobuf used when sending ClientGamesPlayed
            // this message is used for the GC, while the other is used for general steam messages
            var msg = new ClientGCMsgProtobuf<CMsgClientWelcome>( packetMsg );

            Console.WriteLine( "GC is welcoming us. Version: {0}", msg.Body.version );

            Console.WriteLine( "Requesting details of match {0}", matchId );

            // at this point, the GC is now ready to accept messages from us
            // so now we'll request the details of the match we're looking for

            var requestMatch = new ClientGCMsgProtobuf<CMsgGCMatchDetailsRequest>( ( uint )EDOTAGCMsg.k_EMsgGCMatchDetailsRequest );
            requestMatch.Body.match_id = matchId;

            gameCoordinator.Send( requestMatch, APPID );
        }
        private void OnWrenchBroadcast(uint appID, IPacketGCMsg packetMsg)
        {
            if (appID != 440)
            {
                // This message should be TF2 specific, but just in case
                return;
            }

            var msg = new ClientGCMsgProtobuf<CMsgTFGoldenWrenchBroadcast>(packetMsg).Body;

            IRC.Instance.SendMain("{0}{1}{2} item notification: {3}{4}{5} has {6} Golden Wrench no. {7}{8}{9}!",
                Colors.BLUE, Steam.GetAppName(appID), Colors.NORMAL,
                Colors.BLUE, msg.user_name, Colors.NORMAL,
                msg.deleted ? "destroyed" : "found",
                Colors.OLIVE, msg.wrench_number, Colors.NORMAL
            );
        }
示例#54
0
        private void HandleMatchDetailsResponse(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgGCMatchDetailsResponse>(obj);

            Client.PostCallback(new MatchResultResponse(resp.Body));
        }
示例#55
0
        private void HandleChatMessage(IPacketGCMsg obj)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAChatMessage>(obj);

            Client.PostCallback(new ChatMessage(resp.Body));
        }
示例#56
0
        void OnSourceTVGames( IPacketGCMsg msg )
        {
            var gamesList = new ClientGCMsgProtobuf<CMsgSourceTVGamesResponse>( msg );

            DebugLog.WriteLine( "DotaGCClient", "There are currently {0} viewable games", gamesList.Body.num_total_games );

            var game = gamesList.Body.games[ 0 ];

            var watchGame = new ClientGCMsgProtobuf<CMsgWatchGame>( EGCMsg.WatchGame );
            watchGame.Body.client_version = clientVersion;
            watchGame.Body.server_steamid = game.server_steamid;

            SteamGameCoordinator.Send( watchGame, APPID );
        }
		public Task<uint> Connect(bool autoReconect, CancellationToken cancellationToken)
		{
			return Task.Run<uint>(() => {
				bool completed = false;
				uint version = 0;

				// get the GC handler, which is used for messaging DOTA
				var gcHandler = this.SteamClient.GetHandler<SteamGameCoordinator>();

				// register a few callbacks we're interested in
				var cbManager = new CallbackManager(this.SteamClient);

				// these are registered upon creation to a callback manager, 
				// which will then route the callbacks to the functions specified
				cbManager.Subscribe<SteamClient.ConnectedCallback>((SteamClient.ConnectedCallback callback) => {
					cancellationToken.ThrowIfCancellationRequested();

					if (callback.Result == EResult.OK)
					{
						Trace.TraceInformation("Connected to Steam, Logging in '{0}'", this.Username);

						// get the steamuser handler, which is used for logging on after successfully connecting
						var UserHandler = this.SteamClient.GetHandler<SteamUser>();
						UserHandler.LogOn(new SteamUser.LogOnDetails
						{
							Username = this.Username,
							Password = this.Password,
							SentryFileHash = this.Sentry,
						});
					}
					else
					{
						Trace.TraceError("Unable to connect to Steam");

						throw new Exception("Failed to Connect");
					}
				});

				cbManager.Subscribe<SteamClient.DisconnectedCallback>((SteamClient.DisconnectedCallback callback) => {
					cancellationToken.ThrowIfCancellationRequested();

					Trace.TraceInformation("Disconnected from Steam.");

					if (autoReconect)
					{
						// delay a little to give steam some time to finalize the DC
						Thread.Sleep(TimeSpan.FromSeconds(1));

						// reconect
						this.SteamClient.Connect();
					}
				});

				cbManager.Subscribe<SteamUser.LoggedOnCallback>((SteamUser.LoggedOnCallback callback) => {
					cancellationToken.ThrowIfCancellationRequested();

					if (callback.Result == EResult.OK)
					{
						Trace.TraceInformation("Successfully logged on!");

						// we've logged into the account
						// now we need to inform the steam server that we're playing dota (in order to receive GC messages)
						// steamkit doesn't expose the "play game" message through any handler, so we'll just send the message manually
						var gameMsg = new ClientMsgProtobuf<CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
						gameMsg.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
						{
							game_id = new GameID(APPID), // or game_id = APPID,
						});

						// send it off - notice here we're sending this message directly using the SteamClient
						this.SteamClient.Send(gameMsg);

						// delay a little to give steam some time to establish a GC connection to us
						Thread.Sleep(TimeSpan.FromSeconds(1));

						// inform the dota GC that we want a session
						var helloMsg = new ClientGCMsgProtobuf<CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);
						helloMsg.Body.engine = ESourceEngine.k_ESE_Source2;
						gcHandler.Send(helloMsg, APPID);
					}
					else if (callback.Result == EResult.AccountLogonDenied)
					{
						Trace.TraceInformation("Account {0}@{1} is denied.", this.Username, callback.EmailDomain);

						throw new Exception(string.Format("Account {0}@{1} is denied.", this.Username, callback.EmailDomain));
					}
					else
					{
						Trace.TraceError("Failed to Login; Result {0}", callback.Result);

						throw new Exception("Failed to Login.");
					}
				});

				cbManager.Subscribe<SteamGameCoordinator.MessageCallback>((SteamGameCoordinator.MessageCallback callback) =>
				{
					cancellationToken.ThrowIfCancellationRequested();

					if (callback.EMsg == (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome)
					{
						var msg = new ClientGCMsgProtobuf<CMsgClientWelcome>(callback.Message);

						version = msg.Body.version;

						Trace.TraceInformation("GC - Welcome Message");

						completed = true;
					}
				});

				// initiate the connection
				SteamClient.Connect();

				while(completed == false)
				{
					cancellationToken.ThrowIfCancellationRequested();

					// in order for the callbacks to get routed, they need to be handled by the manager
					cbManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
				}

				return version;
			});
		}
示例#58
0
        private void HandleProTeamList(IPacketGCMsg msg)
        {
            var resp = new ClientGCMsgProtobuf <CMsgDOTAProTeamListResponse>(msg);

            Client.PostCallback(new ProTeamListResponse(resp.Body));
        }
示例#59
0
        // this message arrives after we've requested the details for a match
        void OnMatchDetails( IPacketGCMsg packetMsg )
        {
            var msg = new ClientGCMsgProtobuf<CMsgGCMatchDetailsResponse>( packetMsg );

            EResult result = ( EResult )msg.Body.result;
            if ( result != EResult.OK )
            {
                Console.WriteLine( "Unable to request match details: {0}", result );
            }

            gotMatch = true;
            Match = msg.Body.match;

            // we've got everything we need, we can disconnect from steam now
            client.Disconnect();
        }
示例#60
0
        void OnClientWelcome( IPacketGCMsg msg )
        {
            var clientWelcome = new ClientGCMsgProtobuf<CMsgClientWelcome>( msg );

            clientVersion = clientWelcome.Body.version;
            DebugLog.WriteLine( "DotaGCClient", "GC is version {0}", clientWelcome.Body.version );

            var findGames = new ClientGCMsgProtobuf<CMsgFindSourceTVGames>( EGCMsg.FindSourceTVGames );
            findGames.Body.num_games = 10;

            SteamGameCoordinator.Send( findGames, APPID );
        }