예제 #1
0
        public NewMessageActor(ChannelConfiguration config)
        {
            this.Configuration = config;

            this.ChatLogger = Context.ActorSelection(ChatLoggerActor.Path)
                              .ResolveOne(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();

            this.Receive <OnMessageReceivedArgs>((args) => {
                Debug.WriteLine(args.ChatMessage.Username + ": " + args.ChatMessage.Message);
                ChatLogger.Tell(new ChatLogMessage(LogLevel.Information, Configuration.ChannelName, args.ChatMessage.Username + ": " + args.ChatMessage.Message));
            });
        }
예제 #2
0
        private async Task AddChannelToTrack(TrackNewFollowers arg)
        {
            // Check if the channel is already subscribed to with the WebHook API
            if (_FollowerChannels.Contains(arg.ChannelName))
            {
                return;
            }

            _FollowerChannels.Add(arg.ChannelName);

            await SubscribeToTwitchWebhook(arg.ChannelName, arg.ChannelId);

            ChatLogger.Tell(new ChatLogMessage(Microsoft.Extensions.Logging.LogLevel.Debug, "- global -", $"Now tracking followers for channel {arg.ChannelName}"));
        }
        public NewMessageActor(ChannelConfiguration config, IEnumerable <IFeature> features)
        {
            this.Configuration = config;

            this.ChatLogger = Context.ActorSelection(ChatLoggerActor.Path)
                              .ResolveOne(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();

            // TODO:  This should be a static method on the ChannelActor object
            _ChannelActor = Context.ActorSelection($"/user/channelmanager/channel_{config.ChannelName}");

            // Cheer 100 nothing_else_matters 05/07/19
            // Cheer 200 cpayette 05/07/19
            // Cheer 300 pakmanjr 05/07/19
            this.Features = features.ToArray();
            foreach (var f in Features)
            {
                f.BroadcastMessage = (msg) => _ChannelActor.Tell(new MSG.BroadcastMessage(msg));
                f.WhisperMessage   = (user, msg) => _ChannelActor.Tell(new MSG.WhisperMessage(user, msg));
            }

            this.Receive <OnMessageReceivedArgs>((args) =>
            {
                Debug.WriteLine(args.ChatMessage.DisplayName + ": " + args.ChatMessage.Message);
                ChatLogger.Tell(new MSG.ChatLogMessage(LogLevel.Information, Configuration.ChannelName, args.ChatMessage.DisplayName + ": " + args.ChatMessage.Message));

                foreach (var f in Features.Where(f => f.IsEnabled))
                {
                    // TODO: Ensure we pass badges and emotes through to the feature
                    f.FeatureTriggered(args.ChatMessage.DisplayName + ": " + args.ChatMessage.Message);
                }
            });
            this.Receive <MSG.GetFeatureForChannel>(f =>
            {
                if (f.Channel != Configuration.ChannelName || !Features.Any(feature => feature.GetType() == f.FeatureType))
                {
                    return;
                }
                Sender.Tell(Features.First(feature => f.FeatureType == feature.GetType()));
            });
        }