Beispiel #1
0
 public YouTubeSettingsApiController(
     YouTubeSettings youtubeSettings,
     IApiResponseHelper apiResponseHelper
     )
 {
     _youtubeSettings   = youtubeSettings;
     _apiResponseHelper = apiResponseHelper;
 }
Beispiel #2
0
 private void ConfigureYouTubeReader(IServiceCollection services)
 {
     services.TryAddSingleton <IYouTubeSettings>(s =>
     {
         var settings      = new YouTubeSettings();
         var configuration = s.GetService <IConfiguration>();
         configuration.Bind("Settings:YouTube", settings);
         return(settings);
     });
     services.TryAddSingleton <IYouTubeReader, YouTubeReader.YouTubeReader>();
 }
        public YouTubeTradeNotifier(T data, PokeTradeTrainerInfo info, int code, string username, ChatClient client, YouTubeSettings settings)
        {
            Data     = data;
            Info     = info;
            Code     = code;
            Username = username;
            Client   = client;
            Settings = settings;

            LogUtil.LogText($"Created trade details for {Username} - {Code}");
        }
        public virtual YouTubeSettings LoadSettings()
        {
            var settings = Store.Items<YouTubeSettings>().FirstOrDefault();

            if (settings != null)
                return settings;

            settings = new YouTubeSettings();
            Store.Save(settings);
            return settings;
        }
Beispiel #5
0
 private void ConfigureYouTubeReader(IFunctionsHostBuilder builder)
 {
     builder.Services.TryAddSingleton <IYouTubeSettings>(s =>
     {
         var settings      = new YouTubeSettings();
         var configuration = s.GetService <IConfiguration>();
         configuration.Bind("Settings:YouTube", settings);
         return(settings);
     });
     builder.Services.TryAddSingleton <IYouTubeReader, YouTubeReader.YouTubeReader>();
 }
 public virtual bool SaveSettings(YouTubeSettings settings)
 {
     try
     {
         Store.Save(settings, CurrentSettings.Id);
         _currentSettings = settings;
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
Beispiel #7
0
        public YouTubeBot(YouTubeSettings settings, PokeTradeHub <PK8> hub)
        {
            Hub                 = hub;
            Settings            = settings;
            Logger.LogOccurred += Logger_LogOccurred;

            try
            {
                Task.Run(async() =>
                {
                    var connection = await YouTubeConnection.ConnectViaLocalhostOAuthBrowser(Settings.ClientID, Settings.ClientSecret, Scopes.scopes, true);
                    if (connection != null)
                    {
                        channel = await connection.Channels.GetChannelByID(Settings.ChannelID);
                        if (channel != null)
                        {
                            client = new ChatClient(connection);

                            client.OnMessagesReceived += Client_OnMessagesReceived;
                            if (await client.Connect())
                            {
                                await Task.Delay(-1);
                            }
                            else
                            {
                            }
                        }
                    }
                    EchoUtil.Forwarders.Add(msg => client.SendMessage(msg));
                });
            }
            catch (Exception ex)
            {
                LogUtil.LogError(ex.Message, "YouTubeBot");
            }
        }
Beispiel #8
0
 public YouTubeBot(YouTubeSettings settings, PokeTradeHub <T> hub)
 {
     Hub                 = hub;
     Settings            = settings;
     Logger.LogOccurred += Logger_LogOccurred;
     client              = default !;
Beispiel #9
0
 /// <summary>
 /// The constructor for initializing the service
 /// </summary>
 /// <param name="httpClientFactory"></param>
 /// <param name="decryptorService"></param>
 /// <param name="options"></param>
 public YouTubeService(IHttpClientFactory httpClientFactory, IDecryptorService decryptorService, IOptions <YouTubeSettings> options)
 {
     _httpClientFactory = httpClientFactory;
     _decryptorService  = decryptorService;
     _settings          = options.Value;
 }