예제 #1
0
        public async Task SetManager(CoffeeService coffee, User user, string text, SlackResponse response)
        {
            string[] splitted = text.Split(' ').Select(s => s.Trim()).ToArray();
            if (splitted.Length != 2 || !int.TryParse(splitted[1], out var isManagerInt))
            {
                throw new NotWellFormedException();
            }

            var userId = SlackBot.Utils.StringToUserId(splitted[0]);

            if (userId == null)
            {
                throw new NotWellFormedException();
            }

            var isManager   = isManagerInt > 0;
            var changedUser = await coffee.UpdateUserAsync(userId, isManager);

            var subText = isManager ? "운영자로 지정 하였습니다." : "일반 사용자로 지정 하였습니다.";

            response.InChannel($"{user.Name} 님이 {SlackBot.Utils.StringToUserId(changedUser.Id)} 님을 {subText}");
        }