C# client library for building Telegram bot (https://core.telegram.org/bots/api)
Contains strongly-types request and response classes, and transport class for sending requests and receiving results.
var bot = new TelegramBot(accessToken);
var me = await bot.MakeRequestAsync(new GetMe());
if (me != null)
{
Console.WriteLine("Me: {0} (@{1})", me.FirstName, me.Username);
}
See TelegramBotDemo
project for more samples.
net8.0
onlynet6.0
onlynet5.0
onlySystem.Text.Json
replaces Newtosoft.Json
Telegram API updated up to v2.3 (November 21, 2016). Message editing, games - everything should work except inline mode (see below).
Breaking changes (compared to 3.8.1):
MakeRequestAsync
now throws BotRequestException
if non-Ok response is received from server.Contact
type: PhoneNumber
was PhoneNumbet
ReplyKeyboardHide
renamed to ReplyKeyboardRemove
(when it had been renamed in API???)EditMessage
replaced with DisableEditMessage
in SetGameScore
ReplyKeyboardRemove
: HideKeyboard
renamed to RemoveKeyboard
Inline mode
Inline mode needs a lot of new classes to be created. Please make PR if you wish to help.
netstandard1.3
SetWebhook
ParseMode
field to SendMessage
request for simple markdown markup (see FAQ for details)GetFile
request and File
object (run demo project and send him a picture!)WebProxy
property when creating bot (see issue #22 for sample)Project converted to Visual Studio 2015 and new project type (xproj
).
NuGet package now targets multiple runtimes: net45
, dnx45
, dnx50
and dnxcore50
.
New demo console app added (TelegramBotDemo-vNext
) for testing under dnx451
runtime. Old demo app ('classic' console project) also available, but Attention! Now it grabs package from nuget! (because old-style .csproj can't reference new .xproj assemblies directly).
Changes in Telegram API defined as August 15, 2015 implemented (issue #13).
All real changes were already implemented in 3.5.50816
, only some documenation/comments are updated in this version.
Caption
field has been removed from the Video
object and added to the Message
object instead.Caption
and Duration
optional fields have been added to the SendVideo
request.UserId
type in the Contact
object changed to Long (was String - typo in API docs)Performer
and Title
optional fields have been added to Audio
objectDuration
, Performer
and Title
optional fields have been added to the SendAudio
requestVoice
added (to Message
class)SendVoice
request addedImprovements for working via webhooks:
SetWebhook
request added (Issue #3)DeserializeUpdate
method added to convert webhook POST json value to Update
objectFixed issue #6 with sending files with non-latin characters in name.
Message
properties Date
and ForwardDate
are now DateTimeOffset (converted to local time).
Methods for sending files (SendPhoto
, SendVideo
, etc) implemented.
Switched to HttpClient (instead of HttpRequest):
System.Web
dependency;MakeRequest
method is now async only, use .Result
or .Wait()
for synchronous callsRefactored to new request model - base RequestBase
class and one (and one async) MakeRequest
method.
Major version increased to "2", patch version set to current date.
Response class hierarchy (Types
), first requests. It works!