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.
Install as nuget package:
Install-Package NetTelegramBotApi
Dependencies: Newtonsoft.Json
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.
- Changes in Telegram API defined as July 2015 implemented (issue #7):
- The
Caption
field has been removed from theVideo
object and added to theMessage
object instead. Caption
andDuration
optional fields have been added to theSendVideo
request.UserId
type in theContact
object changed to Long (was String - typo in API docs)- Changes, not [yet?] announced in Telegram API changlog:
Performer
andTitle
optional fields have been added toAudio
objectDuration
,Performer
andTitle
optional fields have been added to theSendAudio
request- Object
Voice
added (toMessage
class) SendVoice
request added
Improvements for working via webhooks:
SetWebhook
request added (Issue #3)DeserializeUpdate
method added to convert webhook POST json value toUpdate
object
Fixed 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):
- no more
System.Web
dependency; MakeRequest
method is now async only, use.Result
or.Wait()
for synchronous calls
Refactored 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!