Telegram.Bot.Api.Client 1.0.767

dotnet add package Telegram.Bot.Api.Client --version 1.0.767                
NuGet\Install-Package Telegram.Bot.Api.Client -Version 1.0.767                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Telegram.Bot.Api.Client" Version="1.0.767" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Telegram.Bot.Api.Client --version 1.0.767                
#r "nuget: Telegram.Bot.Api.Client, 1.0.767"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Telegram.Bot.Api.Client as a Cake Addin
#addin nuget:?package=Telegram.Bot.Api.Client&version=1.0.767

// Install Telegram.Bot.Api.Client as a Cake Tool
#tool nuget:?package=Telegram.Bot.Api.Client&version=1.0.767                

Telegram.Bot.Api.Client

GitHub Build Status Nuget

Coverage Quality Gate Status Reliability Rating Security Rating Vulnerabilities

Description

This is a .NET6 library for interacting with Telegram Bot Api.

This library is not finished and yet very limited

Quick start

Installation

dotnet add package Telegram.Bot.Api.Client

Appsettings.json

{
	"Telegram": {
		"Bot": {
			"BaseUrl": "https://api.telegram.org",
			"Token": "YOUR_BOT_TOKEN"
		}
	}
}

Add services

using Telegram.Bot.Api.Client.Extensions;

ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
	// this injects as SINGLETON
	services.AddTelegramBotServices(configuration);

	// you can also inject as SCOPED or TRANSIENT by specifying the ServiceLifetime
	services.AddTelegramBotServices(configuration, ServiceLifetime.Scoped);
}

Using services

using Telegram.Bot.Api.Client.Interfaces;
using Telegram.Bot.Api.Client.Services;

public class MyProcess
{
	private readonly ITelegramBotService _telegramBotService;

	public MyProcess(ITelegramBotService telegramBotService) =>
		_telegramBotService = telegramBotService;

	public async Task SendMessageAsync()
	{
		var response = await _telegramBotService.SendMessageAsync(
			new SendMessageModel
			{
				ChatId = "123456789",
				Text = "Hello World!"
			}
		);

		// or pass in another token so you can manipulate multiple bots at the same time
		var response = await _telegramBotService.SendMessageAsync(
			new SendMessageModel
			{
				ChatId = "123456789",
				Text = "Hello World!"
			},
			"ANOTHER_BOT_TOKEN"
		);

		// you should always check if the request was successful
		if (!res.IsSuccessStatusCode || !res.Content.Ok)
			// failed
			return;

		// success, do something
		...
	}
}

Reference

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.767 201 8/30/2023