AddFriend() public method

Adds somebody to the bot's friend list.
public AddFriend ( SteamID id ) : void
id SteamKit2.SteamID
return void
Beispiel #1
0
        public void Update()
        {
            if (_connectStarted.Elapsed.TotalSeconds > 120)
            {
                if (_bot != null)
                    _bot.Disconnect();
                Status = ConnectionStatus.Disconnected;
            }

            if (Status != ConnectionStatus.Disconnected)
                return;

            _hasConnected = false;
            _connectStarted.Restart();
            Program.Logger.Info("Connecting");

            _bot = new SteamBot(Program.Settings.Username, Program.Settings.Password, Program.Settings.AuthCode);
            _bot.OnConnected += sender =>
            {
                _hasConnected = true;
                _connectStarted.Stop();

                _bot.DisplayName = Program.Settings.PersonaName;
                _bot.PersonaState = EPersonaState.Online;
                Status = ConnectionStatus.Connected;

                Program.Logger.Info("Connected");
            };

            _bot.OnDisconnected += (sender, reason) =>
            {
                if (reason == SteamBotDisconnectReason.SteamGuard)
                    Thread.Sleep(TimeSpan.FromMinutes(2)); // TODO: need a better way of entering steamguard auth

                if (_hasConnected)
                {
                    Program.Logger.InfoFormat("Disconnected {0}", reason);
                    _hasConnected = false;
                }

                Status = ConnectionStatus.Disconnected;
            };

            _bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id);

            _bot.OnPrivateEnter += (sender, chat) =>
            {
                chat.OnMessage += (chatSender, messageSender, message) =>
                    Command.Handle(new CommandTarget(chatSender, messageSender), message, "");
            };

            _bot.OnChatInvite += (sender, chat, @by) =>
            {
                if (chat.Id.IsIndividualAccount)
                    _bot.Join(chat.Id);
            };

            _bot.Connect();
            Status = ConnectionStatus.Connecting;
        }
Beispiel #2
0
        public void Update()
        {
            if (_connectStarted.Elapsed.TotalSeconds > 120)
            {
                if (_bot != null)
                    _bot.Disconnect();
                Status = ConnectionStatus.Disconnected;
            }

            if (Status != ConnectionStatus.Disconnected)
                return;

            _hasConnected = false;
            _connectStarted.Restart();
            Program.Logger.Info("Connecting");

            _bot = new SteamBot(Program.Settings.Username, Program.Settings.Password);
            _bot.OnConnected += sender =>
            {
                _hasConnected = true;
                _connectStarted.Stop();

                _bot.DisplayName = Program.Settings.PersonaName;
                _bot.PersonaState = EPersonaState.Online;
                Status = ConnectionStatus.Connected;

                Program.Logger.Info("Connected");
            };

            _bot.OnDisconnected += (sender, reason) =>
            {
                if (_hasConnected)
                {
                    Program.Logger.Info("Disconnected");
                    _hasConnected = false;
                }

                Status = ConnectionStatus.Disconnected;
            };

            _bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id);

            _bot.OnPrivateEnter += (sender, chat) =>
            {
                chat.OnMessage += (chatSender, messageSender, message) =>
                    Command.Handle(new CommandTarget(chatSender, messageSender), message, "");
            };

            _bot.OnChatInvite += (sender, chat, @by) =>
            {
                if (chat.Id.IsIndividualAccount)
                    _bot.Join(chat.Id);
            };

            _bot.Connect();
            Status = ConnectionStatus.Connecting;
        }