Skip to content

Commit

Permalink
v22.3
Browse files Browse the repository at this point in the history
  • Loading branch information
wiz0u committed Jan 3, 2025
1 parent ed70afa commit 7c50e14
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Examples/2/SendMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private async Task SendAudio()
private async Task SendVoice()
{
// ANCHOR: send-voice
await using Stream stream = System.IO.File.OpenRead("/path/to/voice-nfl_commentary.ogg");
await using Stream stream = File.OpenRead("/path/to/voice-nfl_commentary.ogg");

Check failure on line 58 in Examples/2/SendMessage.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'

Check failure on line 58 in Examples/2/SendMessage.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'
var message = await bot.SendVoice(chatId, stream, duration: 36);
// ANCHOR_END: send-voice
}
Expand Down Expand Up @@ -188,7 +188,7 @@ await bot.SendVideo(chatId, "https://telegrambots.github.io/book/docs/video-coun
private async Task SendVideoNote()
{
// ANCHOR: send-video-note
await using Stream stream = System.IO.File.OpenRead("/path/to/video-waves.mp4");
await using Stream stream = File.OpenRead("/path/to/video-waves.mp4");

Check failure on line 191 in Examples/2/SendMessage.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'

Check failure on line 191 in Examples/2/SendMessage.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'

await bot.SendVideoNote(chatId, stream,
duration: 47, length: 360); // value of width/height
Expand Down
6 changes: 3 additions & 3 deletions Examples/3/Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async Task DownloadFile()
// ANCHOR: download-file
const string destinationFilePath = "../downloaded.file";

await using Stream fileStream = System.IO.File.Create(destinationFilePath);
await using Stream fileStream = File.Create(destinationFilePath);

Check failure on line 36 in Examples/3/Files.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'

Check failure on line 36 in Examples/3/Files.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'
await bot.DownloadFile(filePath, fileStream);
// ANCHOR_END: download-file
}
Expand All @@ -43,7 +43,7 @@ async Task GetInfoAndDownloadFile()
// ANCHOR: get-and-download-file
const string destinationFilePath = "../downloaded.file";

await using Stream fileStream = System.IO.File.Create(destinationFilePath);
await using Stream fileStream = File.Create(destinationFilePath);

Check failure on line 46 in Examples/3/Files.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'

Check failure on line 46 in Examples/3/Files.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'
var file = await bot.GetInfoAndDownloadFile(fileId, fileStream);
// ANCHOR_END: get-and-download-file
}
Expand All @@ -52,7 +52,7 @@ async Task GetInfoAndDownloadFile()
private async Task UploadLocalFile()
{
// ANCHOR: upload-local-file
await using Stream stream = System.IO.File.OpenRead("../hamlet.pdf");
await using Stream stream = File.OpenRead("../hamlet.pdf");

Check failure on line 55 in Examples/3/Files.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'

Check failure on line 55 in Examples/3/Files.cs

View workflow job for this annotation

GitHub Actions / Build and upload

'File' is an ambiguous reference between 'Telegram.Bot.Types.File' and 'System.IO.File'
var message = await bot.SendDocument(chatId, document: InputFile.FromStream(stream, "hamlet.pdf"),
caption: "The Tragedy of Hamlet,\nPrince of Denmark");
// ANCHOR_END: upload-local-file
Expand Down
9 changes: 4 additions & 5 deletions src/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ I recommend you read all of these as you will learn many interesting things. Or
<!-- toc -->

### _1. Can you give me documentation/examples links?_
- Follow [this installation guide](https://telegrambots.github.io/book/#-installation) to install the latest versions of the library.
- Here is the [main documentation website](https://telegrambots.github.io/book/).
- You can find [more bot example projects](https://github.com/TelegramBots/Telegram.Bot.Examples) here
- Search the [official API documentation](https://core.telegram.org/bots/api) and [official bots FAQ](https://core.telegram.org/bots/faq).
Expand Down Expand Up @@ -136,16 +135,16 @@ Remember that not every user has a username, and it can be changed.
Your bot has to be added as administrator of the channel.
You will then receive the messages as `update.ChannelPost` or `update.EditedChannelPost`.

### _27. How to sent the same media multiple times_
### _27. How to send the same media multiple times_
The first time, you will send the media with a stream (upload). Next times, you will use its **FileId**:
```csharp
var sent = await bot.SendVideo(chatId, stream, ....);
var fileId = sent.Video.FileId
var msg = await bot.SendVideo(chatId, stream, ....);
var fileId = msg.Video.FileId

// next times:
await bot.SendVideo(chatId2, fileId, ...);
```
For photos, use `sent.Photo[^1].FileId`
For photos, use `msg.Photo[^1].FileId`


### This FAQ doesn't have my question on it
Expand Down
10 changes: 9 additions & 1 deletion src/migrate/Version-22.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,12 @@ _(if you use this [non-recommended](Version-21.x.md#request-structures) method)_

- Support for [Bot API 8.1](https://core.telegram.org/bots/api-changelog#december-4-2024)
- Support for [Native AOT](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot) / [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot) / [Trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained)
_(this is still experimental and we would enjoy your feedback if you try to use the library in such contexts)_
_(this is still experimental and we would enjoy your feedback if you try to use the library in such contexts)_

## What's new in version 22.3

- Support for [Bot API 8.2](https://core.telegram.org/bots/api#january-1-2025)
- Renamed class `Telegram.Bot.Types.File` as `TGFile`
_(the name `File` was annoyingly conflicting with the often-used `System.IO.File` class)_
- Added property `Token` to `TelegramBotClient`
_(you can use it to `ParseValidateData` MiniApp requests, authenticate WebHook updates, ...)_

0 comments on commit 7c50e14

Please sign in to comment.