WTelegramBot 7.7.1-dev.1
See the version list below for details.
dotnet add package WTelegramBot --version 7.7.1-dev.1
NuGet\Install-Package WTelegramBot -Version 7.7.1-dev.1
<PackageReference Include="WTelegramBot" Version="7.7.1-dev.1" />
paket add WTelegramBot --version 7.7.1-dev.1
#r "nuget: WTelegramBot, 7.7.1-dev.1"
// Install WTelegramBot as a Cake Addin #addin nuget:?package=WTelegramBot&version=7.7.1-dev.1&prerelease // Install WTelegramBot as a Cake Tool #tool nuget:?package=WTelegramBot&version=7.7.1-dev.1&prerelease
Powerful Telegram Bot API library for .NET
WTelegramBot is a full rewrite in pure C# of Telegram Bot API server, presenting the same methods as the Telegram.Bot library for easy migration.
The library is built on top of WTelegramClient to connect directly to Telegram Client API and gives you additional control over your bot, updates and call methods normally impossible to use with Bot API.
[!IMPORTANT]
Library now depends on Telegram.Bot v21.* which is not available on Nuget at the moment.
You will need to configure Nuget options or setup a nuget.config file before installing WTelegramBot
Advantages of WTelegram.Bot
Using class WTelegram.Bot
you have access to a clean set of developer-friendly methods to easily access the Bot API
You can also call Client API methods that are possible for bots but not accessible from Bot API! Some examples:
- Fetch past messages of group/channel
- Get group/channel members list
- Resolve user/chat usernames
- Get full details of users/chats
- Send/receive big files
You also get access to raw Updates information from Client API, in addition to the usual Bot API updates. They contain more information than the limited set of Bot API updates! Some examples:
- Detect deletion of messages (not always immediate)
- Get more info on message media (like date of original media upload, sticker duration, ...)
- Notification when your messages were read in a group
See the Example app for a nice demonstration of features.
➡️ There are still a lot of restrictions to bots, even via Client API, so don't expect to be able to do many fancy things
<a name="migration"></a>
Difference between classes WTelegram.Bot
and TelegramBotClient
The library contains a compatibility layer as Telegram.Bot.WTelegramBotClient
inheriting from WTelegram.Bot.
Click here to easily migrate your existing Telegram.Bot code.
If you're not migrating an existing codebase, it is recommended that you use WTelegram.Bot
class directly.
Here are the main differences:
- The method names don't have the *Async suffix (even though they should still be invoked with
await
) so they are more close to official Bot API method names. - The optional parameters follow a more logical order for developers, with the more rarely used optional parameters near the end.
- There is no CancellationToken parameter because it doesn't make sense to abort an immediate TCP request to Client API.
(Even with HTTP Bot API, it didn't make much sense: You can use cancellationToken.ThrowIfCancellationRequested() at various points of your own code if you want it to be cancellable) - In case of an error, WTelegram.Bot will throw
WTelegram.WTException
likeTL.RpcException
showing the raw Telegram error, instead of an ApiRequestException WTelegram.Bot
andWTelegramBotClient
areIDisposable
, so remember to call.Dispose()
How to access the advanced features?
The Example app demonstrates all of the features below.
On each Update/Message/User/Chat you receive, there is an extra field named "TL...
" that contains the corresponding raw Client API structure, which may contain extra information not transcribed into the Bot API
You can also enable TelegramBotClient.WantUnknownTLUpdates
to receive updates that usually would have been silently ignored by Bot API
(they will be posted as Update of type Unknown with the TLUpdate field filled)
Some extended API calls can be made via WTelegram.Bot
special methods:
GetChatMemberList
: fetch a list of chat membersGetMessagesById
: fetch posted messages (or range of messages) based on their message IDsInputUser
: can resolve a username into a user ID that you can then use with GetChatGetChat
: can obtain details about any group/channel based on their public name, or a user ID resolved by InputUser
Other extended API calls not usually accessible to Bot API can be made via the Bot.Client
property which is the underlying WTelegramClient instance.
- This way, you can use new features available only in Client API latest layers without waiting months for it to be available in Bot API
For more information about calling Client API methods, you can read that library's documentation or search through the official Client API documentation, but make sure to look for the mention "Bots can use this method" (other methods can't be called).
[!NOTE]
If you want to experiment with these, you'll need to add ausing TL;
on top of your code, and these calls might throwTL.RpcException
instead ofApiRequestException
Some other WTelegram.Bot
methods (for example, beginning with Input*) and extension methods can help you convert Bot API ids or structure to/from Client API.
Help with the library
This library is still quite new but I tested it extensively to make sure it covers all of the Bot API successfully.
If you have questions about the (official) Bot API methods from TelegramBotClient, you can ask them in Telegram.Bot support chat.
If your question is more specific to WTelegram.Bot, or an issue with library behaviour, you can ask them in @WTelegramClient.
If you like this library, you can buy me a coffee ❤ This will help the project keep going.
© 2024 Olivier Marcoux
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- Telegram.Bot (>= 21.7.1)
- WTelegramClient (>= 4.1.5)
-
net6.0
- Telegram.Bot (>= 21.7.1)
- WTelegramClient (>= 4.1.5)
-
net8.0
- Telegram.Bot (>= 21.7.1)
- WTelegramClient (>= 4.1.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on WTelegramBot:
Package | Downloads |
---|---|
ZiziBot.TelegramBot.Framework
Building command-based Telegram Bot |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.11.1-dev.1 | 34 | 11/6/2024 |
7.10.3-dev.5 | 74 | 10/12/2024 |
7.10.3-dev.4 | 41 | 10/10/2024 |
7.10.3-dev.3 | 42 | 10/9/2024 |
7.10.3-dev.2 | 63 | 9/21/2024 |
7.10.3-dev.1 | 39 | 9/21/2024 |
7.10.2 | 615 | 9/8/2024 |
7.9.2-dev.3 | 51 | 9/7/2024 |
7.9.2-dev.2 | 45 | 9/7/2024 |
7.9.1 | 300 | 8/14/2024 |
7.8.2-dev.2 | 60 | 8/14/2024 |
7.8.2-dev.1 | 60 | 8/14/2024 |
7.8.1 | 204 | 7/31/2024 |
7.7.1 | 140 | 7/21/2024 |
7.7.1-dev.4 | 50 | 7/21/2024 |
7.7.1-dev.3 | 56 | 7/21/2024 |
7.7.1-dev.2 | 56 | 7/21/2024 |
7.7.1-dev.1 | 54 | 7/20/2024 |
7.6.2 | 120 | 7/20/2024 |
7.6.1 | 148 | 7/6/2024 |
7.4.1-dev.6 | 40 | 7/5/2024 |
7.4.1-dev.4 | 42 | 7/1/2024 |
7.4.1-dev.2 | 59 | 6/10/2024 |
7.4.1-dev.1 | 58 | 6/6/2024 |
7.3.2-dev.1 | 48 | 6/5/2024 |
7.3.1 | 237 | 6/4/2024 |
7.3.1-dev.4 | 52 | 6/4/2024 |
7.3.1-dev.3 | 77 | 5/7/2024 |
7.3.1-dev.2 | 65 | 5/7/2024 |
7.3.1-dev.1 | 70 | 5/6/2024 |
7.2.1-dev.1 | 63 | 4/30/2024 |
7.2.0 | 186 | 4/29/2024 |
7.2.0-dev.8 | 56 | 4/29/2024 |
Bot API 7.7