public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.LicenseDuration);
            ShopUserRepository.UpdateUserBuyLicenseKey(userModel, this.licenseKey);

            await telegramShop.SendMessage(e.Message.Chat.Id, AnswerMessage.LicenseDurationMenu, GetKeyboard(userModel.CurrentDialogState));
        }
Exemple #2
0
        public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.PaymentMethod);
            ShopUserRepository.UpdateUserLicenseDuration(userModel, this.daysCount, this.price);

            await telegramShop.SendMessage(e.Message.Chat.Id, this.GetPaymentMethodMessage(userModel), GetKeyboard(userModel.CurrentDialogState));
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            var qiwiPaymentHistoryHandler = new QiwiPaymentHistoryHandler(Settings.QiwiApi, Settings.QiwiNumber);
            var telegramShopClient        = new TelegramShopClient(Settings.TelegramBotApi, qiwiPaymentHistoryHandler);

            telegramShopClient.StartMessageReceive();

            Thread.Sleep(Timeout.Infinite);
        }
Exemple #4
0
        public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.LicenseRenewSubscription);
            var keyboard = GetKeyboard(userModel.CurrentDialogState);

            await telegramShop.SendMessage(e.Message.Chat.Id, GetAllUsersLicenseMessage(userModel), keyboard);

            await telegramShop.SendMessage(e.Message.Chat.Id, AnswerMessage.SendMeLicenseKeyToStartRenew, keyboard);
        }
Exemple #5
0
        public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, this.dialogState);

            await telegramShop.SendMessage(e.Message.Chat.Id, this.message, GetKeyboard(userModel.CurrentDialogState));
        }
 public virtual Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
 {
     return(Task.FromResult(default(object)));
 }
Exemple #7
0
        public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.QiwiPaymentVerification);

            await telegramShop.SendMessage(e.Message.Chat.Id, GetQiwiPaymentMessage(userModel), GetKeyboard(userModel.CurrentDialogState));
        }
Exemple #8
0
 public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel user)
 {
     await telegramShop.SendMessage(e.Message.Chat.Id, this.text, GetKeyboard(user.CurrentDialogState));
 }
Exemple #9
0
        public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.QiwiPaymentVerification);

            if (cachedPayments != null && IsCachedOld() == false)
            {
                await telegramShop.SendMessage(
                    e.Message.Chat.Id,
                    GetQiwiTimeToNewRequestLeftMessage(),
                    GetKeyboard(userModel.CurrentDialogState));

                return;
            }

            var payments = telegramShop.Qiwi.GetIncomingTransactions().Result;

            lastRequestDate = DateTime.Now;
            cachedPayments  = payments;

            var isPaymentPresent = IsPaymentPresent(
                userModel.LicenseBuyProcess.Comment,
                userModel.LicenseBuyProcess.Price,
                payments);

            if (isPaymentPresent)
            {
                await telegramShop.BoldLog($"@{userModel.Telegram} bought license for {userModel.LicenseBuyProcess.Days} days for {userModel.LicenseBuyProcess.Price} RUB");

                ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.Main);

                if (userModel.LicenseBuyProcess.LicenseKey == null)
                {
                    var newLicenseKey = GetNewLicenseKey(userModel.Telegram);
                    LicenseServerHandler.GetNewLicense(userModel.LicenseBuyProcess.Days);

                    ShopUserRepository.AddLicenseKey(userModel, newLicenseKey);

                    await telegramShop.SendMessage(
                        e.Message.Chat.Id,
                        GetQiwiNewLicenseKeyAddedMessage(newLicenseKey, userModel.LicenseBuyProcess.Days),
                        GetKeyboard(userModel.CurrentDialogState));
                }
                else
                {
                    LicenseServerHandler.AddDaysForExistLicense(
                        userModel.LicenseBuyProcess.LicenseKey,
                        userModel.LicenseBuyProcess.Days);

                    await telegramShop.SendMessage(
                        e.Message.Chat.Id,
                        GetQiwiLicenseKeyDaysAddedMessage(
                            userModel.LicenseBuyProcess.LicenseKey,
                            userModel.LicenseBuyProcess.Days),
                        GetKeyboard(userModel.CurrentDialogState));
                }

                ShopUserRepository.UpdatePurchaseUniqueComment(userModel, null);
                ShopUserRepository.UpdateUserBuyLicenseKey(userModel, null);
                ShopUserRepository.UpdateUserLicenseDuration(userModel, 0, 0);
            }
            else
            {
                await telegramShop.SendMessage(
                    e.Message.Chat.Id,
                    GetQiwiTimeToNewRequestLeftMessage(),
                    GetKeyboard(userModel.CurrentDialogState));
            }
        }
        public override async Task Process(TelegramShopClient telegramShop, MessageEventArgs e, ShopUserModel userModel)
        {
            ShopUserRepository.UpdateUserDialogState(userModel, EDialogState.ManageLicense);

            await telegramShop.SendMessage(e.Message.Chat.Id, AnswerMessage.LicenseManageMenuTitle, GetKeyboard(userModel.CurrentDialogState));
        }