Skip to content

Commit 35d980a

Browse files
authored
Merge pull request #11 from JavaBy/fix/toInlineKeyboardMarkup
It could probably be replaced with a single function
2 parents 0e7c625 + def12b2 commit 35d980a

File tree

1 file changed

+1
-14
lines changed
  • votes/tgbotapi-extensions/src/main/kotlin/by/jprof/telegram/bot/votes/tgbotapi_extensions

1 file changed

+1
-14
lines changed

votes/tgbotapi-extensions/src/main/kotlin/by/jprof/telegram/bot/votes/tgbotapi_extensions/VotesExtensions.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,7 @@ import by.jprof.telegram.bot.votes.model.Votes
44
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
55
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
66

7-
fun Votes.toInlineKeyboardMarkup() = InlineKeyboardMarkup(
8-
listOf(
9-
this
10-
.options
11-
.map {
12-
CallbackDataInlineKeyboardButton(
13-
text = "${this.count(it)} $it",
14-
callbackData = "${this.id}:$it"
15-
)
16-
}
17-
)
18-
)
19-
20-
fun Votes.toInlineKeyboardMarkup(size: Int) = InlineKeyboardMarkup(
7+
fun Votes.toInlineKeyboardMarkup(size: Int = 8) = InlineKeyboardMarkup(
218
if (this.options.isEmpty()) {
229
listOf(emptyList())
2310
} else {

0 commit comments

Comments
 (0)