• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java KeyboardButton类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton的典型用法代码示例。如果您正苦于以下问题:Java KeyboardButton类的具体用法?Java KeyboardButton怎么用?Java KeyboardButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KeyboardButton类属于org.telegram.telegrambots.api.objects.replykeyboard.buttons包,在下文中一共展示了KeyboardButton类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createMainSelectKeyboard

import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton; //导入依赖的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


示例2: toJson

import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton; //导入依赖的package包/类
@Override
public JSONObject toJson() {
    JSONObject jsonObject = new JSONObject();
    JSONArray jsonkeyboard = new JSONArray();

    for (KeyboardRow innerRow : this.keyboard) {
        JSONArray innerJSONKeyboard = new JSONArray();
        for (KeyboardButton button : innerRow) {
            innerJSONKeyboard.put(button.toJson());
        }
        jsonkeyboard.put(innerJSONKeyboard);
    }
    jsonObject.put(ReplyKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);

    if (this.oneTimeKeyboad != null) {
        jsonObject.put(ReplyKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad);
    }
    if (this.resizeKeyboard != null) {
        jsonObject.put(ReplyKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard);
    }
    if (this.selective != null) {
        jsonObject.put(ReplyKeyboardMarkup.SELECTIVE_FIELD, this.selective);
    }

    return jsonObject;
}
 
开发者ID:gomgomdev,项目名称:telegram-bot_misebot,代码行数:27,代码来源:ReplyKeyboardMarkup.java


示例3: serialize

import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton; //导入依赖的package包/类
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
    gen.writeStartObject();
    gen.writeArrayFieldStart(KEYBOARD_FIELD);
    for (KeyboardRow innerRow : keyboard) {
        gen.writeStartArray();
        for (KeyboardButton button : innerRow) {
            gen.writeObject(button);
        }
        gen.writeEndArray();
    }
    gen.writeEndArray();
    if (this.oneTimeKeyboad != null) {
        gen.writeBooleanField(ONETIMEKEYBOARD_FIELD, oneTimeKeyboad);
    }
    if (this.resizeKeyboard != null) {
        gen.writeBooleanField(RESIZEKEYBOARD_FIELD, resizeKeyboard);
    }
    if (this.selective != null) {
        gen.writeBooleanField(SELECTIVE_FIELD, selective);
    }
    gen.writeEndObject();
    gen.flush();
}
 
开发者ID:gomgomdev,项目名称:telegram-bot_misebot,代码行数:25,代码来源:ReplyKeyboardMarkup.java


示例4: mainMenu

import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton; //导入依赖的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


示例5: getKeyboardMarkup

import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnimationPackParseException类代码示例发布时间:2022-05-22
下一篇:
Java NumberConverters类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap