Updated readmes

This commit is contained in:
2026-03-07 20:46:04 +04:00
parent 6c3253107a
commit a3fd6a6007
7 changed files with 103 additions and 30 deletions
@@ -46,7 +46,7 @@ namespace Telegrator.Hosting.Web
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
_innerBuilder.AddTelegratorWeb(settings);
_innerBuilder.AddTelegratorWeb();
}
/// <summary>
@@ -60,7 +60,7 @@ namespace Telegrator.Hosting.Web
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
_innerBuilder.AddTelegratorWeb(settings, null, handlers);
_innerBuilder.AddTelegratorWeb(null, handlers);
}
/// <summary>
+77
View File
@@ -0,0 +1,77 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;
using Telegrator.Hosting;
using Telegrator.Hosting.Web;
namespace Telegrator;
internal class Program
{
public static void TelegramBotWebHostBuilder_Example(string[] args)
{
TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new WebApplicationOptions()
{
Args = args,
ApplicationName = "TelegramBotWebHost example",
});
builder.Handlers.CollectHandlersAssemblyWide();
builder.Build()
.AddLoggingAdapter()
.SetBotCommands()
.Run();
}
public static void WebApplicationBuilder_Example(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions()
{
Args = args,
ApplicationName = "WebApplication example",
});
builder.AddTelegratorWeb();
builder.Handlers.CollectHandlersAssemblyWide();
builder.Build()
.UseTelegratorWeb()
.AddLoggingAdapter()
.SetBotCommands()
.Run();
}
public static void TelegramBotHostBuilder_Example(string[] args)
{
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings()
{
Args = args,
ApplicationName = "TelegramBotHost example",
});
builder.Handlers.CollectHandlersAssemblyWide();
builder.Build()
.AddLoggingAdapter()
.SetBotCommands()
.Run();
}
public static void HostApplicationBuilder_Example(string[] args)
{
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
{
Args = args,
ApplicationName = "Host example",
});
builder.AddTelegrator();
builder.Handlers.CollectHandlersAssemblyWide();
builder.Build()
.UseTelegrator()
.AddLoggingAdapter()
.SetBotCommands()
.Run();
}
}
+10 -9
View File
@@ -16,8 +16,9 @@
---
## Requirements
- .NET 8.0 or later
- .NET 10.0 or later
- ASP.NET Core
- [Telegrator.Hosting](https://github.com/Rikitav/Telegrator)
---
@@ -37,10 +38,10 @@ using Telegrator.Hosting;
using Telegrator.Hosting.Web;
// Creating builder
TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new TelegramBotWebOptions()
TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new WebApplicationOptions()
{
Args = args,
ExceptIntersectingCommandAliases = true
ApplicationName = "Telegrator WebApplication example",
});
// Register handlers
@@ -61,23 +62,23 @@ telegramBot.Run();
```json
{
"TelegramBotClientOptions": {
"Token": "YOUR_BOT_TOKEN"
"TelegratorOptions": {
"Token": "YOUR_BOT_TOKEN",
"ExceptIntersectingCommandAliases": true
}
"TelegratorWebOptions": {
"WebhookerOptioons": {
"WebhookUri" = "https://you-public-host.ru/bot",
"SecretToken": "MEDIC_GAMING"
"DropPendingUpdates": true
}
}
```
- `TelegramBotClientOptions`: Bot token and client settings
---
## Documentation
- [Telegrator Main Docs](https://github.com/Rikitav/Telegrator)
- [Telegrator Main Repository](https://github.com/Rikitav/Telegrator)
- [Getting Started Guide](https://github.com/Rikitav/Telegrator/wiki/Getting-started)
- [Annotation Overview](https://github.com/Rikitav/Telegrator/wiki/Annotation-overview)
@@ -41,11 +41,8 @@ namespace Telegrator
/// <summary>
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
/// </summary>
public static IHostApplicationBuilder AddTelegratorWeb(this IHostApplicationBuilder builder, WebApplicationOptions settings, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
public static IHostApplicationBuilder AddTelegratorWeb(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
{
if (settings is null)
throw new ArgumentNullException(nameof(settings));
IServiceCollection services = builder.Services;
IConfigurationManager configuration = builder.Configuration;
+6 -5
View File
@@ -15,7 +15,7 @@
---
## Requirements
- .NET 8.0 or later
- .NET 10.0 or later
- [Telegrator](https://github.com/Rikitav/Telegrator)
---
@@ -35,10 +35,10 @@ dotnet add package Telegrator.Hosting
using Telegrator.Hosting;
// Creating builder
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new TelegramBotHostBuilderSettings()
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings()
{
Args = args,
ExceptIntersectingCommandAliases = true
ApplicationName = "TelegramBotHost example",
});
// Registerring handlers
@@ -59,8 +59,9 @@ telegramBot.Run();
```json
{
"TelegramBotClientOptions": {
"Token": "YOUR_BOT_TOKEN"
"TelegratorOptions": {
"Token": "YOUR_BOT_TOKEN",
"ExceptIntersectingCommandAliases": true
},
"HostOptions": {
+1 -4
View File
@@ -48,11 +48,8 @@ public static class HostBuilderExtensions
/// <summary>
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
/// </summary>
public static IHostApplicationBuilder AddTelegrator(this IHostApplicationBuilder builder, HostApplicationBuilderSettings settings, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
public static IHostApplicationBuilder AddTelegrator(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
{
if (settings is null)
throw new ArgumentNullException(nameof(settings));
IServiceCollection services = builder.Services;
IConfigurationManager configuration = builder.Configuration;