Try to Handle Commands ...

This commit is contained in:
2026-11-12 23:48:17 +03:30
parent fa59823008
commit 2b7209c5fb
11 changed files with 412 additions and 64 deletions
@@ -11,6 +11,8 @@ using System.Collections.Generic;
using xBotService.Interfaces.Dtos;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using xBotService.Constants;
using xBotService.Extensions;
namespace xBotService.Reciever
{
@@ -73,7 +75,7 @@ namespace xBotService.Reciever
//
// Log ...
logger.LogInformation($"Updates: {Environment.NewLine}{updates.ToJSON()}");
logger.LogInformation($"Updates: {Environment.NewLine}");
//
// HandleRecieved Updates ...
@@ -81,7 +83,7 @@ namespace xBotService.Reciever
{
//
logger
.LogInformation($"Handle Bot Update: {Environment.NewLine} {update}");
.LogInformation($"Handle Update: {Environment.NewLine} {update.ToJSON()}");
//
// Check Item Exists in Db ...
@@ -117,17 +119,65 @@ namespace xBotService.Reciever
//
// Check Verified ...
if (item.Verified)
if (item.IsVerified())
{
//
logger.LogInformation("User Verified ...");
continue;
}
//
// TODO: Remove this ...
if (item.BotUserName != "llhajamir")
{
continue;
}
//
// Handle Callback Commands ...
if (!update.CallbackQuery.IsNullOrDefault())
{
//
return;
}
//
// Try to Show Verification Menu on User ...
logger
.LogInformation($"Show Verification Request Method to User: {item.User.GetFullname()}");
var response = await botProvider.ShowVerificationMenu(
botUserId: item.BotUserId,
cancellationToken: cancellationToken
);
//
logger.LogInformation($"Verification Menu Shown for User: {item.BotUserId}");
}
}
public async Task HandleBotAction(XBotUpdateResponse update)
{
//
// Validate ...
if (update.IsNullOrDefault() ||
update.CallbackQuery.IsNullOrDefault() ||
update.CallbackQuery.Data.IsNullOrEmpty())
{
return;
}
//
// Switch Betwen Data ...
switch (update.CallbackQuery.Data)
{
//
case XBotMessageIds.XBotRequestVerificationCode:
{
//
// Remove Inline Keyboard ...
// And Send Verification ...
break;
}
}
}
}