Skip to content

Commit

Permalink
Merge pull request #1013 from TelegramBots/develop
Browse files Browse the repository at this point in the history
Publish v17.0.0-alpha.3
  • Loading branch information
tuscen authored Aug 1, 2021
2 parents 658492a + cfe0ea7 commit e3e812b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variables:
- name: versionPrefix
value: 17.0.0
- name: versionSuffix
value: "alpha.2"
value: "alpha.3"
- name: ciVersionSuffix
value: ci.$(Build.BuildId)+git.commit.$(Build.SourceVersion)
- name: buildConfiguration
Expand Down
22 changes: 16 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Changed
- Method `GetInfoAndDownloadFileAsync` moved into static class `TelegramBotClientExtensions` as an extension method
- Symbols are always include in the package

## [v17.0.0-alpha.2] - 2021-09-01

### Added
- Interface `IExceptionsParser`
- Type `ApiResponse`
- Property `ITelegramBotClient.ExceptionsParser`

## [v.16.0.2] - 2021-08-16

### Fixed
- Parameter name `ChatLocation.String` replaced with `ChatLocation.Address`

## [v16.0.1] - 2021-07-10

### Fixed

- `ITelegramBotClient.SendDocumentAsync` passed wrong value into `DisableContentTypeDetection` property

## [v16.0.0] - 2021-06-13
## [v17.0.0-alpha.1] - 2021-06-13

> [Bot API 5.3](https://core.telegram.org/bots/api#june-25-2021) (June 25, 2021)
### Added

- Enum `InputMediaType`
- Type `BanCommandScope`
- Type `BanCommandScopeDefault`
Expand Down Expand Up @@ -79,6 +88,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Interface `IUserTargetable`

### Changed

- Type `InlineQueryResultBase` renamed to `InlineQueryResult`
- Type `ChatMember` is made abstract
- Property `ChatMember.Status` is made abstract
Expand All @@ -102,6 +112,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- All optional types are made nullable be it value or reference types

### Removed

- Public setter `ChatMember.Status`
- Enum member `ParseMode.Default`
- Enum members `ChatAction.RecordAudio` and `ChatAction.UploadAudio`
Expand All @@ -112,15 +123,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Property setter `InputMediaBase.Media`
- Protected setter `InputOnlineFile.Url`
- All obsolete types, methods and properties related to polling events
- Following interfaces: `ICaptionEntities`, `IEntities`, `IFormattableEntities`, `IInlineMessage`,
`IInlineReplyMarkupMessage`, `INotifiableMessage`, `IReplyMarkupMessage`, `IReplyMessage`, `IThumbMediaMessage`,
`ICaptionInlineQueryResult`, `ILocationInlineQueryResult`, `IThumbnailInlineQueryResult`,
- Following interfaces: `ICaptionEntities`, `IEntities`, `IFormattableEntities`, `IInlineMessage`,
`IInlineReplyMarkupMessage`, `INotifiableMessage`, `IReplyMarkupMessage`, `IReplyMessage`, `IThumbMediaMessage`,
`ICaptionInlineQueryResult`, `ILocationInlineQueryResult`, `IThumbnailInlineQueryResult`,
`IThumbnailUrlInlineQueryResult`


## [v16.0.0] - 2021-06-13

### Changed

- `Animation` inherits from `FileBase`
- All custom exceptions are marked as obsolete

Expand Down Expand Up @@ -168,7 +179,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
## [v16.0.0-alpha.1] - 2021-05-01

> [Bot API 5.1](https://core.telegram.org/bots/api#march-9-2021) (March 9, 2021)
> [Bot API 5.0](https://core.telegram.org/bots/api#november-4-2020) (November 4, 2020)
### Added
Expand Down
13 changes: 0 additions & 13 deletions src/Telegram.Bot/ITelegramBotClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,5 @@ Task DownloadFileAsync(
Stream destination,
CancellationToken cancellationToken = default
);

/// <summary>
/// Use this method to get basic info about a file download it. For the moment, bots can download files of up to 20MB in size.
/// </summary>
/// <param name="fileId">File identifier to get info about</param>
/// <param name="destination">Destination stream to write file to</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>On success, a <see cref="File"/> object is returned.</returns>
Task<File> GetInfoAndDownloadFileAsync(
string fileId,
Stream destination,
CancellationToken cancellationToken = default
);
}
}
13 changes: 4 additions & 9 deletions src/Telegram.Bot/Telegram.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Title>Telegram Bot API Client</Title>
Expand All @@ -20,6 +18,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/TelegramBots/telegram.bot.git</RepositoryUrl>
<PackageTags>Telegram;Bot;Api;Payment;Inline;Games</PackageTags>
<AllowedOutputExtensionsInPackageBuildOutputFolder>
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
</AllowedOutputExtensionsInPackageBuildOutputFolder>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<ItemGroup>
Expand All @@ -36,13 +38,6 @@
<Deterministic>true</Deterministic>
</PropertyGroup>

<!-- Embed PBD files into test package built in CI because Azure Pipelines don't have symbols server yet -->
<PropertyGroup Condition="'$(CI_EMBED_SYMBOLS)' == 'true'">
<AllowedOutputExtensionsInPackageBuildOutputFolder>
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
Expand Down
15 changes: 0 additions & 15 deletions src/Telegram.Bot/TelegramBotClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,6 @@ static async Task<HttpResponseMessage> GetResponseAsync(
}
}

