コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: infom/DeeBeeTeeBot
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            Start.Visibility = Visibility.Hidden;
            Stop.Visibility  = Visibility.Visible;

            _cancelTokenSource = new CancellationTokenSource();

            try
            {
                if (CanGetByName.SelectedItem.ToString() == "Open Weather Map")
                {
                    _weatherByName = new OpenWeatherMap(Properties.Settings.Default.TokenOpenWeather, Properties.Settings.Default.RequestOpenWeather);
                }
                else if (CanGetByName.SelectedItem.ToString() == "Dark Sky")
                {
                    _weatherByName = new DarkSky(_translator, Properties.Settings.Default.TokenDarkSky, Properties.Settings.Default.RequestDarkSky);
                }

                if (CanGetByCoordinate.SelectedItem.ToString() == "Dark Sky")
                {
                    _weatherByCoordinate = new DarkSky(_translator, Properties.Settings.Default.TokenDarkSky, Properties.Settings.Default.RequestDarkSky);
                }

                var token = _cancelTokenSource.Token;

                apiWork = new Bot(Properties.Settings.Default.TokenBot, token, _weatherByCoordinate, _weatherByName, _translator, () => new UsersRepository());

                apiWork.BotWork();
            }
            catch (Telegram.Bot.Exceptions.ApiRequestException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        public MessageControl(ICanTranslate translator, ICanGetWeatherByName weatherByName, ICanGetWeatherByCoordinate weatherByCoordinate, List <long> isWaitAnswerForWeather, List <long> isWaitAnswerForRememder, Func <IUsersRepository> createRepository)
        {
            _isWaitAnswerForWeather  = isWaitAnswerForWeather;
            _isWaitAnswerForRememder = isWaitAnswerForRememder;

            _weatherByCoordinate = weatherByCoordinate;
            _weatherByName       = weatherByName;
            _translator          = translator;

            _createRepository = createRepository;
        }
コード例 #3
0
ファイル: Bot.cs プロジェクト: infom/DeeBeeTeeBot
        public Bot(string key, CancellationToken token, ICanGetWeatherByCoordinate weatherByCoordinate, ICanGetWeatherByName weatherByName, ICanTranslate translator, Func <IUsersRepository> createRepository)
        {
            _key = key;

            _token = token;

            _isWaitAnswerForWeather  = new List <long>();
            _isWaitAnswerForRememder = new List <long>();

            _translator          = translator;
            _weatherByName       = weatherByName;
            _weatherByCoordinate = weatherByCoordinate;

            _createRepository = createRepository;

            _messageControl = new MessageControl(_translator, _weatherByName, _weatherByCoordinate, _isWaitAnswerForWeather, _isWaitAnswerForRememder, createRepository);
        }