예제 #1
0
        public override async void Callback(BotContext context, CallbackQueryEventArgs args)
        {
            var message      = args.CallbackQuery.Message;
            var callbcakData = JsonConvert.DeserializeObject <InlineKeyboardCallback>(args.CallbackQuery.Data);

            var bill = storageManager.GetBillWIthMessageId(message.MessageId);

            if (bill?.CreatedBy != args.CallbackQuery.From.Id)
            {
                return;
            }

            Button button;
            var    input = (string)callbcakData.Data;

            if (Enum.IsDefined(typeof(Button), input))
            {
                Enum.TryParse(input, false, out button);
                UpdateBill(bill, button, context);
            }
            else
            {
                switch (bill.CurrentStatus)
                {
                case Bill.Status.SetAmountIntegeral:
                case Bill.Status.SetAmountFractional:
                    HandleDigitInput(bill, input);
                    break;

                case Bill.Status.SetSharedWith:
                    HandleUserSelection(bill, input);
                    break;

                case Bill.Status.Sealed:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            await GenerateResponse(bill, context.BotClient, true);
        }