当前位置: 首页>>代码示例>>Java>>正文


Java SendMessage.setReplyMarkup方法代码示例

本文整理汇总了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);
}
 
开发者ID:enoy19,项目名称:spring-tg,代码行数:20,代码来源:TgMessageServiceContextless.java

示例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);
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:17,代码来源:ChannelHandlers.java

示例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);
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:19,代码来源:TransifexHandlers.java

示例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);
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:18,代码来源:WeatherHandlers.java

示例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;
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:19,代码来源:WeatherHandlers.java

示例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);
    }
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:20,代码来源:WeatherHandlers.java

示例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());
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:21,代码来源:FilesHandlers.java

示例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());
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:18,代码来源:FilesHandlers.java

示例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();
    }
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:33,代码来源:FreedomoticBotHandlers.java

示例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);
}
 
开发者ID:enoy19,项目名称:spring-tg,代码行数:10,代码来源:TgMessageServiceContextless.java

示例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;
}
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:15,代码来源:MensaBot.java

示例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;
}
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:14,代码来源:DishesMessageCreator.java

示例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;
}
 
开发者ID:paramoshkinandrew,项目名称:ninegag-telegram-bot,代码行数:8,代码来源:ResponseBuilder.java

示例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;
}
 
开发者ID:paramoshkinandrew,项目名称:ninegag-telegram-bot,代码行数:8,代码来源:ResponseBuilder.java

示例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;
}
 
开发者ID:paramoshkinandrew,项目名称:ninegag-telegram-bot,代码行数:14,代码来源:ResponseBuilder.java


注:本文中的org.telegram.telegrambots.api.methods.send.SendMessage.setReplyMarkup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。