Skip to content

Commit

Permalink
Merge pull request #1317 from TelegramBots/develop
Browse files Browse the repository at this point in the history
Bot API 6.8 and 6.9
  • Loading branch information
tuscen committed Oct 30, 2023
2 parents 6fe1f1e + 582eef1 commit 8b53002
Show file tree
Hide file tree
Showing 28 changed files with 266 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .azure-pipelines/variables.yml
@@ -1,9 +1,9 @@
variables:
- group: Integration Tests Variables
- name: versionPrefix
value: 19.0.0
value: 20.0.0
- name: versionSuffix
value: ''
value: 'alpha.1'
- name: ciVersionSuffix
value: ci.$(Build.BuildId)+git.commit.$(Build.SourceVersion)
- name: isPreRelease
Expand Down
34 changes: 33 additions & 1 deletion CHANGELOG.md
Expand Up @@ -21,7 +21,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

<!-- markdownlint-configure-file { "MD024": false } -->

## [v19.0.0-preview.4] - Unreleased
## [v20.0.0] - Unreleased

> [Bot API 6.9](https://core.telegram.org/bots/api#september-22-2023) (September 22, 2023)
### Added

- The new administrator privileges `CanPostStories`, `CanEditStories` and `CanDeleteStories`
to the classes `ChatMemberAdministrator` and `ChatAdministratorRights`.
- The parameters `CanPostStories`, `CanEditStories` and `CanDeleteStories` to the method `ITelegramBotClient.PromoteChatMemberAsync`
and `PromoteChatMemberRequest`.Currently, bots have no use for these privileges besides assigning them to other administrators.
- The properties `FromRequest` and `FromAttachmentMenu` to the class `WriteAccessAllowed`.

> [Bot API 6.8](https://core.telegram.org/bots/api#august-18-2023) (August 18, 2023)
### Added

- Type `Story`.
- Member `Story` to the enum `MessageType`
- Property `Story? Story` to the class `Message`. Currently, it holds no information.
- Property `Chat? VoterChat` to the `PollAnswer` class. For backward compatibility, the field user in
such objects will contain the user `136817688` (`@Channel_Bot`).
- Property `DateTime? EmojiStatusExpirationDate` to the `Chat` class.
- New request related to topics:
- `UnpinAllGeneralForumTopicMessages`
- New method related to topics:
- `ITelegramBotClient.UnpinAllGeneralForumTopicMessagesAsync`

### Changed

- Property `User? User` in the `PollAnswer` class is optional now.

## [v19.0.0] - 2023-05-07

> [Bot API 6.7](https://core.telegram.org/bots/api#april-21-2023) (April 21, 2023)
Expand Down Expand Up @@ -134,6 +165,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Stickers tests

### Removed

- Class `AddAnimatedStickerToSetRequest`
- Class `AddStaticStickerToSetRequest`
- Class `AddVideoStickerToSetRequest`
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
# .NET Client for Telegram Bot API

[![package](https://img.shields.io/nuget/vpre/Telegram.Bot.svg?label=Telegram.Bot&style=flat-square)](https://www.nuget.org/packages/Telegram.Bot)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-6.7%20(April%2021,%202023)-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api#march-9-2023)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-6.9%20(September%2022,%202023)-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api#september-22-2023)
[![documentations](https://img.shields.io/badge/Documentations-Book-orange.svg?style=flat-square)](https://telegrambots.github.io/book/)
[![telegram chat](https://img.shields.io/badge/Support_Chat-Telegram-blue.svg?style=flat-square)](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA)

Expand Down
2 changes: 1 addition & 1 deletion global.json
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "7.0.400",
"rollForward": "latestFeature"
}
}
6 changes: 3 additions & 3 deletions src/EnumSerializer.Generator/EnumSerializer.Generator.csproj
Expand Up @@ -14,10 +14,10 @@

<!-- The following libraries include the source generator interfaces and types we need -->
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.45" PrivateAssets="all" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.85" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" PrivateAssets="all" />
<PackageReference Include="Scriban" Version="5.7.0" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="Scriban" Version="5.9.0" GeneratePathProperty="true" PrivateAssets="all" />

<!-- This ensures the library will be packaged as a source generator when we use `dotnet pack` -->
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
Expand Down
14 changes: 7 additions & 7 deletions src/Telegram.Bot/Converters/ChatMemberConverter.cs
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using Newtonsoft.Json.Linq;
using Telegram.Bot.Types.Enums;

Expand Down Expand Up @@ -42,13 +42,13 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer

var actualType = status switch
{
ChatMemberStatus.Creator => typeof(ChatMemberOwner),
ChatMemberStatus.Creator => typeof(ChatMemberOwner),
ChatMemberStatus.Administrator => typeof(ChatMemberAdministrator),
ChatMemberStatus.Member => typeof(ChatMemberMember),
ChatMemberStatus.Left => typeof(ChatMemberLeft),
ChatMemberStatus.Kicked => typeof(ChatMemberBanned),
ChatMemberStatus.Restricted => typeof(ChatMemberRestricted),
_ => throw new JsonSerializationException($"Unknown chat member status value of '{jo["status"]}'")
ChatMemberStatus.Member => typeof(ChatMemberMember),
ChatMemberStatus.Left => typeof(ChatMemberLeft),
ChatMemberStatus.Kicked => typeof(ChatMemberBanned),
ChatMemberStatus.Restricted => typeof(ChatMemberRestricted),
_ => throw new JsonSerializationException($"Unknown chat member status value of '{jo["status"]}'")
};

// Remove status because status property only has getter
Expand Down
8 changes: 4 additions & 4 deletions src/Telegram.Bot/Converters/MenuButtonConverter.cs
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using Newtonsoft.Json.Linq;
using Telegram.Bot.Types.Enums;

Expand Down Expand Up @@ -43,10 +43,10 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer

var actualType = status switch
{
MenuButtonType.Default => typeof(MenuButtonDefault),
MenuButtonType.Default => typeof(MenuButtonDefault),
MenuButtonType.Commands => typeof(MenuButtonCommands),
MenuButtonType.WebApp => typeof(MenuButtonWebApp),
_ => throw new JsonSerializationException($"Unknown menu button type value of '{typeToken}'")
MenuButtonType.WebApp => typeof(MenuButtonWebApp),
_ => throw new JsonSerializationException($"Unknown menu button type value of '{typeToken}'")
};

// Remove status because status property only has getter
Expand Down
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
Expand Down Expand Up @@ -104,7 +104,7 @@ public Enumerator(QueuedUpdateReceiver receiver, CancellationToken cancellationT
);

#pragma warning disable CA2016
Task.Run(ReceiveUpdatesAsync);
_ = Task.Run(ReceiveUpdatesAsync);
#pragma warning restore CA2016
}

Expand Down
Expand Up @@ -9,7 +9,7 @@ namespace Telegram.Bot.Requests;
/// </summary>
/// <remarks>
/// Alternatively, the user can be redirected to the specified Game URL.For this option to work, you
/// must first create a game for your bot via <c>@Botfather</c> and accept the terms. Otherwise, you
/// must first create a game for your bot via <c>@BotFather</c> and accept the terms. Otherwise, you
/// may use links like <c>t.me/your_bot? start = XXXX</c> that open your bot with a parameter.
/// </remarks>
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
Expand Down Expand Up @@ -37,7 +37,7 @@ public class AnswerCallbackQueryRequest : RequestBase<bool>
/// <summary>
/// URL that will be opened by the user's client. If you have created a
/// <a href="https://core.telegram.org/bots/api#game">Game</a> and accepted the conditions
/// via <c>@Botfather</c>, specify the URL that opens your game — note that this will only work
/// via <c>@BotFather</c>, specify the URL that opens your game — note that this will only work
/// if the query comes from a callback_game button.
/// <para>
/// Otherwise, you may use links like <c>t.me/your_bot? start = XXXX</c> that open your bot with
Expand Down
Expand Up @@ -52,6 +52,24 @@ public class PromoteChatMemberRequest : RequestBase<bool>, IChatTargetable, IUse
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? CanDeleteMessages { get; set; }

/// <summary>
/// Pass <see langword="true"/> if the administrator can post stories in the channel; channels only
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? CanPostStories { get; set; }

/// <summary>
/// Pass <see langword="true"/> if the administrator can edit stories posted by other users; channels only
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? CanEditStories { get; set; }

/// <summary>
/// Pass <see langword="true"/> if the administrator can delete stories posted by other users; channels only
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? CanDeleteStories { get; set; }

/// <summary>
/// Pass <see langword="true"/>, if the administrator can manage video chats
/// </summary>
Expand Down
@@ -0,0 +1,27 @@
using Telegram.Bot.Requests.Abstractions;

// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;

/// <summary>
/// Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in
/// the chat for this to work and must have the <see cref="ChatAdministratorRights.CanPinMessages"/> administrator right in the supergroup.
/// Returns <see langword="true"/> on success.
/// </summary>
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public class UnpinAllGeneralForumTopicMessages : RequestBase<bool>, IChatTargetable
{
/// <inheritdoc />
[JsonProperty(Required = Required.Always)]
public ChatId ChatId { get; }

/// <summary>
/// Initializes a new request
/// </summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup</param>
public UnpinAllGeneralForumTopicMessages(ChatId chatId)
: base("unpinAllGeneralForumTopicMessages")
{
ChatId = chatId;
}
}
4 changes: 2 additions & 2 deletions src/Telegram.Bot/Requests/Games/SendGameRequest.cs
Expand Up @@ -27,7 +27,7 @@ public class SendGameRequest : RequestBase<Message>, IChatTargetable

/// <summary>
/// Short name of the game, serves as the unique identifier for the game. Set up your games
/// via <a href="https://t.me/botfather">@Botfather</a>
/// via <a href="https://t.me/botfather">@BotFather</a>
/// </summary>
[JsonProperty(Required = Required.Always)]
public string GameShortName { get; }
Expand Down Expand Up @@ -58,7 +58,7 @@ public class SendGameRequest : RequestBase<Message>, IChatTargetable
/// <param name="chatId">Unique identifier for the target chat</param>
/// <param name="gameShortName">
/// Short name of the game, serves as the unique identifier for the game. Set up your games via
/// <a href="https://t.me/botfather">@Botfather</a>
/// <a href="https://t.me/botfather">@BotFather</a>
/// </param>
public SendGameRequest(long chatId, string gameShortName)
: base("sendGame")
Expand Down
Expand Up @@ -30,7 +30,7 @@ public class CreateInvoiceLinkRequest : RequestBase<string>
public string Payload { get; }

/// <summary>
/// Payments provider token, obtained via <a href="https://t.me/botfather">@Botfather</a>
/// Payments provider token, obtained via <a href="https://t.me/botfather">@BotFather</a>
/// </summary>
[JsonProperty(Required = Required.Always)]
public string ProviderToken { get; }
Expand Down Expand Up @@ -150,7 +150,7 @@ public class CreateInvoiceLinkRequest : RequestBase<string>
/// <param name="description">Product description, 1-255 characters</param>
/// <param name="payload">Bot-defined invoice payload, 1-128 bytes</param>
/// <param name="providerToken">
/// Payments provider token, obtained via <a href="https://t.me/botfather">@Botfather</a>
/// Payments provider token, obtained via <a href="https://t.me/botfather">@BotFather</a>
/// </param>
/// <param name="currency">
/// Three-letter ISO 4217 currency code, see
Expand Down
4 changes: 2 additions & 2 deletions src/Telegram.Bot/Requests/Payments/SendInvoiceRequest.cs
Expand Up @@ -48,7 +48,7 @@ public class SendInvoiceRequest : RequestBase<Message>, IChatTargetable
public string Payload { get; }

/// <summary>
/// Payments provider token, obtained via <a href="https://t.me/botfather">@Botfather</a>
/// Payments provider token, obtained via <a href="https://t.me/botfather">@BotFather</a>
/// </summary>
[JsonProperty(Required = Required.Always)]
public string ProviderToken { get; }
Expand Down Expand Up @@ -202,7 +202,7 @@ public class SendInvoiceRequest : RequestBase<Message>, IChatTargetable
/// <param name="description">Product description, 1-255 characters</param>
/// <param name="payload">Bot-defined invoice payload, 1-128 bytes</param>
/// <param name="providerToken">
/// Payments provider token, obtained via <a href="https://t.me/botfather">@Botfather</a>
/// Payments provider token, obtained via <a href="https://t.me/botfather">@BotFather</a>
/// </param>
/// <param name="currency">
/// Three-letter ISO 4217 currency code, see
Expand Down
4 changes: 2 additions & 2 deletions src/Telegram.Bot/Telegram.Bot.csproj
Expand Up @@ -79,9 +79,9 @@
</ItemGroup>

<ItemGroup Label="Dev">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.45" PrivateAssets="all" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.85" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" PrivateAssets="All" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
<ProjectReference Include="..\EnumSerializer.Generator\EnumSerializer.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
Expand Down

0 comments on commit 8b53002

Please sign in to comment.