예제 #1
0
        public async Task FillWallet(CoffeeService coffee, User user, string text, SlackResponse response)
        {
            if (!int.TryParse(text, out var amount))
            {
                throw new NotWellFormedException();
            }

            var u = await coffee.FillWalletAsync(user.Id, amount, DateTime.Now);

            response.Ephemeral($"현재 잔액은 {u.Deposit}원 입니다.");
        }
예제 #2
0
        // [CoffeeCommand("대리적립", "", true)]
        public async Task FillOtherWallet(CoffeeService coffee, User requestUser, string text, SlackResponse response)
        {
            var splitted = text.Split(' ');

            if (splitted.Length != 2 || !int.TryParse(splitted[1], out var amount))
            {
                throw new NotWellFormedException();
            }

            var userId = SlackBot.Utils.StringToUserId(splitted[0]);
            var user   = await coffee.FindUserAsync(userId);

            if (user == null)
            {
                user = await coffee.CreateUserAsync(userId, null, false);

                await coffee.SaveAsync();
            }

            var u = await coffee.FillWalletAsync(userId, amount, DateTime.Now);

            response.Ephemeral($"현재 잔액은 {u.Deposit}원 입니다.");
        }