@@ -27,13 +27,20 @@ class EchoBot[F[_]](bot: Api[F])(implicit syncF: Sync[F], timer: Timer[F]) exten
27
27
InlineKeyboardButton (" Yes" , callbackData = Some (" Yes" )),
28
28
InlineKeyboardButton (" No" , callbackData = Some (" No" ))
29
29
),
30
+ List (
31
+ InlineKeyboardButton (" Roll the dice" , callbackData = Some (" dice" )),
32
+ ),
30
33
)
31
34
)
32
35
)
33
36
)).void
34
37
}
35
38
36
39
override def onCallbackQuery (query : CallbackQuery ): F [Unit ] = {
40
+ def rollTheDice (chatId : Long ): F [Unit ] = {
41
+ bot.sendDice(SendDiceReq (ChatIntId (chatId))).void >>
42
+ bot.answerCallbackQuery(AnswerCallbackQueryReq (callbackQueryId = query.id)).void
43
+ }
37
44
def sendMsg (chatId : Long , text : String , parseMode : ParseMode ): F [Unit ] = {
38
45
bot.sendMessage(SendMessageReq (
39
46
chatId = ChatIntId (chatId),
@@ -45,6 +52,7 @@ class EchoBot[F[_]](bot: Api[F])(implicit syncF: Sync[F], timer: Timer[F]) exten
45
52
case " HTML" => query.message.fold(syncF.unit)(m => sendMsg(m.chat.id, htmlText, Html ))
46
53
case " Markdown" => query.message.fold(syncF.unit)(m => sendMsg(m.chat.id, markdownText, Markdown ))
47
54
case " Markdown2" => query.message.fold(syncF.unit)(m => sendMsg(m.chat.id, markdown2Text, Markdown2 ))
55
+ case " dice" => query.message.fold(syncF.unit)(m => rollTheDice(m.chat.id))
48
56
case x => bot.answerCallbackQuery(AnswerCallbackQueryReq (
49
57
callbackQueryId = query.id,
50
58
text = Some (s " Your choice is $x" )
0 commit comments