Skip to content

Commit

Permalink
Fix command recognize
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Sep 15, 2022
1 parent fd95056 commit 8e85748
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/Corsinvest.ProxmoxVE.TelegramBot.Api/Commands/Api/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,27 @@ await botClient.ChooseInlineKeyboard(message.Chat.Id,
_typeRequest = TypeRequest.ArgParameter;

await botClient.SendTextMessageAsyncNoKeyboard(message.Chat.Id,
$"Insert value for parmater <b>{parametersArgs[0]}</b>");
$"Insert value for parametr <b>{parametersArgs[0]}</b>");
}
else if (requestArgs.Length == 0)
{
var pveClient = await GetClient();
//execute request
var (ResultCode, ResultText) = await ApiExplorerHelper.Execute(pveClient,
await PveHelperInt.GetClassApiRoot(pveClient),
resource,
MethodType,
ApiExplorerHelper.CreateParameterResource(parameters),
false,
TableGenerator.Output.Html);
await PveHelperInt.GetClassApiRoot(pveClient),
resource,
MethodType,
ApiExplorerHelper.CreateParameterResource(parameters),
false,
TableGenerator.Output.Html);

if (ResultCode != 200)
{
await botClient.SendTextMessageAsync(message.Chat.Id, $"Error: {ResultText}");
}
else
{
var filename = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(resource).Replace("/", "");
var filename = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(resource).Replace("/", "-");
await botClient.SendDocumentAsyncFromText(message.Chat.Id, ResultText, $"{filename}.html");
}

Expand All @@ -140,7 +140,7 @@ public override async Task<bool> Execute(Message message, TelegramBotClient botC
switch (_typeRequest)
{
case TypeRequest.Start:
_messageText = "";
_messageText = message.Text;
var args = ParserExtensions.Parse(new Parser(), _messageText).Tokens.Select(a => a.Value).ToList();
if (args.Count > 1) { _messageText = string.Join(" ", args.Skip(1).ToArray()); }
break;
Expand Down
3 changes: 3 additions & 0 deletions src/Corsinvest.ProxmoxVE.TelegramBot.Api/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ internal static Command GetCommand(string messageText)
if (messageText.Trim().StartsWith("/"))
{
var name = messageText.Trim()[1..];
var pos = name.IndexOf(" ");
if (pos > 0) { name = name[..pos]; }

command = GetCommands().FirstOrDefault(a => a.Names.Contains(name) || name == a.Name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Version>1.6.2</Version>
<Version>1.6.3</Version>
<Company>Corsinvest Srl</Company>
<Authors>Daniele Corsini</Authors>
<Copyright>Corsinvest Srl</Copyright>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>1.5.3</Version>
<Version>1.5.4</Version>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>cv4pve-botgram</AssemblyName>
<Company>Corsinvest Srl</Company>
Expand All @@ -19,7 +19,7 @@
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="7.3.7" />

<!-- <ProjectReference Include="..\Corsinvest.ProxmoxVE.TelegramBot.Api\Corsinvest.ProxmoxVE.TelegramBot.Api.csproj" /> -->
<PackageReference Include="Corsinvest.ProxmoxVE.TelegramBot.Api" Version="1.6.2" />
<PackageReference Include="Corsinvest.ProxmoxVE.TelegramBot.Api" Version="1.6.3" />
</ItemGroup>

<Target Name="SpicNSpan" AfterTargets="Clean">
Expand Down

0 comments on commit 8e85748

Please sign in to comment.