rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.78k stars 1.22k forks source link

Can't set custom keyboard (ReplyKeyboardMarkup) on channel #397

Closed elFerZur closed 6 years ago

elFerZur commented 6 years ago

Trying to set custom keyboard:

ReplyKeyboardMarkup replyKeyboardMarkup=new ReplyKeyboardMarkup();
List<KeyboardRow> rows=new ArrayList<>();
KeyboardRow row=new KeyboardRow();
KeyboardButton keyboardButton=new KeyboardButton("Button 1");
row.add(keyboardButton);
rows.add(row);
replyKeyboardMarkup.setKeyboard(rows);
replyKeyboardMarkup.setOneTimeKeyboard(false);
SendMessage message = new SendMessage() ;
              .setChatId(chatId)
              .setText("Configurando Keyboard")
              .setReplyMarkup(replyKeyboardMarkup);

But always same error: Error sending message: [400] Bad Request: inline keyboard expected Sending message: "{"chat_id":"-1011336565116","text":"Configurando Keyboard","reply_markup":{"@class":"org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup","keyboard":[[{"@class":"org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton","text":"Button 1"}]],"one_time_keyboard":false},"method":"sendmessage"}"

rubenlagus commented 6 years ago

@elFerZur Are you trying to use it in a channel? Or group? Can you explain a bit more the situation?

Andy-ch commented 6 years ago

@rubenlagus I tried to make a keyboard in a channel and failed with this error. I would like to know if it is even possible in a channel, I have an impression you can't reply in any way in a channel

gekoramy commented 6 years ago

You can’t send a Reply Keyboard in a channel, indeed subscribers cannot send messages. But you can send an Inline Keyboard.