예제 #1
0
        public ChatServiceMultiplexer(ILogger <ChatServiceMultiplexer> logger, IList <IChatService> streamingServices)
        {
            _logger            = logger;
            _streamingServices = streamingServices;
            _twitchService     = (TwitchService)streamingServices.First(s => s is TwitchService);
            _bilibiliService   = (BiliBiliService)streamingServices.First(s => s is BiliBiliService);

            var displayNameBuilder = new StringBuilder();

            foreach (var service in _streamingServices)
            {
                service.OnTextMessageReceived += Service_OnTextMessageReceived;
                service.OnJoinChannel         += Service_OnJoinChannel;
                service.OnRoomStateUpdated    += Service_OnRoomStateUpdated;
                service.OnLeaveChannel        += Service_OnLeaveChannel;
                service.OnLogin                     += Service_OnLogin;
                service.OnChatCleared               += Service_OnChatCleared;
                service.OnMessageCleared            += Service_OnMessageCleared;
                service.OnChannelResourceDataCached += Service_OnChannelResourceDataCached;

                if (displayNameBuilder.Length > 0)
                {
                    displayNameBuilder.Append(", ");
                }

                displayNameBuilder.Append(service.DisplayName);
            }

            DisplayName = displayNameBuilder.Length > 0 ? displayNameBuilder.ToString() : "Generic";
        }
예제 #2
0
 public DiscordBot(Config config, ILogger <DiscordBot> logger, IServiceCollection serviceCollection, TwitchService twitch)
 {
     _config            = config;
     _logger            = logger;
     _serviceCollection = serviceCollection;
     _twitch            = twitch;
 }
예제 #3
0
        public static void Init(TwitchClient client, TwitchPubSub pubsubClient, ApplicationSettings appSettings, Account account,
                                CouchDbStore <Viewer> viewerCollection, List <Command> settings)
        {
            _client           = client;
            _account          = account;
            _viewerCollection = viewerCollection;
            _commandSettings  = settings;
            _twitchService    = new TwitchService(appSettings);

            _client.OnJoinedChannel               += OnJoinedChannel;
            _client.OnMessageReceived             += OnMessageReceived;
            _client.OnWhisperReceived             += OnWhisperReceived;
            _client.OnNewSubscriber               += OnNewSubscriber;
            _client.OnLog                         += OnLog;
            _client.OnConnectionError             += OnConnectionError;
            _client.OnChatCommandReceived         += OnChatCommandReceived;
            _client.OnUserTimedout                += OnUserTimedOut;
            _client.OnUserBanned                  += ClientOnUserBanned;
            pubsubClient.OnPubSubServiceConnected += TwitchPubSubOnOnPubSubServiceConnected;
            pubsubClient.OnPubSubServiceClosed    += TwitchPubSubOnOnPubSubServiceClosed;
            pubsubClient.OnChannelSubscription    += TwitchPubSubOnOnChannelSubscription;
            pubsubClient.OnFollow                 += TwitchPubSubOnOnFollow;
            pubsubClient.OnEmoteOnly              += TwitchPubSubOnOnEmoteOnly;
            pubsubClient.OnEmoteOnlyOff           += TwitchPubSubOnOnEmoteOnlyOff;

            pubsubClient.ListenToFollows(appSettings?.Keys.Twitch.ChannelId);
            pubsubClient.ListenToSubscriptions(appSettings?.Keys.Twitch.ChannelId);
            pubsubClient.ListenToChatModeratorActions(_account?.TwitchBotSettings.Username, appSettings?.Keys.Twitch.ChannelId);
        }
예제 #4
0
 public TwitchController(TwitchService service, DiscordBot discord, DiscordContext ctx, ILogger <TwitchController> logger)
 {
     _service = service;
     _discord = discord;
     _db      = ctx;
     _logger  = logger;
 }
예제 #5
0
 public TwitchController(
     AccountService accountService,
     TwitchService twitchService)
 {
     _twitchService  = twitchService;
     _accountService = accountService;
 }
