1111using Botticelli . Shared . ValueObjects ;
1212using FluentValidation ;
1313using Microsoft . Extensions . Logging ;
14- using Telegram . Bot . Types . ReplyMarkups ;
1514
1615namespace MessagingSample . Common . Commands . Processors ;
1716
1817public class StartCommandProcessor < TReplyMarkup > : CommandProcessor < StartCommand > where TReplyMarkup : class
1918{
2019 private readonly IJobManager _jobManager ;
2120 private readonly SendOptionsBuilder < TReplyMarkup > _options ;
22-
21+
2322 public StartCommandProcessor ( ILogger < StartCommandProcessor < TReplyMarkup > > logger ,
24- ICommandValidator < StartCommand > commandValidator ,
25- MetricsProcessor metricsProcessor ,
26- IJobManager jobManager ,
27- ILayoutSupplier < TReplyMarkup > layoutSupplier ,
28- ILayoutParser layoutParser ,
29- IValidator < Message > messageValidator )
23+ ICommandValidator < StartCommand > commandValidator ,
24+ MetricsProcessor metricsProcessor ,
25+ IJobManager jobManager ,
26+ ILayoutSupplier < TReplyMarkup > layoutSupplier ,
27+ ILayoutParser layoutParser ,
28+ IValidator < Message > messageValidator )
3029 : base ( logger , commandValidator , metricsProcessor , messageValidator )
3130 {
3231 _jobManager = jobManager ;
3332
3433 var location = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ?? string . Empty ;
3534 var responseLayout = layoutParser . ParseFromFile ( Path . Combine ( location , "main_layout.json" ) ) ;
3635 var responseMarkup = layoutSupplier . GetMarkup ( responseLayout ) ;
37-
36+
3837 _options = SendOptionsBuilder < TReplyMarkup > . CreateBuilder ( responseMarkup ) ;
3938 }
4039
@@ -46,7 +45,7 @@ public StartCommandProcessor(ILogger<StartCommandProcessor<TReplyMarkup>> logger
4645
4746 protected override async Task InnerProcess ( Message message , CancellationToken token )
4847 {
49- var chatId = message . ChatIds . FirstOrDefault ( ) ;
48+ var chatId = message . ChatIds . First ( ) ;
5049 var greetingMessageRequest = new SendMessageRequest
5150 {
5251 Message = new Message
@@ -59,7 +58,7 @@ protected override async Task InnerProcess(Message message, CancellationToken to
5958
6059 await Bot . SendMessageAsync ( greetingMessageRequest , _options , token ) ;
6160
62- var assemblyPath = Path . GetDirectoryName ( typeof ( StartCommandProcessor < TReplyMarkup > ) . Assembly . Location ) ;
61+ var assemblyPath = Path . GetDirectoryName ( typeof ( StartCommandProcessor < TReplyMarkup > ) . Assembly . Location ) ?? throw new FileNotFoundException ( ) ;
6362 _jobManager . AddJob ( Bot ,
6463 new Reliability
6564 {
@@ -81,11 +80,11 @@ protected override async Task InnerProcess(Message message, CancellationToken to
8180 Poll = new Poll
8281 {
8382 Question = "To be or not to be?" ,
84- Variants = new [ ]
85- {
83+ Variants =
84+ [
8685 "To be!" ,
8786 "Not to be!"
88- } ,
87+ ] ,
8988 CorrectAnswerId = 0 ,
9089 IsAnonymous = false ,
9190 Type = Poll . PollType . Quiz
0 commit comments