Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Skip comments with null commenter
Browse files Browse the repository at this point in the history
  • Loading branch information
lay295 committed Jan 15, 2021
1 parent bc438a6 commit 7606250
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions TwitchDownloaderCore/ChatRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ await Task.Run(() =>
{
if (comment.source != "chat")
continue;
if (comment.message.fragments == null)
if (comment.message.fragments == null || comment.commenter == null)
continue;
if (comment.message.user_notice_params != null && comment.message.user_notice_params.msg_id != null)
{
Expand Down Expand Up @@ -484,22 +484,26 @@ public static SKBitmap DrawTimestamp(SKBitmap sectionImage, List<SKBitmap> image
public SKBitmap DrawBadges(SKBitmap sectionImage, List<SKBitmap> imageList, ChatRenderOptions renderOptions, List<ChatBadge> chatBadges, Comment comment, Size canvasSize, ref Point drawPos)
{
//A little easter egg for my Twitch username won't hurt :)
if (comment.commenter.name == "ilovekeepo69" && chatBadges.Any(x => x.Name == "ilovekeepo69"))
try
{
SKBitmap badgeImage = chatBadges.Where(x => x.Name == "ilovekeepo69").First().Versions["1"];
using (SKCanvas sectionImageCanvas = new SKCanvas(sectionImage))
if (comment.commenter.name == "ilovekeepo69" && chatBadges.Any(x => x.Name == "ilovekeepo69"))
{
float imageRatio = (float)(renderOptions.EmoteScale * 0.5);
float imageSize = badgeImage.Width * imageRatio;
float left = (float)drawPos.X;
float right = imageSize + left;
float top = (float)((sectionImage.Height - imageSize) / 2);
float bottom = imageSize + top;
SKRect drawBox = new SKRect(left, top, right, bottom);
sectionImageCanvas.DrawBitmap(badgeImage, drawBox, imagePaint);
drawPos.X += (int)Math.Floor(20 * renderOptions.EmoteScale);
SKBitmap badgeImage = chatBadges.Where(x => x.Name == "ilovekeepo69").First().Versions["1"];
using (SKCanvas sectionImageCanvas = new SKCanvas(sectionImage))
{
float imageRatio = (float)(renderOptions.EmoteScale * 0.5);
float imageSize = badgeImage.Width * imageRatio;
float left = (float)drawPos.X;
float right = imageSize + left;
float top = (float)((sectionImage.Height - imageSize) / 2);
float bottom = imageSize + top;
SKRect drawBox = new SKRect(left, top, right, bottom);
sectionImageCanvas.DrawBitmap(badgeImage, drawBox, imagePaint);
drawPos.X += (int)Math.Floor(20 * renderOptions.EmoteScale);
}
}
}
catch { }

if (comment.message.user_badges != null)
{
Expand Down

0 comments on commit 7606250

Please sign in to comment.