예제 #6
0
        private async Task InvokeAddTwitchListener()
        {
            List <IMessage> messagesInInteraction = new List <IMessage>();

            try
            {
                messagesInInteraction.Add(Context.Message);
                twitchService = new TwitchService();
                messagesInInteraction.Add(await ReplyAsync("Which twitch channel do you want to monitor for stream activity?"));
                var channelToWatch = await NextMessageAsync(timeout : TimeSpan.FromSeconds(60));

                string twitchUserId = await getTwitchUserIdFromChannelName(messagesInInteraction, channelToWatch);

                if (twitchUserId == null)
                {
                    return;
                }
                messagesInInteraction.Add(await ReplyAsync("What would you like to say when this channel goes online? You can use `[streamer]` and `[streamlink]` and I will replace it with the streamer's name or their stream link respectively!"));
                var announcementText = await NextMessageAsync(timeout : TimeSpan.FromSeconds(120));

                if (!await IsAnnouncementNotNull(messagesInInteraction, announcementText))
                {
                    return;
                }
                await twitchService.SaveOrUpdateTwitchMonitorRecord(new TwitchMonitorRecord(Context, twitchUserId, announcementText.Content));
                await SendConfirmationEmbed(messagesInInteraction, channelToWatch, announcementText);
            }
            finally
            {
                await CleanUpMessagesAfterFiveSeconds(messagesInInteraction);
            }
        }
예제 #7
0
        public async Task Twitch(CommandContext ctx,
                                 [Description("Channel to find on Twitch")][RemainingText] string query)
        {
            if (!BotServices.CheckUserInput(query))
            {
                return;
            }
            var results = await TwitchService.GetTwitchDataAsync(query).ConfigureAwait(false);

            if (results.Stream.Count == 0)
            {
                await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_TWITCH, EmbedType.Missing).ConfigureAwait(false);
            }
            else
            {
                var stream = results.Stream[0];
                var output = new DiscordEmbedBuilder()
                             .WithTitle(stream.UserName + " is live on Twitch!")
                             .WithDescription(stream.Title)
                             .AddField("Start Time:", stream.StartTime, true)
                             .AddField("View Count:", stream.ViewCount.ToString(), true)
                             .WithImageUrl(stream.ThumbnailUrl.Replace("{width}", "500").Replace("{height}", "300"))
                             .WithUrl("https://www.twitch.tv/" + stream.UserName)
                             .WithColor(new DiscordColor("#6441A5"));
                await ctx.RespondAsync(embed : output.Build()).ConfigureAwait(false);
            }
        }
 public LeagueOfLegendsChannel(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager)
 {
     _logger           = logManager.GetLogger(GetType().Name);
     _lolVideoProvider = new LolVideoProvider(httpClient, jsonSerializer, _logger);
     _twitchService    = new TwitchService(httpClient, jsonSerializer);
     _vimeoService     = new VimeoService(httpClient, jsonSerializer);
 }
예제 #9
0
        public TwitchTeamService(
            ILogger <TwitchTeamService> logger,
            ITwitchTeamMemberRepository twitchTeamMemberRepository,
            ITwitchTeamSettingsRepository twitchTeamSettingsRepository,
            IEnumerable <BotDiscordSocketClient> botDiscordSocketClients,
            TwitchService twitchService,
            Random random
            )
        {
            _logger = logger;
            _twitchTeamMemberRepository   = twitchTeamMemberRepository;
            _twitchTeamSettingsRepository = twitchTeamSettingsRepository;
            _botDiscordSocketClients      = botDiscordSocketClients;
            _twitchService = twitchService;
            _random        = random;

            _timer           = new System.Timers.Timer(2 * 60 * 1000);
            _timer.Elapsed  += timer_Elapsed;
            _timer.AutoReset = true;

            _timerTeam           = new System.Timers.Timer(10 * 60 * 1000);
            _timerTeam.Elapsed  += timerTeam_Elapsed;
            _timerTeam.AutoReset = true;

            _existingMessages = new ConcurrentDictionary <ulong, List <Message> >();
            _guildTeamMembers = new ConcurrentDictionary <ulong, List <string> >();
        }
예제 #10
0
 public Channel(string channelId, TwitchService twitchService, MacroService macroService, AuthenticationService authenticationService)
 {
     Id                     = channelId.ToLower();
     _twitchService         = twitchService;
     _macroService          = macroService;
     _authenticationService = authenticationService;
 }
예제 #11
0
 public TwitchController(TwitchService twitchService, UserService userService, TwitchManager twitchManager, ConfigurationService configurationService)
 {
     this.twitchService        = twitchService;
     this.userService          = userService;
     this.twitchManager        = twitchManager;
     this.configurationService = configurationService;
 }
예제 #12
0
        public void SetupTests()
        {
            var settingsCollection = new CouchDbStore <ApplicationSettings>(ApplicationSettings.CouchDbUrl);
            var settings           = settingsCollection.FindAsync("9c3131ee7b9fb97491e8551211495381").GetAwaiter().GetResult();

            _twitchService = new TwitchService(settings);
        }
