本文整理汇总了Java中org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton类的典型用法代码示例。如果您正苦于以下问题:Java InlineKeyboardButton类的具体用法?Java InlineKeyboardButton怎么用?Java InlineKeyboardButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InlineKeyboardButton类属于org.telegram.telegrambots.api.objects.replykeyboard.buttons包,在下文中一共展示了InlineKeyboardButton类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ligar
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
public InlineKeyboardMarkup ligar() {
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<List<InlineKeyboardButton>>();
List<InlineKeyboardButton> row1 = new ArrayList<InlineKeyboardButton>();
for (int i = 0; i < 9; i++) {
if (!State.d[i]) {
row1.add(new InlineKeyboardButton().setText("liga led " + (i + 1)).setCallbackData(i + "on"));
} else {
row1.add(new InlineKeyboardButton().setText("desliga led " + (i + 1)).setCallbackData(i + "off"));
}
if (i % 2 == 0 || i == 0) {
rowsInline.add(row1);
row1 = new ArrayList<InlineKeyboardButton>();
}
}
rowsInline.add(acionaTodos());
rowsInline.add(desacionaTodos());
markupInline.setKeyboard(rowsInline);
return markupInline;
}
开发者ID:alexNeto,项目名称:smart-home-bot,代码行数:21,代码来源:Start.java
示例2: createFilterKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
* Creates the keyboard for filtering of the dishes message
* @param mensaId id of the mensa of the dishes
* @param date of the dishes
* @param selectedValue currently selected filter
* @return the inline keyboard of the filters
*/
public InlineKeyboardMarkup createFilterKeyboard(String mensaId, LocalDate date, String selectedValue) {
List<List<InlineKeyboardButton>> rows = new ArrayList<>();
List<InlineKeyboardButton> currentRow = new ArrayList<>();
for (FilterConfig filter : config.getFilters()) {
InlineKeyboardButton button = new InlineKeyboardButton();
if (StringUtils.equals(selectedValue, filter.getValue())) {
button.setText(messagesService.getMessage(Messages.FILTER_ALL));
button.setCallbackData(FilterInfo.of(BotConstants.FILTER_ALL_VALUE, mensaId, date).toString());
} else {
button.setText(messagesService.getMessage(filter.getMessageKey()));
button.setCallbackData(FilterInfo.of(filter.getValue(), mensaId, date).toString());
}
currentRow.add(button);
if (currentRow.size() % 2 == 0) {
rows.add(currentRow);
currentRow = new ArrayList<>();
}
}
if (!currentRow.isEmpty()) {
rows.add(currentRow);
}
InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup();
inlineKeyboardMarkup.setKeyboard(rows);
return inlineKeyboardMarkup;
}
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:33,代码来源:KeyboardUtils.java
示例3: toJson
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
JSONArray jsonkeyboard = new JSONArray();
for (List<InlineKeyboardButton> innerRow : this.keyboard) {
JSONArray innerJSONKeyboard = new JSONArray();
for (InlineKeyboardButton element : innerRow) {
innerJSONKeyboard.put(element.toJson());
}
jsonkeyboard.put(innerJSONKeyboard);
}
jsonObject.put(InlineKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
return jsonObject;
}
开发者ID:gomgomdev,项目名称:telegram-bot_misebot,代码行数:17,代码来源:InlineKeyboardMarkup.java
示例4: sendMovedToMessage
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的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
示例5: validate
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
@Override
public void validate() throws TelegramApiValidationException {
if (keyboard == null) {
throw new TelegramApiValidationException("Keyboard parameter can't be null", this);
}
for (List<InlineKeyboardButton> inlineKeyboardButtons : keyboard) {
for (InlineKeyboardButton inlineKeyboardButton : inlineKeyboardButtons) {
inlineKeyboardButton.validate();
}
}
}
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:12,代码来源:InlineKeyboardMarkup.java
示例6: getInlineKeyboardMarkup
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
private static InlineKeyboardMarkup getInlineKeyboardMarkup() {
InlineKeyboardButton button = new InlineKeyboardButton()
.setText("Button1")
.setCallbackData("Callback");
List<InlineKeyboardButton> row = new ArrayList<>();
row.add(button);
List<List<InlineKeyboardButton>> keyboard = new ArrayList<>();
keyboard.add(row);
return new InlineKeyboardMarkup()
.setKeyboard(keyboard);
}
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:12,代码来源:BotApiMethodHelperFactory.java
示例7: createSelectMensaMessage
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的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
示例8: serialize
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeArrayFieldStart(KEYBOARD_FIELD);
for (List<InlineKeyboardButton> innerRow : keyboard) {
gen.writeStartArray();
for (InlineKeyboardButton element : innerRow) {
gen.writeObject(element);
}
gen.writeEndArray();
}
gen.writeEndArray();
gen.writeEndObject();
gen.flush();
}
开发者ID:gomgomdev,项目名称:telegram-bot_misebot,代码行数:16,代码来源:InlineKeyboardMarkup.java
示例9: getRoomView
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
*
* @param index
* @param action
* @return
*/
public InlineKeyboardMarkup getRoomView(int index, int action) {
List<Zone> roomsList = this.getRoomsList();
/*
* action = 1 -> back
* action = 2 -> next
* action = -1 -> nothing
*/
if (action == 1 && index > 0) {
index--;
} else if ((action == 1 && index == 0)) {
return null;
} else if (action == 2 && index >= roomsList.size() - 1) {
return null;
} else if (action == 2) {
index++;
}
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
Zone room = roomsList.get(index);
rowInline.add(new InlineKeyboardButton().setText(room.getName()).setCallbackData("rooms:text:" + index + ":" + room.getUuid()));
List<InlineKeyboardButton> rowInline2 = new ArrayList<>();
rowInline2.add(new InlineKeyboardButton().setText(BACK + i18n.msg("back")).setCallbackData("rooms:back:" + index + ":" + room.getUuid()));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("objects")).setCallbackData("rooms:things-list:" + index + ":" + room.getUuid()));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("next") + NEXT).setCallbackData("rooms:next:" + index + ":" + room.getUuid()));
rowsInline.add(rowInline);
rowsInline.add(rowInline2);
markupInline.setKeyboard(rowsInline);
return markupInline;
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:46,代码来源:FreedomoticBotHandlers.java
示例10: getKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
public List<List<InlineKeyboardButton>> getKeyboard() {
return keyboard;
}
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:4,代码来源:InlineKeyboardMarkup.java
示例11: setKeyboard
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
public InlineKeyboardMarkup setKeyboard(List<List<InlineKeyboardButton>> keyboard) {
this.keyboard = keyboard;
return this;
}
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:5,代码来源:InlineKeyboardMarkup.java
示例12: getGalleryView
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
*
* @param index Index of the current image
* @param action What button was clicked
* @return
*/
private InlineKeyboardMarkup getGalleryView(int index, int action){
/*
* action = 1 -> back
* action = 2 -> next
* action = -1 -> nothing
*/
if(action == 1 && index > 0){
index--;
}
else if((action == 1 && index == 0)){
return null;
}
else if(action == 2 && index >= this.urls.size()-1){
return null;
}
else if(action == 2){
index++;
}
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
rowInline.add(new InlineKeyboardButton().setText(this.urls.get(index)[2]).setCallbackData("gallery:text:" + index));
List<InlineKeyboardButton> rowInline2 = new ArrayList<>();
rowInline2.add(new InlineKeyboardButton().setText(BACK).setCallbackData("gallery:back:" + index));
rowInline2.add(new InlineKeyboardButton().setText(NEXT).setCallbackData("gallery:next:" + index));
List<InlineKeyboardButton> rowInline3 = new ArrayList<>();
rowInline3.add(new InlineKeyboardButton().setText("Link").setUrl(this.urls.get(index)[0]));
rowsInline.add(rowInline);
rowsInline.add(rowInline3);
rowsInline.add(rowInline2);
markupInline.setKeyboard(rowsInline);
return markupInline;
}
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:51,代码来源:ElektrollArtFanHandler.java
示例13: getPluginView
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
*
* @param index
* @param action
* @return
*/
public InlineKeyboardMarkup getPluginView(int index, int action) {
List<Plugin> pluginsList = this.getPluginsList();
/*
* action = 1 -> back
* action = 2 -> next
* action = -1 -> nothing
*/
if (action == 1 && index > 0) {
index--;
} else if ((action == 1 && index == 0)) {
return null;
} else if (action == 2 && index >= pluginsList.size() - 1) {
return null;
} else if (action == 2) {
index++;
}
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
Plugin plugin = pluginsList.get(index);
rowInline.add(new InlineKeyboardButton().setText(plugin.getName() + "\n" + plugin.getStatus()).setCallbackData("plugins:text:" + index + ":" + plugin.getClassName()));
List<InlineKeyboardButton> rowInline2 = new ArrayList<>();
rowInline2.add(new InlineKeyboardButton().setText(BACK + i18n.msg("back")).setCallbackData("plugins:back:" + index + ":" + plugin.getClassName()));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("next") + NEXT).setCallbackData("plugins:next:" + index + ":" + plugin.getClassName()));
List<InlineKeyboardButton> rowInline3 = new ArrayList<>();
if (!plugin.isRunning()) {
rowInline3.add(new InlineKeyboardButton().setText(START + i18n.msg("start")).setCallbackData("plugins:start:" + index + ":" + plugin.getClassName()));
} else {
rowInline3.add(new InlineKeyboardButton().setText(STOP + i18n.msg("stop")).setCallbackData("plugins:stop:" + index + ":" + plugin.getClassName()));
}
rowsInline.add(rowInline);
rowsInline.add(rowInline3);
rowsInline.add(rowInline2);
markupInline.setKeyboard(rowsInline);
return markupInline;
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:53,代码来源:FreedomoticBotHandlers.java
示例14: getThingView
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
*
* @param index
* @param action
* @return
*/
public InlineKeyboardMarkup getThingView(int index, int action) {
List<EnvObject> thingsList;
thingsList = getThingsList();
/*
* action = 1 -> back
* action = 2 -> next
* action = -1 -> nothing
*/
if (action == 1 && index > 0) {
index--;
} else if ((action == 1 && index == 0)) {
return null;
} else if (action == 2 && index >= thingsList.size() - 1) {
return null;
} else if (action == 2) {
index++;
}
EnvObject thing = thingsList.get(index);
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
rowInline.add(new InlineKeyboardButton().setText(thing.getName() + "\n" + getMainThingStatus(thing.getUUID())).setCallbackData("things:text:" + index + ":" + thing.getUUID()));
List<InlineKeyboardButton> rowInline2 = new ArrayList<>();
rowInline2.add(new InlineKeyboardButton().setText(BACK + i18n.msg("back")).setCallbackData("things:back:" + index + ":" + thing.getUUID()));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("next") + NEXT).setCallbackData("things:next:" + index + ":" + thing.getUUID()));
List<InlineKeyboardButton> rowInline3 = new ArrayList<>();
rowInline3.add(new InlineKeyboardButton().setText(i18n.msg("status")).setCallbackData("things:status:" + index + ":" + thing.getUUID()));
rowInline3.add(new InlineKeyboardButton().setText(i18n.msg("click")).setCallbackData("things:click:" + index + ":" + thing.getUUID()));
rowsInline.add(rowInline);
rowsInline.add(rowInline3);
rowsInline.add(rowInline2);
markupInline.setKeyboard(rowsInline);
return markupInline;
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:51,代码来源:FreedomoticBotHandlers.java
示例15: getLanguageView
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
*
* @param index
* @param action
* @return
*/
public InlineKeyboardMarkup getLanguageView(int index, int action) {
List<Locale> languagesList;
languagesList = api.getI18n().getAvailableLocales();
/*
* action = 1 -> back
* action = 2 -> next
* action = -1 -> nothing
*/
if (action == 1 && index > 0) {
index--;
} else if ((action == 1 && index == 0)) {
return null;
} else if (action == 2 && index >= languagesList.size() - 1) {
return null;
} else if (action == 2) {
index++;
}
Locale locale = languagesList.get(index);
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
rowInline.add(new InlineKeyboardButton().setText(locale.getDisplayCountry(i18n.getDefaultLocale()) + " - " + locale.getDisplayLanguage(locale)).setCallbackData("languages:text:" + index + ":" + locale.toString()));
List<InlineKeyboardButton> rowInline2 = new ArrayList<>();
rowInline2.add(new InlineKeyboardButton().setText(BACK + i18n.msg("back")).setCallbackData("languages:back:" + index + ":" + locale.getDisplayLanguage(locale)));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("set")).setCallbackData("languages:set:" + index + ":" + locale.getDisplayLanguage(locale)));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("next") + NEXT).setCallbackData("languages:next:" + index + ":" + locale.getDisplayLanguage(locale)));
rowsInline.add(rowInline);
rowsInline.add(rowInline2);
markupInline.setKeyboard(rowsInline);
return markupInline;
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:47,代码来源:FreedomoticBotHandlers.java
示例16: getRoomThingView
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
/**
*
* @param index
* @param action
* @return
*/
public InlineKeyboardMarkup getRoomThingView(int index, int action, String roomUuid) {
List<EnvObject> thingsList;
thingsList = getThingsListInRoom(roomUuid);
if (!thingsList.isEmpty()) {
/*
* action = 1 -> back
* action = 2 -> next
* action = -1 -> nothing
*/
if (action == 1 && index > 0) {
index--;
} else if ((action == 1 && index == 0)) {
return null;
} else if (action == 2 && index >= thingsList.size() - 1) {
return null;
} else if (action == 2) {
index++;
}
EnvObject thing = thingsList.get(index);
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
rowInline.add(new InlineKeyboardButton().setText(thing.getName()).setCallbackData("rooms-things:text:" + index + ":" + roomUuid));
List<InlineKeyboardButton> rowInline2 = new ArrayList<>();
rowInline2.add(new InlineKeyboardButton().setText(BACK + i18n.msg("back")).setCallbackData("rooms-things:back:" + index + ":" + roomUuid));
rowInline2.add(new InlineKeyboardButton().setText(i18n.msg("next") + NEXT).setCallbackData("rooms-things:next:" + index + ":" + roomUuid));
List<InlineKeyboardButton> rowInline3 = new ArrayList<>();
rowInline3.add(new InlineKeyboardButton().setText(i18n.msg("status")).setCallbackData("things:status:" + index + ":" + thing.getUUID()));
rowInline3.add(new InlineKeyboardButton().setText(i18n.msg("click")).setCallbackData("rooms-things:click:" + index + ":" + thing.getUUID()));
rowsInline.add(rowInline);
rowsInline.add(rowInline3);
rowsInline.add(rowInline2);
markupInline.setKeyboard(rowsInline);
return markupInline;
} else {
return null;
}
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:57,代码来源:FreedomoticBotHandlers.java
示例17: acionaTodos
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
public List<InlineKeyboardButton> acionaTodos() {
List<InlineKeyboardButton> row1 = new ArrayList<InlineKeyboardButton>();
row1.add(new InlineKeyboardButton().setText("liga todos").setCallbackData("todos"));
return row1;
}
开发者ID:alexNeto,项目名称:smart-home-bot,代码行数:9,代码来源:Start.java
示例18: desacionaTodos
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton; //导入依赖的package包/类
public List<InlineKeyboardButton> desacionaTodos() {
List<InlineKeyboardButton> row1 = new ArrayList<InlineKeyboardButton>();
row1.add(new InlineKeyboardButton().setText("desliga todos").setCallbackData("desligaTodos"));
return row1;
}
开发者ID:alexNeto,项目名称:smart-home-bot,代码行数:9,代码来源:Start.java
注:本文中的org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论