|
| 1 | +package io.github.natanimn; |
| 2 | + |
| 3 | +import io.github.natanimn.telebof.BotClient; |
| 4 | +import io.github.natanimn.telebof.BotContext; |
| 5 | +import io.github.natanimn.telebof.annotations.MessageHandler; |
| 6 | +import io.github.natanimn.telebof.enums.ButtonStyle; |
| 7 | +import io.github.natanimn.telebof.types.keyboard.InlineKeyboardButton; |
| 8 | +import io.github.natanimn.telebof.types.keyboard.InlineKeyboardMarkup; |
| 9 | +import io.github.natanimn.telebof.types.updates.Message; |
| 10 | +import org.junit.jupiter.api.Test; |
| 11 | +import org.junit.jupiter.api.BeforeEach; |
| 12 | + |
| 13 | +class ColoredKeyboardTest { |
| 14 | + private BotClient bot; |
| 15 | + |
| 16 | + @BeforeEach |
| 17 | + void setUp(){ |
| 18 | + this.bot = new BotClient(System.getenv("TOKEN")); |
| 19 | + bot.addHandler(this); |
| 20 | + } |
| 21 | + |
| 22 | + @Test |
| 23 | + void startBot() throws InterruptedException { |
| 24 | + bot.startPolling(); |
| 25 | +// Thread.currentThread().join(); |
| 26 | + } |
| 27 | + |
| 28 | + @MessageHandler(commands = "start") |
| 29 | + void start(BotContext ctx, Message message){ |
| 30 | + InlineKeyboardMarkup markup = new InlineKeyboardMarkup(); |
| 31 | + markup.setRowWidth(1); |
| 32 | + markup.addKeyboard( |
| 33 | + new InlineKeyboardButton("GREEN", "green").setStyle(ButtonStyle.SUCCESS), |
| 34 | + new InlineKeyboardButton("RED", "red").setStyle(ButtonStyle.DANGER), |
| 35 | + new InlineKeyboardButton("PRIMARY", "primary").setStyle(ButtonStyle.PRIMARY) |
| 36 | + ); |
| 37 | + |
| 38 | + ctx.sendMessage(message.getChat().getId(), "Here are colored buttons: ") |
| 39 | + .replyMarkup(markup) |
| 40 | + .exec(); |
| 41 | + } |
| 42 | + |
| 43 | + @MessageHandler(commands = "icons") |
| 44 | + void icons(BotContext ctx, Message message){ |
| 45 | + InlineKeyboardMarkup markup = new InlineKeyboardMarkup(); |
| 46 | + markup.setRowWidth(1); |
| 47 | + |
| 48 | + markup.addKeyboard( |
| 49 | + new InlineKeyboardButton("Verified", "verified").setIconCustomEmojiId("5426871635841941065"), |
| 50 | + new InlineKeyboardButton("Gift", "gift").setIconCustomEmojiId("5938540495792771769"), |
| 51 | + new InlineKeyboardButton("Java", "java").setIconCustomEmojiId("5373232592441065346") |
| 52 | + ); |
| 53 | + |
| 54 | + ctx.sendMessage(message.getChat().getId(), "Here are premium icon: ") |
| 55 | + .replyMarkup(markup) |
| 56 | + .exec(); |
| 57 | + } |
| 58 | +} |
0 commit comments