예제 #13
0
 public TwitchModule(DiscordSocketClient client)
 {
     if (twitchService == null)
     {
         twitchService = new TwitchService(client);
     }
     this.client = client;
 }
예제 #14
0
 public IntegrationController(IntegrationService integrationService, YoutubeService youtubeService,
                              TwitchService twitchService, DiscordService discordService)
 {
     this.integrationService = integrationService;
     this.youtubeService     = youtubeService;
     this.twitchService      = twitchService;
     this.discordService     = discordService;
 }
예제 #15
0
 public TwitchMonitoringJob(long channelId, TwitchService twitchService, JakeBotContext botContext,
                            DiscordSocketClient client)
 {
     _channelId     = channelId;
     _twitchService = twitchService;
     _botContext    = botContext;
     _client        = client;
 }
예제 #16
0
 public MainWindow(MainWindowViewModel mainWindowViewModel,
                   TwitchService twitchService)
 {
     _twitchService = twitchService;
     DataContext    = mainWindowViewModel;
     Closing       += MainWindow_Closing;
     InitializeComponent();
 }
예제 #17
0
        public async Task Twitch(CommandContext ctx,
                                 [Description("Channel to find on Twitch.")][RemainingText]
                                 string query)
        {
            if (string.IsNullOrWhiteSpace(query))
            {
                return;
            }
            await ctx.TriggerTypingAsync();

            var results = await TwitchService.GetTwitchDataAsync(Program.Settings.Tokens.TwitchToken, query)
                          .ConfigureAwait(false);

            if (results.Total == 0)
            {
                await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_TWITCH, ResponseType.Missing)
                .ConfigureAwait(false);

                return;
            }

            foreach (var streamer in results.Streams)
            {
                var output = new DiscordEmbedBuilder()
                             .WithTitle(streamer.Channel.DisplayName)
                             .WithDescription("[LIVE] Now Playing: " + streamer.Channel.Game)
                             .AddField("Broadcaster", streamer.Channel.BroadcasterType.ToUpperInvariant(), true)
                             .AddField("Viewers", streamer.Viewers.ToString(), true)
                             .AddField("Followers", streamer.Channel.Followers.ToString(), true)
                             .AddField("Status", streamer.Channel.Status)
                             .WithThumbnail(streamer.Channel.Logo)
                             .WithImageUrl(streamer.Preview.Large)
                             .WithUrl(streamer.Channel.Url)
                             .WithFooter(!streamer.Id.Equals(results.Streams.Last().Id)
                        ? "Type 'next' within 10 seconds for the next streamer."
                        : "This is the last found streamer on the list.")
                             .WithColor(new DiscordColor("#6441A5"));
                var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false);

                if (results.Total == 1)
                {
                    continue;
                }
                var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false);

                if (interactivity.Result is null)
                {
                    break;
                }
                await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false);

                if (!streamer.Id.Equals(results.Streams.Last().Id))
                {
                    await BotServices.RemoveMessage(message).ConfigureAwait(false);
                }
            }
        }
        public async Task StopSubscription()
        {
            Logger.LogInformation($"{DateTime.UtcNow}: Stopping Subscription");

            var channels = Config.GetSection(Constants.CONFIG_TWITCH_CHANNELS).Get <List <string> >();
            await TwitchService.UnsubscribeFromChannelEvents(channels);

            Logger.LogInformation($"{DateTime.UtcNow}: Stopped Subscription");
        }
예제 #19
0
        public void Perform(TwitchClient client, TwitchService service, ChatCommand chatCommand, Command command)
        {
            if (!command.IsActive)
            {
                return;
            }

            client.SendMessage(chatCommand.ChatMessage.Channel, "Tier 1 emote: kungraHEY Tier 2 emote: kungraDERP Tier 3 emote: kungraTHRONE");
        }
예제 #20
0
 public MainWindowViewModel(TwitchService twitchService,
                            ChatViewModel chatViewModel,
                            CommandsViewModel commandsViewModel)
 {
     ChatViewModel     = chatViewModel;
     CommandsViewModel = commandsViewModel;
     _twitchService    = twitchService;
     _twitchService.Start();
 }
예제 #21
0
        protected override async Task OnInitializedAsync()
        {
            var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            if (authState.User.Identity.IsAuthenticated)
            {
                await TwitchService.LoadChannelData();
            }
        }
