Esempio n. 1
0
        public void UnassignBot(IStreamBot bot)
        {
            if (Bot != bot)
            {
                return;
            }

            if (Host != null)
            {
                bot.Disconnect(Host.User);
            }

            this.Bot = null;
        }
Esempio n. 2
0
        public void AssignBot(IStreamBot bot)
        {
            this.Bot = bot;

            // only player hosted sessions have a host.
            // these are the only sessions that will need the bot to monitor for commands.
            if (Host != null)
            {
                bot.Connect(Host.User);
                foreach (var player in Players.GetAll())
                {
                    Bot.OnPlayerAdd(session.Name, player);
                }
            }
        }
        public void Remove(IStreamBot bot)
        {
            lock (mutex)
            {
                bots.Remove(bot);

                // would be better to do: bot.GetAllSessions();
                // but the bot has no references to the session right now

                var sessions = sessionManager.GetAll();
                foreach (var session in sessions)
                {
                    session.UnassignBot(bot);
                }

                logger.LogWarning("Bot: @cya@" + bot.Name + " @red@disconnected.");
            }
        }
        public void Add(IStreamBot bot)
        {
            lock (mutex)
            {
                bots.Add(bot);

                // get all unmonitored sessions (sessions without bots)
                // and assign the new bot to those sessions.

                IReadOnlyList <IGameSession> sessions = sessionManager.GetUnmonitoredSessions();
                foreach (var session in sessions)
                {
                    session.AssignBot(bot);
                }

                logger.LogDebug("Bot: @cya@" + bot.Name + " @whi@connected.");
            }
        }