本文整理汇总了Java中org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup类的典型用法代码示例。如果您正苦于以下问题:Java ReplyKeyboardMarkup类的具体用法?Java ReplyKeyboardMarkup怎么用?Java ReplyKeyboardMarkup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReplyKeyboardMarkup类属于org.telegram.telegrambots.api.objects.replykeyboard包,在下文中一共展示了ReplyKeyboardMarkup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendReplyKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
public Message sendReplyKeyboard(long chatId, String message, String[][] keyboardText, boolean oneTimeKeyboard) {
ReplyKeyboardMarkup keyboard = new ReplyKeyboardMarkup();
keyboard.setOneTimeKeyboard(oneTimeKeyboard);
List<KeyboardRow> keyboardRows = new ArrayList<>();
for (String[] rows : keyboardText) {
KeyboardRow keyboardRow = new KeyboardRow();
for (String row : rows) {
keyboardRow.add(row);
}
keyboardRows.add(keyboardRow);
}
keyboard.setKeyboard(keyboardRows);
SendMessage sendMessage = new SendMessage(chatId, message);
sendMessage.setReplyMarkup(keyboard);
return execute(sendMessage);
}
开发者ID:enoy19,项目名称:spring-tg,代码行数:20,代码来源:TgMessageServiceContextless.java
示例2: createMainSelectKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
/**
* Creates the main select menu for selecting a date
* @return the keyboard
*/
public ReplyKeyboard createMainSelectKeyboard() {
ReplyKeyboardMarkup keyboard = new ReplyKeyboardMarkup();
KeyboardRow firstRow = new KeyboardRow();
firstRow.add(messagesService.getMessage(Messages.COMMAND_DATE_TODAY));
firstRow.add(messagesService.getMessage(Messages.COMMAND_DATE_TOMORROW));
KeyboardRow secondRow = new KeyboardRow();
secondRow.add(messagesService.getMessage(Messages.COMMAND_CHANGE_MENSA));
secondRow.add(messagesService.getMessage(Messages.COMMAND_WEEKDAYS));
KeyboardRow thirdRow = new KeyboardRow();
KeyboardButton selectNearestMensaButton = new KeyboardButton(messagesService.getMessage(Messages.COMMAND_SELECT_NEAREST_MENSA));
selectNearestMensaButton.setRequestLocation(true);
thirdRow.add(selectNearestMensaButton);
keyboard.setResizeKeyboard(true);
keyboard.setKeyboard(Arrays.asList(firstRow, secondRow, thirdRow));
return keyboard;
}
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:21,代码来源:KeyboardUtils.java
示例3: createSelectDayOfWeekKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
/**
* Creates the select menu for selecting a day of week
* @return the keyboard
*/
public ReplyKeyboardMarkup createSelectDayOfWeekKeyboard(boolean withSaturday) {
ReplyKeyboardMarkup keyboard = new ReplyKeyboardMarkup();
KeyboardRow firstRow = new KeyboardRow();
firstRow.add(DayOfWeek.MONDAY.getDisplayName(TextStyle.FULL, BotConstants.DEFAULT_LOCALE));
firstRow.add(DayOfWeek.TUESDAY.getDisplayName(TextStyle.FULL, BotConstants.DEFAULT_LOCALE));
firstRow.add(DayOfWeek.WEDNESDAY.getDisplayName(TextStyle.FULL, BotConstants.DEFAULT_LOCALE));
KeyboardRow secondRow = new KeyboardRow();
secondRow.add(DayOfWeek.THURSDAY.getDisplayName(TextStyle.FULL, BotConstants.DEFAULT_LOCALE));
secondRow.add(DayOfWeek.FRIDAY.getDisplayName(TextStyle.FULL, BotConstants.DEFAULT_LOCALE));
if (withSaturday) {
secondRow.add(DayOfWeek.SATURDAY.getDisplayName(TextStyle.FULL, BotConstants.DEFAULT_LOCALE));
}
secondRow.add(messagesService.getMessage(Messages.COMMAND_BACK));
keyboard.setResizeKeyboard(true);
keyboard.setKeyboard(Arrays.asList(firstRow, secondRow));
return keyboard;
}
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:22,代码来源:KeyboardUtils.java
示例4: getKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private ReplyKeyboardMarkup getKeyboard(Post post) {
ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup();
List<KeyboardRow> keyboardRows = new ArrayList<KeyboardRow>();
// Row for all cases
KeyboardRow firstRow = new KeyboardRow();
firstRow.add("Random \uD83D\uDC4B");
keyboardRows.add(firstRow);
// Optional row
if (post != null) {
KeyboardRow secondRow = new KeyboardRow();
secondRow.add(StringUtils.capitalize(CommandType.NEXT.toString().toLowerCase()));
secondRow.add(StringUtils.capitalize(CommandType.INFO.toString().toLowerCase()));
secondRow.add(StringUtils.capitalize(CommandType.LINK.toString().toLowerCase()));
keyboardRows.add(secondRow);
}
keyboardMarkup.setKeyboard(keyboardRows);
return keyboardMarkup;
}
开发者ID:paramoshkinandrew,项目名称:ninegag-telegram-bot,代码行数:19,代码来源:ResponseBuilder.java
示例5: showMainMenu
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
public void showMainMenu(final Message request, final TGSession session) throws TelegramApiException {
final ReplyKeyboardMarkup replyKeyboardMarkup = getMainMenuKeyboard();
final SendMessage msg =
createMessageWithKeyboard(request.getChatId().toString(), request.getMessageId(), replyKeyboardMarkup);
if (session.isNew()) {
session.setNew(false);
msg.setText("Привет, либо ты тут в первый раз, "
+ "либо мы _берега попутали_.\n"
+ "Пиши -- от души.");
} else {
msg.setText("Пиши -- от души.");
}
sendMessage(msg);
}
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:17,代码来源:TGBot.java
示例6: getMainMenuKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private ReplyKeyboardMarkup getMainMenuKeyboard() {
final ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setSelective(true);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboad(false);
List<KeyboardRow> keyboard = new ArrayList<>();
// KeyboardRow row = null;
// for (int i = 0; i < mainControllers.size(); i++) {
// // группируем кнопки по две
// if (i % 2 == 0 || row == null) {
// row = new KeyboardRow();
// keyboard.add(row);
// }
// final Controller controller = mainControllers.get(i);
// final String entry = controller.getEntry();
// row.add(entry);
// }
KeyboardRow row = new KeyboardRow();
row.add(mainControllers.get(mainControllers.size() - 1).getEntry());
keyboard.add(row);
replyKeyboardMarkup.setKeyboard(keyboard);
return replyKeyboardMarkup;
}
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:26,代码来源:TGBot.java
示例7: sendHelpMessage
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private void sendHelpMessage(Long chatId, Integer messageId, ReplyKeyboardMarkup replyKeyboardMarkup) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(chatId);
sendMessage.setReplyToMessageId(messageId);
if (replyKeyboardMarkup != null) {
sendMessage.setReplyMarkup(replyKeyboardMarkup);
}
sendMessage.setText(HELP_TEXT);
try {
sendMessage(sendMessage);
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:17,代码来源:ChannelHandlers.java
示例8: onSetLanguageCommand
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private void onSetLanguageCommand(Message message, String language) throws InvalidObjectException {
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
List<LocalisationService.Language> languages = LocalisationService.getSupportedLanguages();
List<KeyboardRow> commands = new ArrayList<>();
for (LocalisationService.Language languageItem : languages) {
KeyboardRow commandRow = new KeyboardRow();
commandRow.add(languageItem.getCode() + " --> " + languageItem.getName());
commands.add(commandRow);
}
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(true);
replyKeyboardMarkup.setKeyboard(commands);
replyKeyboardMarkup.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardMarkup);
sendMessageRequest.setText(LocalisationService.getString("chooselanguage", language));
try {
sendMessage(sendMessageRequest);
languageMessages.add(message.getFrom().getId());
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:25,代码来源:DirectionsHandlers.java
示例9: onDeleteAlertCommand
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private static SendMessage onDeleteAlertCommand(Message message, String language) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(message.getChatId());
ReplyKeyboardMarkup replyKeyboardMarkup = getAlertsListKeyboard(message.getFrom().getId(), language);
if (replyKeyboardMarkup != null) {
sendMessage.setReplyMarkup(replyKeyboardMarkup);
sendMessage.setText(LocalisationService.getString("chooseNewAlertCity", language));
DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), ALERTDELETE);
} else {
sendMessage.setReplyMarkup(getAlertsKeyboard(language));
sendMessage.setText(LocalisationService.getString("noAlertList", language));
}
sendMessage.setReplyToMessageId(message.getMessageId());
return sendMessage;
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:20,代码来源:WeatherHandlers.java
示例10: onForecastChoosen
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private static SendMessage onForecastChoosen(Message message, String language) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
ReplyKeyboardMarkup replyKeyboardMarkup = getRecentsKeyboard(message.getFrom().getId(), language);
sendMessage.setReplyMarkup(replyKeyboardMarkup);
sendMessage.setReplyToMessageId(message.getMessageId());
sendMessage.setChatId(message.getChatId());
if (replyKeyboardMarkup.getKeyboard().size() > 3) {
sendMessage.setText(LocalisationService.getString("onForecastCommandFromHistory", language));
} else {
sendMessage.setText(LocalisationService.getString("onForecastCommandWithoutHistory", language));
}
DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), FORECASTWEATHER);
return sendMessage;
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:18,代码来源:WeatherHandlers.java
示例11: onCurrentChoosen
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private static SendMessage onCurrentChoosen(Message message, String language) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
ReplyKeyboardMarkup replyKeyboardMarkup = getRecentsKeyboard(message.getFrom().getId(), language);
sendMessage.setReplyMarkup(replyKeyboardMarkup);
sendMessage.setReplyToMessageId(message.getMessageId());
sendMessage.setChatId(message.getChatId());
if (replyKeyboardMarkup.getKeyboard().size() > 3) {
sendMessage.setText(LocalisationService.getString("onCurrentCommandFromHistory", language));
} else {
sendMessage.setText(LocalisationService.getString("onCurrentCommandWithoutHistory", language));
}
DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), CURRENTWEATHER);
return sendMessage;
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:18,代码来源:WeatherHandlers.java
示例12: getMainMenuKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private static ReplyKeyboardMarkup getMainMenuKeyboard(String language) {
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setSelective(true);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(false);
List<KeyboardRow> keyboard = new ArrayList<>();
KeyboardRow keyboardFirstRow = new KeyboardRow();
keyboardFirstRow.add(getCurrentCommand(language));
keyboardFirstRow.add(getForecastCommand(language));
KeyboardRow keyboardSecondRow = new KeyboardRow();
keyboardSecondRow.add(getSettingsCommand(language));
keyboardSecondRow.add(getRateCommand(language));
keyboard.add(keyboardFirstRow);
keyboard.add(keyboardSecondRow);
replyKeyboardMarkup.setKeyboard(keyboard);
return replyKeyboardMarkup;
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:20,代码来源:WeatherHandlers.java
示例13: getSettingsKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private static ReplyKeyboardMarkup getSettingsKeyboard(String language) {
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setSelective(true);
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(false);
List<KeyboardRow> keyboard = new ArrayList<>();
KeyboardRow keyboardFirstRow = new KeyboardRow();
keyboardFirstRow.add(getLanguagesCommand(language));
keyboardFirstRow.add(getUnitsCommand(language));
KeyboardRow keyboardSecondRow = new KeyboardRow();
keyboardSecondRow.add(getAlertsCommand(language));
keyboardSecondRow.add(getBackCommand(language));
keyboard.add(keyboardFirstRow);
keyboard.add(keyboardSecondRow);
replyKeyboardMarkup.setKeyboard(keyboard);
return replyKeyboardMarkup;
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:20,代码来源:WeatherHandlers.java
示例14: onDeleteCommandWithoutParameters
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private void onDeleteCommandWithoutParameters(Message message, String language) throws InvalidObjectException, TelegramApiException {
DatabaseManager.getInstance().addUserForFile(message.getFrom().getId(), DELETE_UPLOADED_STATUS);
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setText(LocalisationService.getString("deleteUploadedFile", language));
sendMessageRequest.setChatId(message.getChatId());
HashMap<String, String> files = DatabaseManager.getInstance().getFilesByUser(message.getFrom().getId());
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
if (files.size() > 0) {
List<KeyboardRow> commands = new ArrayList<>();
for (Map.Entry<String, String> entry : files.entrySet()) {
KeyboardRow commandRow = new KeyboardRow();
commandRow.add(Commands.deleteCommand + " " + entry.getKey() + " " + Emoji.LEFT_RIGHT_ARROW.toString()
+ " " + entry.getValue());
commands.add(commandRow);
}
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(true);
replyKeyboardMarkup.setKeyboard(commands);
}
sendMessageRequest.setReplyMarkup(replyKeyboardMarkup);
sendMessage(sendMessageRequest);
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:23,代码来源:FilesHandlers.java
示例15: onSetLanguageCommand
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private void onSetLanguageCommand(Message message, String language) throws InvalidObjectException, TelegramApiException {
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
List<LocalisationService.Language> languages = LocalisationService.getSupportedLanguages();
List<KeyboardRow> commands = new ArrayList<>();
for (LocalisationService.Language languageItem : languages) {
KeyboardRow commandRow = new KeyboardRow();
commandRow.add(languageItem.getCode() + " " + Emoji.LEFT_RIGHT_ARROW.toString() + " " + languageItem.getName());
commands.add(commandRow);
}
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(true);
replyKeyboardMarkup.setKeyboard(commands);
replyKeyboardMarkup.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardMarkup);
sendMessageRequest.setText(LocalisationService.getString("chooselanguage", language));
sendMessage(sendMessageRequest);
languageMessages.add(message.getFrom().getId());
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:21,代码来源:FilesHandlers.java
示例16: mainMenu
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
/**
* Shows the main menu.
*
* @param message
*/
private void mainMenu(String message) {
SendMessage sendMessagerequest = new SendMessage();
sendMessagerequest.setChatId(message);
sendMessagerequest.setText(i18n.msg("welcome_message"));
// main keyboard
KeyboardRow row = new KeyboardRow();
row.add(new KeyboardButton(i18n.msg("rooms")));
row.add(new KeyboardButton(i18n.msg("objects")));
KeyboardRow row2 = new KeyboardRow();
row2.add(new KeyboardButton(i18n.msg("plugins")));
//row2.add(new KeyboardButton(i18n.msg("languages")));
ReplyKeyboardMarkup markup = new ReplyKeyboardMarkup();
markup.setResizeKeyboard(true);
ArrayList<KeyboardRow> rows = new ArrayList<>();
rows.add(row);
rows.add(row2);
markup.setKeyboard(rows);
sendMessagerequest.setReplyMarkup(markup);
try {
sendMessage(sendMessagerequest);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:33,代码来源:FreedomoticBotHandlers.java
示例17: getKeyboardMarkup
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private static ReplyKeyboard getKeyboardMarkup() {
ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup();
keyboardMarkup.setResizeKeyboard(true);
keyboardMarkup.setOneTimeKeyboard(true);
keyboardMarkup.setSelective(true);
List<KeyboardRow> keyboard = new ArrayList<>();
KeyboardRow row = new KeyboardRow();
KeyboardButton button = new KeyboardButton();
button.setText("Button1");
button.setRequestContact(true);
row.add(button);
keyboard.add(row);
keyboardMarkup.setKeyboard(keyboard);
return keyboardMarkup;
}
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:16,代码来源:BotApiMethodHelperFactory.java
示例18: createMessageWithKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
/**
* Отправка сообщения с клавиатурой и текстом
* сообщение отправляется с прикреплённым запросом пользователя
*
* @param chatId
* @param messageId
* @param text
* @param replyKeyboardMarkup
* @return
*/
SendMessage createMessageWithKeyboard(final String chatId,
final Integer messageId,
final String text,
final ReplyKeyboardMarkup replyKeyboardMarkup) {
final SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(chatId);
sendMessage.setReplyToMessageId(messageId);
sendMessage.setText(text);
if (replyKeyboardMarkup != null) {
sendMessage.setReplyMarkup(replyKeyboardMarkup);
}
return sendMessage;
}
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:25,代码来源:Controller.java
示例19: onMain
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private void onMain(final Message request, final TGSession session) throws TelegramApiException {
final ReplyKeyboardMarkup replyKeyboardMarkup =
buildKeyboard(Collections.singletonList(BACK));
final SendMessage msg =
createMessageWithKeyboard(
request.getChatId().toString(),
request.getMessageId(),
"Сегодня мы с тобой рифмуем... \nНапиши что-нибудь, по-братски прошу.",
replyKeyboardMarkup);
getBot().sendMessage(msg);
}
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:14,代码来源:RhymingController.java
示例20: onMain
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup; //导入依赖的package包/类
private void onMain(final Message request, final TGSession session) throws TelegramApiException {
final ReplyKeyboardMarkup replyKeyboardMarkup = buildKeyboard(Arrays.asList(BACK));
final SendMessage msg =
createMessageWithKeyboard(
request.getChatId().toString(),
request.getMessageId(),
"Введи название песни",
replyKeyboardMarkup);
getBot().sendMessage(msg);
}
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:12,代码来源:SongSearchController.java
注:本文中的org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboardMarkup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论