コード例 #1
0
ファイル: SteamRoom.cs プロジェクト: Rohansi/RohBot
        public void Disconnect()
        {
            if (Chat == null)
                return;

            Chat.Leave(SteamChatLeaveReason.Left);
            Chat = null;
        }
コード例 #2
0
ファイル: SteamRoom.cs プロジェクト: krixalis/RohBot
        public override void Leave()
        {
            if (Chat != null)
            {
                Chat.Leave(SteamChatLeaveReason.Left);
                Chat = null;
            }

            base.Leave();
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: Naarkie/RohBot
 // For Steam private messages
 public CommandTarget(SteamChat steamChat, SteamPersona sender)
 {
     PrivateChat = steamChat;
     Persona = sender;
 }
コード例 #4
0
ファイル: SteamRoom.cs プロジェクト: krixalis/RohBot
        private void HandleMessage(SteamChat chat, SteamPersona user, string message)
        {
            _lastMessage.Restart();

            var senderName = user.DisplayName;
            var senderId = user.Id.ConvertToUInt64().ToString("D");
            var inGame = user.Playing != null && user.Playing.ToUInt64() != 0;

            var line = new ChatLine(Util.GetCurrentTimestamp(), RoomInfo.ShortName, "Steam", senderName, senderId, "", message, inGame);
            SendLine(line);

            Command.Handle(new CommandTarget(this, user.Id), message, "~");
        }
コード例 #5
0
ファイル: SteamRoom.cs プロジェクト: krixalis/RohBot
        private void HandleLeave(SteamChat chat, SteamPersona user, SteamChatLeaveReason reason, SteamPersona sourceUser)
        {
            _lastMessage.Restart();

            var message = user.DisplayName;
            switch (reason)
            {
                case SteamChatLeaveReason.Left:
                    message += " left chat.";
                    break;
                case SteamChatLeaveReason.Disconnected:
                    message += " disconnected.";
                    break;
                case SteamChatLeaveReason.Kicked:
                    message += string.Format(" was kicked by {0}.", sourceUser.DisplayName);
                    break;
                case SteamChatLeaveReason.Banned:
                    message += string.Format(" was banned by {0}.", sourceUser.DisplayName);
                    break;
            }

            var by = sourceUser != null ? sourceUser.DisplayName : "";
            var byId = sourceUser != null ? sourceUser.Id.ConvertToUInt64().ToString("D") : "0";
            var byType = sourceUser != null ? "Steam" : "";

            var line = new StateLine(Util.GetCurrentTimestamp(), RoomInfo.ShortName, reason.ToString(), user.DisplayName, user.Id.ConvertToUInt64().ToString("D"), "Steam", by, byId, byType, message);
            SendLine(line);
        }
コード例 #6
0
ファイル: SteamRoom.cs プロジェクト: krixalis/RohBot
        private void HandleEnter(SteamChat chat, SteamPersona user)
        {
            _lastMessage.Restart();

            var message = user.DisplayName + " entered chat.";

            var line = new StateLine(Util.GetCurrentTimestamp(), RoomInfo.ShortName, "Enter", user.DisplayName, user.Id.ConvertToUInt64().ToString("D"), "Steam", "", "0", "", message);
            SendLine(line);
        }
コード例 #7
0
ファイル: SteamRoom.cs プロジェクト: krixalis/RohBot
        public override void Update()
        {
            if (!IsActive)
            {
                if (Chat != null)
                    Chat.Leave(SteamChatLeaveReason.Left);

                return;
            }

            if (Chat != null && _lastMessage.Elapsed >= TimeSpan.FromMinutes(30))
            {
                Program.Logger.Info("Rejoining " + RoomInfo.ShortName);
                _lastMessage.Restart();
                Chat.Leave(SteamChatLeaveReason.Disconnected);
                return;
            }

            if (Program.Steam.Status != Steam.ConnectionStatus.Connected || Chat != null)
                return;

            _hasConnected = false;
            Chat = Program.Steam.Bot.Join(SteamId);

            Chat.OnEnter += sender =>
            {
                _hasConnected = true;
                Program.Logger.Info("Entered " + RoomInfo.ShortName);
                SendPersistentSysMessage("Connected to Steam.");
            };

            Chat.OnLeave += (sender, reason) =>
            {
                if (_hasConnected)
                {
                    _hasConnected = false;
                    Program.Logger.Info("Left " + RoomInfo.ShortName + ": " + reason);
                    SendPersistentSysMessage("Lost connection to Steam.");
                }

                Chat = null;
            };

            Chat.OnMessage += HandleMessage;
            Chat.OnUserEnter += HandleEnter;
            Chat.OnUserLeave += HandleLeave;
        }
コード例 #8
0
ファイル: Command.cs プロジェクト: krixalis/RohBot
 public CommandTarget(SteamChat steamChat, SteamID sender)
 {
     PrivateChat = steamChat;
     SteamId = sender;
 }
コード例 #9
0
ファイル: SteamBot.cs プロジェクト: Rohansi/EzSteam
        /// <summary>
        /// Attempt to join a chat. Will call OnLeave if the chat could not be joined.
        /// </summary>
        public SteamChat Join(SteamID chatId)
        {
            if (chatId.IsClanAccount)
            {
                SteamFriends.RequestFriendInfo(chatId, EClientPersonaStateFlag.ClanInfo | EClientPersonaStateFlag.ClanTag | EClientPersonaStateFlag.PlayerName);
                chatId = Util.ChatFromClan(chatId);
            }

            var chatsCopy = Chats;
            if (chatsCopy.Any(r => r.Id == chatId && r.IsActive))
                return chatsCopy.Find(r => r.Id == chatId);

            var chat = new SteamChat(this, chatId);
            chat.Subscribe();
            SteamFriends.JoinChat(chatId);

            lock (_sync)
                _chats.Add(chat);

            return chat;
        }