From dd9b6a8145d58f353ff825fc4decb17d6b24eb79 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:29:09 +0200 Subject: [PATCH 1/3] updated some docs --- CHANGELOG.md | 41 +++++++++-------------------------------- CONTRIBUTING.md | 35 ++--------------------------------- README.md | 3 +-- 3 files changed, 12 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 339edfc94..387996332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,18 @@ -# Changelog +## [v21.*] - 2024-06-22 +Starting with version 21.x, changes are documented here: +https://telegrambots.github.io/book/Migration-Guide-to-Version-21.x.html + +We keep this library updated to the latest version of Telegram Bot API. +See the [latest changes to Bot API here](https://core.telegram.org/bots/api#recent-changes) + + + -## [v21.1.0] - 2024-06-23 - -### [Bot API 7.5](https://core.telegram.org/bots/api#june-18-2024) -Added GetStarTransactions method, and parameter BusinessConnectionId on various requests. - -## [v21.0.0] - 2024-06-22 - -### Rationalization of the library - -These changes are aimed at making your life simpler and should not break existing code and instead ease the migration from previous versions: - -- `ReplyParameters`: just pass an `int` when you just want to reply to a message -_(so the new replyParameters: parameter behaves the same as the old replyToMessageId: parameter)_ -- `LinkPreviewOptions`: just pass a `bool` (true) to disable link preview -_(so the new linkPreviewOptions: parameter behaves the same as the old disableWebPagePreview: parameter)_ -- `InputFile`: just pass a `string`/`Stream` for file_id/url/stream content _(as was possible in previous versions of Telegram.Bot)_ -- `InputMedia*`: just pass an `InputFile` when you don't need to associate caption or such -- `MessageId`: auto-converts to/from `int` (and also from `Message`) -- `ReactionType`: just pass a `string` when you want to send an emoji -- `ReactionType`: just pass a `long` when you want to send a custom emoji (id) -- Some other obvious implicit conversion operators for structures containing a single property -- No more enforcing `init;` properties, so you can adjust the content of fields as you wish or modify a structure returned by the API _(before passing it back to the API if you want)_ -- Not using the annoying `MaybeInaccessibleMessage`, you would just get a `Message` of type Unknown with Date==default if inaccessible -- Removed many [Obsolete] tags for things that still simplify your code -- Turned many `bool?` into normal `bool` (`false` is the same as `null`) -- Turned `ParseMode?` back into `ParseMode` (using `default` or `ParseMode.None` when unset) -- Restored some `MessageType` enum value that were removed (renamed) recently (easier compatibility) -- Recently added methods based on request structures are now obsolete and will be removed soon. Favor parameter-based methods instead. -If you already changed your code to use these structures and don't want to switch back, you can still use the `MakeRequestAsync` method to send them. - ## [v20.0.0] - 2024-06-15 > [Bot API 7.0](https://core.telegram.org/bots/api#december-29-2023) (December 29, 2023) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ba914921..2c83285fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,46 +13,15 @@ Before creating a pull request, make sure that your PR - Has the HEAD commit from `develop` branch - Has a clear message saying why this PR - References/Explains any related issues -- Has updated changelog in `CHANGELOG.md` file - -## Tests - -Unit Tests and Systems Integration Tests are meant to be examples for our users of how to interact with the Bot API. It is necessary for test methods to be highly readable, clear on their intents, and show expected behaviour of both systems. - -If commits in PR contain any changes to tests, ensure: - -- Types are explicitly declared (no use of `var` keyword). -- If possible, method calls to `ITelegramBotClient` have argument names explicitly mentioned ## Code Style ### Bot API Requests -All requests to Telegram Bot API are represented by classes derived from `RequestBase`. Required properties of a request must be get-only with value assigned in the constructor. +All requests to Telegram Bot API are represented by classes derived from `RequestBase`. If a request class (and its accompanying method on `ITelegramBotClient`) accepts a collection, the type must be `IEnumerable`. Also, return types of JSON array responses will be `TResult[]`. -For example, here is a request with required `allowedUpdates` and optional `offset` parameters that returns a JSON array as result: - -```c# -Task GetUpdatesAsync( - IEnumerable allowedUpdates, - int offset = default -); -``` - -```c# -class GetUpdatesRequest : RequestBase { - IEnumerable AllowedUpdates { get; } - int Offset { get; set; } - - public GetUpdatesRequest(IEnumerable allowedUpdates) - : base("getUpdates") - { AllowedUpdates = allowedUpdates; } -} -``` - ## Related Documents -- [Change Logs](./CHANGELOG.md) -- [Systems Integration Tests - How To](https://telegrambots.github.io/book/3/tests.html) +- [Systems Integration Tests - How To](https://github.com/TelegramBots/Telegram.Bot/blob/master/test/Telegram.Bot.Tests.Integ/README.md) diff --git a/README.md b/README.md index b89f24ca4..d69188c0d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# .NET Client for Telegram Bot API +# .NET Client for Telegram Bot API [![Nuget](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fnuget.voids.site%2Fv3%2Fpackage%2FTelegram.Bot%2Findex.json&query=versions%5B-1%3A%5D&style=flat-square&label=Telegram.Bot&color=d8b541)](https://nuget.voids.site/packages/Telegram.Bot) [![Bot API Version](https://img.shields.io/badge/Bot%20API-7.7-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api#july-7-2024) @@ -51,7 +51,6 @@ use it in your own bot projects. ## 🗂 References -- [Changelog](CHANGELOG.md) - [Documentation](https://telegrambots.github.io/book/) - [Examples](https://github.com/TelegramBots/Telegram.Bot.Examples) From 3eb63531d57c7963c20704ffa2086a2539f51378 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sat, 20 Jul 2024 02:16:27 +0200 Subject: [PATCH 2/3] ToMarkdown: fix escaping of '`' --- src/Telegram.Bot/Extensions/FormatExtensions.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Telegram.Bot/Extensions/FormatExtensions.cs b/src/Telegram.Bot/Extensions/FormatExtensions.cs index e5f87dd67..5b9899b8c 100644 --- a/src/Telegram.Bot/Extensions/FormatExtensions.cs +++ b/src/Telegram.Bot/Extensions/FormatExtensions.cs @@ -67,10 +67,12 @@ public static string ToMarkdown(string message, MessageEntity[]? entities) } switch (lastCh = sb[i]) { - case '_': case '*': case '~': case '`': case '#': case '+': case '-': case '=': case '.': case '!': + case '_': case '*': case '~': case '#': case '+': case '-': case '=': case '.': case '!': case '[': case ']': case '(': case ')': case '{': case '}': case '>': case '|': case '\\': - if (closings.Count == 0 || closings[0].md[0] != '`') - sb.Insert(i++, '\\'); + if (closings.Count != 0 && closings[0].md[0] == '`') break; + goto case '`'; + case '`': + sb.Insert(i++, '\\'); break; } } From 487f7251588866869037794ac4d710157a6ff9be Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sat, 20 Jul 2024 13:37:47 +0200 Subject: [PATCH 3/3] Releasing 21.7.1 --- .azure-pipelines/variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/variables.yml b/.azure-pipelines/variables.yml index e8674f462..d57c6f856 100644 --- a/.azure-pipelines/variables.yml +++ b/.azure-pipelines/variables.yml @@ -1,7 +1,7 @@ variables: - group: Integration Tests Variables - name: versionPrefix - value: 21.7.0 + value: 21.7.1 - name: versionSuffix value: '' - name: ciVersionSuffix