Пример #1
0
        private string GetChannelPostText(Comment comment)
        {
            var course = courseManager.GetCourse(comment.CourseId);
            var slide = course.FindSlideById(comment.SlideId);
            if (slide == null)
                return "";

            var slideTitle = $"{MakeNestedQuotes(course.Title)}: {MakeNestedQuotes(slide.Title)}";

            var url = "https://ulearn.me/Course/" + comment.CourseId + "/" + slide.Url + "#comment-" + comment.Id;
            var text = $"*{EscapeMarkdown(comment.Author.VisibleName)} â «{EscapeMarkdown(slideTitle)}»*\n{EscapeMarkdown(comment.Text.Trim())}\n\n{EscapeMarkdown(url)}";
            return text;
        }
Пример #2
0
        public async Task PostToChannel(Comment comment)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(token))
                    return;

                var api = new Telegram.Bot.TelegramBotClient(token);
                
                var text = GetChannelPostText(comment);
                await api.SendTextMessageAsync(channel, text, parseMode: ParseMode.Markdown, disableWebPagePreview: true);
            }
            catch (Exception e)
            {
                log.Error(e);
                ErrorLog.GetDefault(HttpContext.Current).Log(new Error(e));
            }
        }
Пример #3
0
		public int GetCommentLikesCount(Comment comment)
		{
			return db.CommentLikes.Count(x => x.CommentId == comment.Id);
		}
Пример #4
0
		public IEnumerable<ApplicationUser> GetCommentLikers(Comment comment)
		{
			return GetCommentLikes(comment).Select(x => x.User);
		}
Пример #5
0
		public IEnumerable<CommentLike> GetCommentLikes(Comment comment)
		{
			return db.CommentLikes.Where(x => x.CommentId == comment.Id);
		}
Пример #6
0
		private bool CanEditAndDeleteComment(IPrincipal user, Comment comment)
		{
			return user.HasAccessFor(comment.CourseId, CourseRole.Instructor) ||
					user.Identity.GetUserId() == comment.AuthorId;
		}