private GoogleSheetsUpdater(
            [NotNull] SheetsService service,
            [NotNull] CryptoTickerBotCore ctb,
            [NotNull] string applicationName,
            [NotNull] string sheetName,
            [NotNull] string sheetId,
            [NotNull] IDictionary <CryptoExchangeId, string> sheetsRanges,
            int updateFrequency
            )
        {
            Service         = service;
            Ctb             = ctb;
            Cts             = Ctb.Cts;
            ApplicationName = applicationName;
            SheetName       = sheetName;
            SheetId         = sheetId;
            SheetsRanges    = sheetsRanges;
            UpdateFrequency = updateFrequency;

            foreach (var exchange in Ctb.Exchanges.Values)
            {
                exchange.Changed += (ex, coin) => pendingUpdates = pendingUpdates.Add(ex.Id);
            }

            Start();
        }
Exemplo n.º 2
0
 public static GoogleSheetsUpdater StartGoogleSheetUpdater(CryptoTickerBotCore ctb) =>
 GoogleSheetsUpdater.Build(
     ctb,
     Settings.Instance.ApplicationName,
     Settings.Instance.SheetName,
     Settings.Instance.SheetId,
     Settings.Instance.SheetsRanges,
     Settings.Instance.SheetUpdateFrequency
     );
Exemplo n.º 3
0
        public CtbWebSocketService(CryptoTickerBotCore ctb)
        {
            Ctb           = ctb;
            Subscriptions = new HashSet <WebSocketIncomingMessage> ( );

            AvailableCommands = new Dictionary <string, Action <string, WebSocketIncomingMessage> >
            {
                ["GetBestPair"] = GetBestPairCommand
            };
            AvailableSubscriptions = new Dictionary <string, Action <string, WebSocketIncomingMessage, bool> >
            {
                ["CoinValueUpdates"] = SubscribeToCoinValueUpdates
            };
        }
Exemplo n.º 4
0
        public static void Main( )
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
                                                          Logger.Error(args);

            LogManager.Configuration.Variables["DataSource"] = Data.Settings.Instance.DataSource;

            Console.Title = "Crypto Ticker Bot";

            var ctb = CryptoTickerBotCore.CreateAndStart( );

            StartGoogleSheetUpdater(ctb);

            Console.ReadLine( );
        }
Exemplo n.º 5
0
        public static void Main( )
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
                                                          Logger.Error(args);

            LogManager.Configuration.Variables["DataSource"] = Data.Settings.Instance.DataSource;

            Console.Title = "Crypto Ticker Bot";

            var ctb = CryptoTickerBotCore.CreateAndStart( );

            StartGoogleSheetUpdater(ctb);

            var teleBot = new TeleBot(Settings.Instance.BotToken, ctb);

            teleBot.Start( );
            teleBot.Restart += bot => StartGoogleSheetUpdater(bot.Ctb);

            var server = StartWebSocketServer(teleBot);

            Console.ReadLine( );
        }
        public static GoogleSheetsUpdater Build(
            [NotNull] CryptoTickerBotCore ctb,
            [NotNull] string applicationName,
            [NotNull] string sheetName,
            [NotNull] string sheetId,
            [NotNull] IDictionary <CryptoExchangeId, string> sheetsRanges,
            int updateFrequency = 2000
            )
        {
            Logger.Info($"Building Google Sheets Service for {applicationName}");
            var credential = GetCredentials();

            var service = new SheetsService(new BaseClientService.Initializer
            {
                HttpClientInitializer = credential,
                ApplicationName       = applicationName
            });

            return(new GoogleSheetsUpdater(
                       service, ctb, applicationName, sheetName, sheetId, sheetsRanges, updateFrequency
                       ));
        }