using System.Threading;
using Telegram.Bot;
using Telegram.Bot.Exceptions;
using Telegram.Bot.Polling;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
namespace TgramBotTutorial;
class Program
{
private static string API_KEY = "<INSERT_API_KEY>";
private static long ChannelId = <REPLACE_WITH_CHANNEL_ID>;
private static readonly TelegramBotClient botClient = new(API_KEY);
static async Task Main(string[] args)
{
long chatId = ChannelId;
CancellationToken cancellationToken = CancellationToken.None;
ReplyKeyboardMarkup replyKeyboardMarkup = new(new[]
{
new KeyboardButton[] { "Help me", "Call me ☎️" },
})
{
ResizeKeyboard = true
};
Message sentMessage = await botClient.SendTextMessageAsync(
chatId: chatId,
text: "Choose a response",
replyMarkup: replyKeyboardMarkup,
cancellationToken: cancellationToken);
}
}
Expected behavior
The CLI tool would send a message to the channel like a normal message. The channel ID is correct, as I have been following steps from other areas of the guide with no problem. This is specifically targeting the Custom Keyboards. Inline Keyboards are compiling and running as expected.
Actual behavior
Click Run in Visual Studio and error happens when reaches the example code. Won't send message.
Error code: Telegram.Bot.Exceptions.ApiRequestException: "Bad Request: inline keyboard expected" at Telegram.Bot.TelegramBotClient.<MakeRequestAsync>d__211.MoveNext()\n at Telegram.Bot.TelegramBotClientExtensions.d7.MoveNext()\n at TgramBotTutorial.Program.d3.MoveNext() in /Projects/TgramBotTutorial/Program.cs:30`
Screenshots
Environment data
NuGet Package Version: 19.0.0
.NET Version: 7.0.302
IDE: Visual Studio 2022 for Mac, Version 17.5.5 (build 12)
I found a bug to report
Please use the following template to ensure maintainers can reproduce the bug and solve it quickly.
Steps to reproduce
Copied the code directly from the guide produced by this repository https://telegrambots.github.io/book/2/reply-markup.html. Tried to compile the application and it failed.
Actual code used instead of photo in
Program.cs
:Expected behavior
The CLI tool would send a message to the channel like a normal message. The channel ID is correct, as I have been following steps from other areas of the guide with no problem. This is specifically targeting the Custom Keyboards. Inline Keyboards are compiling and running as expected.
Actual behavior
Click Run in Visual Studio and error happens when reaches the example code. Won't send message.
Error code:d7.MoveNext()\n at TgramBotTutorial.Program.d 3.MoveNext() in /Projects/TgramBotTutorial/Program.cs:30`
Telegram.Bot.Exceptions.ApiRequestException: "Bad Request: inline keyboard expected" at Telegram.Bot.TelegramBotClient.<MakeRequestAsync>d__21
1.MoveNext()\n at Telegram.Bot.TelegramBotClientExtensions.Screenshots
Environment data
NuGet Package Version: 19.0.0
.NET Version: 7.0.302
IDE: Visual Studio 2022 for Mac, Version 17.5.5 (build 12)
App: Compiled as a CLI application on macOS