Skip to content

Commit 4fc71b5

Browse files
committed
fix: now /cancel command works well.
1 parent 21f35f7 commit 4fc71b5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/LinkTracker.Bot/Commands/CommandDispatcher.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ public async Task HandleMessageAsync(ITelegramBotClient bot, Message msg, Cancel
2121

2222
if (messageText.StartsWith("/"))
2323
{
24-
var commandName = messageText.Split(' ')[0];
24+
var commandName = messageText.Split(' ')[0].ToLower();
25+
26+
if (commandName == "/cancel")
27+
{
28+
if (session.State == UserState.Idle)
29+
{
30+
await bot.SendMessage(chatId, "There is nothing to cancel.", cancellationToken: ct);
31+
}
32+
else
33+
{
34+
stateService.ResetSession(chatId);
35+
await bot.SendMessage(chatId, "Operation cancelled.", cancellationToken: ct);
36+
}
37+
return;
38+
}
2539

2640
if (session.State != UserState.Idle && commandName != "/track")
2741
{

0 commit comments

Comments
 (0)