Add channel system with CLI, Telegram, and Web channel implementations
Define channel abstractions (IChannel, IChannelManager) with event-driven message and connection handling. Implement ChannelManager for multi-channel orchestration, CliChannel for terminal I/O, TelegramChannel with adapter pattern for bot API integration, and WebChannel stub. Includes DI registration and channel type enumeration.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Luna.Channels.Abstractions;
|
||||
using Luna.Channels.Telegram;
|
||||
using Luna.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Telegram.Bot;
|
||||
|
||||
namespace Luna.Channels.Extensions;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
private const string TelegramBotToken = "REDACTED-TELEGRAM-BOT-TOKEN";
|
||||
|
||||
extension(IServiceCollection services)
|
||||
{
|
||||
public IServiceCollection AddChannels()
|
||||
{
|
||||
services.AddSingleton<IChannelManager, ChannelManager>();
|
||||
|
||||
// Telegram
|
||||
var telegramOptions = new TelegramOptions { BotToken = TelegramBotToken };
|
||||
services.AddSingleton(telegramOptions);
|
||||
services.AddSingleton<ITelegramBotClient>(_ => new TelegramBotClient(TelegramBotToken));
|
||||
services.AddHostedService<TelegramAdapter>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user