/// <inheritdoc />
public async Task<File> GetInfoAndDownloadFileAsync(
string fileId,
Stream destination,
CancellationToken cancellationToken = default)
{
var file = await MakeRequestAsync(new GetFileRequest(fileId), cancellationToken)
.ConfigureAwait(false);

await DownloadFileAsync(file.FilePath!, destination, cancellationToken)
.ConfigureAwait(false);

return file;
}

static string ExtractBaseUrl(string? baseUrl)
{
if (baseUrl is null) { throw new ArgumentNullException(paramName: nameof(baseUrl)); }
Expand Down
26 changes: 25 additions & 1 deletion src/Telegram.Bot/TelegramBotClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Telegram.Bot.Helpers;
Expand Down Expand Up @@ -1024,7 +1025,7 @@ await botClient.ThrowIfNull(nameof(botClient)).MakeRequestAsync(
/// Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. The file can then be downloaded via the link <c>https://api.telegram.org/file/bot&lt;token&gt;/&lt;file_path&gt;</c>, where <c>&lt;file_path&gt;</c> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling <see cref="GetFileAsync"/> again.
/// </summary>
/// <remarks>
/// You can use <see cref="ITelegramBotClient.DownloadFileAsync"/> or <see cref="ITelegramBotClient.GetInfoAndDownloadFileAsync"/> methods to download the file
/// You can use <see cref="ITelegramBotClient.DownloadFileAsync"/> or <see cref="TelegramBotClientExtensions.GetInfoAndDownloadFileAsync"/> methods to download the file
/// </remarks>
/// <param name="botClient">An instance of <see cref="ITelegramBotClient"/>.</param>
/// <param name="fileId">File identifier to get info about</param>
Expand All @@ -1038,6 +1039,29 @@ public static async Task<File> GetFileAsync(
await botClient.ThrowIfNull(nameof(botClient)).MakeRequestAsync(
new GetFileRequest(fileId), cancellationToken);

/// <summary>
/// Use this method to get basic info about a file download it. For the moment, bots can download files of up to 20MB in size.
/// </summary>
/// <param name="botClient">An instance of <see cref="ITelegramBotClient"/>.</param>
/// <param name="fileId">File identifier to get info about</param>
/// <param name="destination">Destination stream to write file to</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>On success, a <see cref="File"/> object is returned.</returns>
public static async Task<File> GetInfoAndDownloadFileAsync(
this ITelegramBotClient botClient,
string fileId,
Stream destination,
CancellationToken cancellationToken = default)
{
var file = await botClient.ThrowIfNull(nameof(botClient)).MakeRequestAsync(new GetFileRequest(fileId), cancellationToken)
.ConfigureAwait(false);

await botClient.DownloadFileAsync(file.FilePath!, destination, cancellationToken)
.ConfigureAwait(false);

return file;
}

/// <summary>
/// Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless <see cref="UnbanChatMemberAsync(ITelegramBotClient, ChatId, long, bool?, CancellationToken)">unbanned</see> first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram.Bot/Types/ChatLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public class ChatLocation
/// Location address; 1-64 characters, as defined by the chat owner
/// </summary>
[JsonProperty(Required = Required.Always)]
public string String { get; set; } = default!;
public string Address { get; set; } = default!;
}
}

0 comments on commit e3e812b

Please sign in to comment.