mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Small cleanup
This commit is contained in:
@@ -10,7 +10,6 @@ using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.Core.Controllers
|
||||
{
|
||||
[Route("/Telegram")]
|
||||
public class Telegram : Controller
|
||||
{
|
||||
private const string SecretTokenHeader = "X-Telegram-Bot-Api-Secret-Token";
|
||||
@@ -33,9 +32,8 @@ namespace Kruzya.TelegramBot.Core.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Route("/WebHook")]
|
||||
[HttpPost]
|
||||
public IActionResult Index()
|
||||
public IActionResult Index([FromBody] Update? update)
|
||||
{
|
||||
if (_secretToken != null && !Request.Headers.ContainsKey(SecretTokenHeader))
|
||||
{
|
||||
@@ -50,15 +48,14 @@ namespace Kruzya.TelegramBot.Core.Controllers
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
LaunchHandle();
|
||||
LaunchHandle(update);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
private void LaunchHandle()
|
||||
private void LaunchHandle(Update? update)
|
||||
{
|
||||
try
|
||||
{
|
||||
var update = JsonConvert.DeserializeObject<Update>(Request.Body.ToString());
|
||||
if (update == null)
|
||||
{
|
||||
throw new System.Exception("Invalid request body");
|
||||
|
||||
Reference in New Issue
Block a user