Adding additional bot command checks toa void invalid configurations

This commit is contained in:
Florian Zevedei
2024-06-09 14:13:43 +02:00
parent e3d1652a02
commit 834038ff44
3 changed files with 19 additions and 2 deletions
+12 -1
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Telegram.Bot.Types;
@@ -20,6 +21,16 @@ public static class Extensions
scope = BotCommandScope.Default();
}
if (string.IsNullOrEmpty(command))
{
throw new ArgumentNullException(nameof(command), $"{nameof(command)} parameter can not be null or empty");
}
if(command.StartsWith(Constants.Telegram.BotCommandIndicator))
{
throw new ArgumentException($"{nameof(command)} parameter does not have to start with a slash, please remove.", $"{nameof(command)}");
}
var item = cmds.FirstOrDefault(a => a.Key.Type == scope.Type);
if (item.Value != null)