Esempio n. 1
0
        public TwitchCommandClient(
            ILogger logger,
            IKernel kernel,
            IBotServer game,
            IMessageBus messageBus,
            ITwitchMessageFormatter messageFormatter,
            ITwitchCommandController commandHandler,
            ITwitchCredentialsProvider credentialsProvider,
            ITwitchPubSubManager pubSubManager)
        {
            this.logger              = logger;
            this.kernel              = kernel;
            this.game                = game;
            this.messageBus          = messageBus;
            this.messageFormatter    = messageFormatter;
            this.commandHandler      = commandHandler;
            this.credentialsProvider = credentialsProvider;
            this.pubSubManager       = pubSubManager;

            //// For the time being, pubsub will be disabled as it needs actual token for the person that wants to use it? worked in the old bot. but not here. Wutfacers
            //// ugh...
            //this.messageBus.Subscribe<string>("streamer_userid_acquired", userid =>
            //{
            //    ListenForChannelPoints(logger, userid);
            //});

            this.messageBus.Subscribe <PubSubToken>("pubsub", OnPubSubTokenReceived);
            CreateTwitchClient();
        }
Esempio n. 2
0
        public TwitchBot(
            ILogger logger,
            IKernel kernel,
            IRavenfallClient ravenfall,
            IPlayerProvider playerProvider,
            ITwitchMessageFormatter localizer,
            IMessageBus messageBus,
            ICommandProvider commandProvider,
            ICommandHandler commandHandler,
            IChannelProvider channelProvider,
            IConnectionCredentialsProvider credentialsProvider)
        {
            this.logger           = logger;
            this.kernel           = kernel;
            this.ravenfall        = ravenfall;
            this.playerProvider   = playerProvider;
            this.messageFormatter = localizer;
            this.messageBus       = messageBus;
            this.commandProvider  = commandProvider;

            this.commandHandler      = commandHandler;
            this.channelProvider     = channelProvider;
            this.credentialsProvider = credentialsProvider;

            this.messageBus.Subscribe <string>("streamer_userid_acquired", userid =>
            {
                try
                {
                    if (listeningToChannelPoints)
                    {
                        return;
                    }


                    if (pubsubIsConnected)
                    {
                        pubsubIsConnected = false;
                        pubsub.Disconnect();
                    }

                    pubsub.ListenToChannelPoints(userid);
                    pubsub.Connect();
                    pubsubIsConnected = true;

                    logger.WriteDebug("Connecting to PubSub");
                }
                catch (Exception exc)
                {
                    logger.WriteError(exc.ToString());
                }
            });

            this.CreateTwitchClient();

            ravenfall.ProcessAsync(Settings.UNITY_SERVER_PORT);
        }