本文整理汇总了Java中org.telegram.telegrambots.api.methods.send.SendMessage.setReplyMarkup方法的典型用法代码示例。如果您正苦于以下问题:Java SendMessage.setReplyMarkup方法的具体用法?Java SendMessage.setReplyMarkup怎么用?Java SendMessage.setReplyMarkup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.telegrambots.api.methods.send.SendMessage
的用法示例。
在下文中一共展示了SendMessage.setReplyMarkup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendReplyKeyboard
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的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);
}
示例2: sendHelpMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的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);
}
}
示例3: sendMovedToMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private void sendMovedToMessage(Message message) throws InvalidObjectException, TelegramApiException {
String language = DatabaseManager.getInstance().getUserLanguage(message.getFrom().getId());
SendMessage answer = new SendMessage();
answer.setChatId(message.getChatId());
answer.setReplyToMessageId(message.getMessageId());
answer.setText(LocalisationService.getString("movedToLangBot", language));
InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rows = new ArrayList<>();
List<InlineKeyboardButton> row = new ArrayList<>();
InlineKeyboardButton button = new InlineKeyboardButton();
button.setText(LocalisationService.getString("checkLangBot", language));
button.setUrl("https://telegram.me/langbot");
row.add(button);
rows.add(row);
inlineKeyboardMarkup.setKeyboard(rows);
answer.setReplyMarkup(inlineKeyboardMarkup);
sendMessage(answer);
}
示例4: onCurrentWeatherCityReceived
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private static SendMessage onCurrentWeatherCityReceived(Long chatId, Integer userId, Integer messageId, String text, String language) {
Integer cityId = DatabaseManager.getInstance().getRecentWeatherIdByCity(userId, text);
if (cityId != null) {
String unitsSystem = DatabaseManager.getInstance().getUserWeatherOptions(userId)[1];
String weather = WeatherService.getInstance().fetchWeatherCurrent(cityId.toString(), userId, language, unitsSystem);
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.enableMarkdown(true);
sendMessageRequest.setReplyMarkup(getMainMenuKeyboard(language));
sendMessageRequest.setReplyToMessageId(messageId);
sendMessageRequest.setText(weather);
sendMessageRequest.setChatId(chatId.toString());
DatabaseManager.getInstance().insertWeatherState(userId, chatId, MAINMENU);
return sendMessageRequest;
} else {
return sendChooseOptionMessage(chatId, messageId, getRecentsKeyboard(userId, language), language);
}
}
示例5: onAlertNewOptionSelected
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private static SendMessage onAlertNewOptionSelected(Message message, String language) {
SendMessage sendMessageRequest = null;
if (message.hasText()) {
if (message.getText().equals(getCancelCommand(language))) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(message.getChatId());
sendMessage.setReplyToMessageId(message.getMessageId());
sendMessage.setReplyMarkup(getAlertsKeyboard(language));
sendMessage.setText(LocalisationService.getString("alertsMenuMessage", language));
DatabaseManager.getInstance().insertWeatherState(message.getFrom().getId(), message.getChatId(), ALERT);
sendMessageRequest = sendMessage;
} else {
sendMessageRequest = onNewAlertCityReceived(message, language);
}
}
return sendMessageRequest;
}
示例6: onNewAlertCityReceived
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private static SendMessage onNewAlertCityReceived(Message message, String language) {
int userId = message.getFrom().getId();
Integer cityId = DatabaseManager.getInstance().getRecentWeatherIdByCity(userId, message.getText());
if (cityId != null) {
DatabaseManager.getInstance().createNewWeatherAlert(userId, cityId, message.getText());
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.enableMarkdown(true);
sendMessageRequest.setReplyMarkup(getAlertsKeyboard(language));
sendMessageRequest.setReplyToMessageId(message.getMessageId());
sendMessageRequest.setText(getChooseNewAlertSetMessage(message.getText(), language));
sendMessageRequest.setChatId(message.getChatId());
DatabaseManager.getInstance().insertWeatherState(userId, message.getChatId(), ALERT);
return sendMessageRequest;
} else {
return sendChooseOptionMessage(message.getChatId(), message.getMessageId(),
getRecentsKeyboard(message.getFrom().getId(), language, false), language);
}
}
示例7: onSetLanguageCommand
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的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());
}
示例8: onLanguageReceived
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private void onLanguageReceived(Message message) throws InvalidObjectException, TelegramApiException {
String[] parts = message.getText().split(Emoji.LEFT_RIGHT_ARROW.toString(), 2);
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
if (LocalisationService.getLanguageByCode(parts[0].trim()) != null) {
DatabaseManager.getInstance().putUserLanguage(message.getFrom().getId(), parts[0].trim());
sendMessageRequest.setText(LocalisationService.getString("languageModified", parts[0].trim()));
} else {
sendMessageRequest.setText(LocalisationService.getString("errorLanguage"));
}
sendMessageRequest.setReplyToMessageId(message.getMessageId());
ReplyKeyboardRemove replyKeyboardRemove = new ReplyKeyboardRemove();
replyKeyboardRemove.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardRemove);
sendMessage(sendMessageRequest);
languageMessages.remove(message.getFrom().getId());
}
示例9: mainMenu
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的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();
}
}
示例10: removeKeyboard
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
public void removeKeyboard(long chatId) {
ReplyKeyboardRemove removeMarkup = new ReplyKeyboardRemove();
SendMessage sendMessage = new SendMessage(chatId, "This message was sent to remove the keyboard.");
sendMessage.setReplyMarkup(removeMarkup);
Message message = execute(sendMessage);
DeleteMessage deleteMessage = new DeleteMessage(chatId, message.getMessageId());
execute(deleteMessage);
}
示例11: createSelectMensaMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private SendMessage createSelectMensaMessage() {
SendMessage result = new SendMessage();
result.setText(messagesService.getMessage(Messages.RESPONSE_SELECT_MENSA));
InlineKeyboardMarkup markup = new InlineKeyboardMarkup();
markup.setKeyboard(mensaRepo.findAllByOrderByName().stream()
.map(mensa -> {
InlineKeyboardButton button = new InlineKeyboardButton();
button.setText(mensa.getName());
button.setCallbackData(mensa.getId());
return Arrays.asList(button);
}).collect(Collectors.toList()));
result.setReplyMarkup(markup);
return result;
}
示例12: createMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
/**
* Create a new message displaying dishes for a day
* @param mensaId of the mensa to create the message for
* @param dateSearchResult result of the date search
* @return the message to send to the user
*/
public SendMessage createMessage(String mensaId, DateSearchResult dateSearchResult) {
SendMessage message = new SendMessage();
List<DishBotDTO> dishes = getDishBotDTOs(mensaId, dateSearchResult.getDateToUse());
message.setText(formatText(mensaId, dateSearchResult, dishes));
message.setReplyMarkup(keyboardUtils.createFilterKeyboard(mensaId, dateSearchResult.getDateToUse(), BotConstants.FILTER_ALL_VALUE));
return message;
}
示例13: buildLinkMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private SendMessage buildLinkMessage(Long chatId, Post lastPost) {
SendMessage message = new SendMessage();
message.setChatId(chatId);
message.setText(lastPost.getLink());
message.setReplyMarkup(getKeyboard(lastPost));
return message;
}
示例14: buildInfoMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
private SendMessage buildInfoMessage(Long chatId, Post lastPost) {
SendMessage message = new SendMessage();
message.setChatId(chatId);
message.setText("Post info:\nID: " + lastPost.getId() + "\nComments: " + lastPost.getComments() + "\nVotes: " + lastPost.getVotes());
message.setReplyMarkup(getKeyboard(lastPost));
return message;
}
示例15: buildFallbackMessage
import org.telegram.telegrambots.api.methods.send.SendMessage; //导入方法依赖的package包/类
/**
* Build fallback response message
*
* @param chatId - chat id for response
* @return - completed response message
*/
private SendMessage buildFallbackMessage(Long chatId) {
SendMessage message = new SendMessage();
message.setChatId(chatId);
message.setText("Fallback message");
message.setReplyMarkup(getKeyboard());
return message;
}