Skip to content

Commit

Permalink
Add DiscordService
Browse files Browse the repository at this point in the history
  • Loading branch information
jim60105 committed Dec 11, 2023
1 parent 15062d8 commit 537dc0c
Show file tree
Hide file tree
Showing 8 changed files with 2,172 additions and 2,118 deletions.
35 changes: 1 addition & 34 deletions Helper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Discord;
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;

namespace YoutubeLiveChatToDiscord;

Expand Down Expand Up @@ -36,38 +35,6 @@ where File.Exists(path)
return YtdlPath;
}

/// <summary>
/// 把.NET Core logger對應到Discord內建的logger上面
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
internal static Task DiscordWebhookClient_Log(LogMessage arg)
=> Task.Run(() =>
{
switch (arg.Severity)
{
case LogSeverity.Critical:
_logger.LogCritical("{message}", arg);
break;
case LogSeverity.Error:
_logger.LogError("{message}", arg);
break;
case LogSeverity.Warning:
_logger.LogWarning("{message}", arg);
break;
case LogSeverity.Info:
_logger.LogInformation("{message}", arg);
break;
case LogSeverity.Verbose:
_logger.LogTrace("{message}", arg);
break;
case LogSeverity.Debug:
default:
_logger.LogDebug("{message}", arg);
break;
}
});

/// <summary>
/// 處理Youtube的圖片url,取得原始尺寸圖片
/// </summary>
Expand Down
8 changes: 6 additions & 2 deletions Json/SourceGenerationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

// Must read:
// https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-8-0
[JsonSerializable(typeof(Info))]
[JsonSerializable(typeof(Chat))]
[JsonSourceGenerationOptions(WriteIndented = true, AllowTrailingCommas = true, ReadCommentHandling = JsonCommentHandling.Skip)]
[JsonSerializable(typeof(Info.info))]
[JsonSerializable(typeof(Chat.chat))]
[JsonSerializable(typeof(Info.Thumbnail), TypeInfoPropertyName = "InfoThumbnail")]
[JsonSerializable(typeof(Chat.Thumbnail), TypeInfoPropertyName = "ChatThumbnail")]
[JsonSerializable(typeof(List<Chat.Thumbnail>), TypeInfoPropertyName = "ChatThumbnailList")]
[JsonSerializable(typeof(List<Info.Thumbnail>), TypeInfoPropertyName = "InfoThumbnailList")]
internal partial class SourceGenerationContext : JsonSerializerContext { }
547 changes: 148 additions & 399 deletions LiveChatMonitorWorker.cs

Large diffs are not rendered by default.

Loading

0 comments on commit 537dc0c

Please sign in to comment.