コード例 #1
0
        protected override void OnCallbackQuery(CallbackQuery query)
        {
            var cbargs = query?.Data.Split(' ');

            switch (cbargs[0])
            {
            case "month":
                var month     = new Month((MonthName)Enum.Parse(typeof(MonthName), cbargs[2]), uint.Parse(cbargs[1]));
                var mkeyboard = new InlineKeyboardMarkup
                {
                    InlineKeyboard = Calendar.New(month)
                };
                Api.EditMessageReplyMarkup <Message>(new EditMessageReplyMarkup
                {
                    ChatId      = query.Message.Chat.Id,
                    MessageId   = query.Message.MessageId,
                    ReplyMarkup = mkeyboard
                });
                break;

            case "year":
                var ykeyboard = new InlineKeyboardMarkup
                {
                    InlineKeyboard = Calendar.New(uint.Parse(cbargs[1]))
                };
                Api.EditMessageReplyMarkup <Message>(new EditMessageReplyMarkup
                {
                    ChatId      = query.Message.Chat.Id,
                    MessageId   = query.Message.MessageId,
                    ReplyMarkup = ykeyboard
                });
                break;

            default:
                Api.AnswerCallbackQuery(new AnswerCallbackQueryArgs
                {
                    CallbackQueryId = query.Id,
                    Text            = query.Data,
                    ShowAlert       = true
                });
                break;
            }
        }