public void Execute(CommandContext context)
 {
     Weather weather = GetWeather(context.Parameters);
     string response;
     if (weather != null)
         response = String.Format(new TemperatureFormatter(), "In {0} {1}, temperature is {2:C}.",
             weather.City, weather.Description, weather.Temperature);
     else
         response = "Error.";
     context.Bot.SendTextMessage(context.ChatId, response);
 }
        public async void Execute(CommandContext context)
        {
            Currency[] rates = await GetRates(context.Parameters);
            string response = "";
            if (rates != null)
                foreach (var rate in rates)
	            {
                    response += String.Format("{0} ({1}) - {2:C}\n",
                        rate.Name, rate.CharCode, rate.Rate);
	            }
            else
                response = "Error.";
            context.Bot.SendTextMessage(context.ChatId, response);
        }
        static async Task Run()
        {
            CommandFactory factory = new CommandFactory();
            factory.Register("weather", new WeatherCommand() { DefaultCity = "Minsk" });
            factory.Register("rate", new CurrencyRateCommand());

            CustomBot bot = new CustomBot();
            CommandParser parser = new CommandParser();

            while (true)
            {
                Message message = await bot.NextTextMessage();
                ICommand command = factory.GetCommand(parser.GetCommandName(message.Text));
                if (command != null)
                {
                    CommandContext context = new CommandContext(parser.GetCommandParameters(message.Text), message.Chat.Id, bot);
                    command.Execute(context);
                }
                else
                {
                    //
                }
            }
        }
 public void Execute(CommandContext context)
 {
     throw new NotImplementedException();
 }