예제 #22
0
        private async Task StopSubscription(string channel = null)
        {
            Logger.LogFormattedMessage("Stopping Subscription");
            var channels = string.IsNullOrEmpty(channel) ? TwitchService.TwitchUsers.Select(x => x.LoginName) : new[] { channel };
            await TwitchService.UpdateFollowerSubscription(channels, SubscriptionStatus.Unsubscribed);

            await TwitchService.UpdateStreamChangeSubscription(channels, SubscriptionStatus.Unsubscribed);

            Logger.LogFormattedMessage("Stopped Subscription");
        }
예제 #23
0
 public SingleStreamerModule(
     ISingleStreamerSettingsRepository singleStreamerSettingsRepository,
     IGuildSettingsRepository guildSettingsRepoistory,
     TwitchService twitchService
     )
 {
     _singleStreamerSettingsRepository = singleStreamerSettingsRepository;
     _guildSettingsRepoistory          = guildSettingsRepoistory;
     _twitchService = twitchService;
 }
예제 #24
0
        public async Task <IReadOnlyList <TwitchStream> > GetTwitchStreamsAsync(int take)
        {
            var random = new Random();

            return(await Task.Run(() => TwitchService
                                  .GetTwitchStreams()
                                  .OrderBy(x => random.Next())
                                  .Take(take)
                                  .ToList()));
        }
        protected override async Task OnInitializedAsync()
        {
            var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            if (authState.User.Identity.IsAuthenticated)
            {
                await TwitchService.LoadChannelData(Config.GetSection(Constants.CONFIG_TWITCH_CHANNELS).Get <List <string> >());

                await TwitchService.GetCurrentSubscriptions();
            }
        }
예제 #26
0
        public void Awake()
        {
            ChatCoreInstance chatCore = ChatCoreInstance.Create();

            twitchService = chatCore.RunTwitchServices();

            twitchService.OnTextMessageReceived += OnMessage;

            DontDestroyOnLoad(this);

            enabled = false;
        }
예제 #27
0
 public TwitchTeamModule(
     ITwitchTeamMemberRepository twitchTeamMemberRepository,
     ITwitchTeamSettingsRepository twitchTeamSettingsRepository,
     IGuildSettingsRepository guildSettingsRepoistory,
     TwitchService twitchService
     )
 {
     _twitchTeamMemberRepository   = twitchTeamMemberRepository;
     _twitchTeamSettingsRepository = twitchTeamSettingsRepository;
     _guildSettingsRepoistory      = guildSettingsRepoistory;
     _twitchService = twitchService;
 }
예제 #28
0
 public CallbackController(
     ILogger <CallbackController> logger,
     TwitchService service,
     StringCipher cypher,
     IEnumerable <BotDiscordSocketClient> botDiscordSocketClients,
     IOwnerTwitchCredentialRepository ownerTwitchCredentialRespository)
 {
     _logger  = logger;
     _service = service;
     _cypher  = cypher;
     _botDiscordSocketClients          = botDiscordSocketClients;
     _ownerTwitchCredentialRespository = ownerTwitchCredentialRespository;
 }
예제 #29
0
        public Form1()
        {
            InitializeComponent();

            var streamCore = ChatCoreInstance.Create();

            streamingService          = streamCore.RunAllServices();
            twitchService             = streamingService.GetTwitchService();
            streamingService.OnLogin += StreamingService_OnLogin;
            streamingService.OnTextMessageReceived += StreamServiceProvider_OnMessageReceived;
            streamingService.OnJoinChannel         += StreamServiceProvider_OnChannelJoined;
            streamingService.OnLeaveChannel        += StreamServiceProvider_OnLeaveChannel;
            streamingService.OnRoomStateUpdated    += StreamServiceProvider_OnChannelStateUpdated;
            //Console.WriteLine($"StreamService is of type {streamServiceProvider.ServiceType.Name}");
        }
예제 #30
0
 public ChatViewModel(TwitchService twitchService,
                      TwitchSettings twitchSettings,
                      IPhoneticMatch phonetic,
                      ToolContext context,
                      OverrustlelogsService overrustlelogsService)
 {
     Messages               = new ObservableCollection <TwitchMessage>();
     _twitchService         = twitchService;
     TwitchSettings         = twitchSettings;
     _phonetic              = phonetic;
     _context               = context;
     _overrustlelogsService = overrustlelogsService;
     _twitchService.Client.OnMessageReceived += Client_OnMessageReceived;
     _whitelistedWords = _context.WhitelistWords.ToList();
     _whitelistedUsers = _context.WhitelistUsers.ToList();
 }