示例#1
0
        public static async Task <User> CheckUserRoleAsync(User user, Message message)
        {
            if (user.Role == Role.NotSet)
            {
                if (!message.Text.StartsWith(Emoji.Star))
                {
                    RequestUserRole(user, message.Chat.Id);
                }
                else if (message.Text.StartsWith(Emoji.Star))
                {
                    string msg = message.Text.Replace(Emoji.Star, "");

                    if (msg.Equals(Rm.GetString("Student")))
                    {
                        UService.ChangeRole(user.Id, Role.Student);
                        user = UService.View <Student>(user.Id);
                    }
                    else if (msg.Equals(Rm.GetString("Teacher")))
                    {
                        UService.ChangeRole(user.Id, Role.Teacher);
                        user = UService.View <Teacher>(user.Id);
                    }

                    await Bot.SendTextMessageAsync(message.Chat.Id, Rm.GetString("RoleSetMessage"),
                                                   replyMarkup : new ReplyKeyboardHide());
                }
            }
            return(user);
        }
        public async Task <User> CheckUserRoleAsync(User user, Message message)
        {
            if (user.Role == Role.NotSet)
            {
                if (!message.Text.StartsWith(Emoji.Star))
                {
                    RequestUserRole(user, message.Chat.Id);
                }
                else if (message.Text.StartsWith(Emoji.Star))
                {
                    string msg = message.Text.Replace(Emoji.Star, "");

                    if (msg.Equals(" Я учусь"))
                    {
                        NormalMessage($"User role changed:{user.Id}");
                        UService.ChangeRole(user.Id, Role.Student);
                        user = UService.View <Student>(user.Id);
                    }
                    else if (msg.Equals(" Я преподаю"))
                    {
                        NormalMessage($"User role changed:{user.Id}");
                        UService.ChangeRole(user.Id, Role.Teacher);
                        user = UService.View <Teacher>(user.Id);
                    }

                    await Bot.SendTextMessageAsync(message.Chat.Id, "Отлично, теперь я знаю кто ты!",
                                                   replyMarkup : new ReplyKeyboardHide());
                }
            }
            return(user);
        }