Skip to content

Commit

Permalink
Merge pull request #13 from approvers/feature/rinia/era/001
Browse files Browse the repository at this point in the history
Birth: 主張をもっと強くした
  • Loading branch information
2RiniaR authored Apr 23, 2024
2 parents 14f08f0 + 42fad64 commit cf90606
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
9 changes: 9 additions & 0 deletions Common/EnumerableUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Approvers.King.Common;

public static class EnumerableUtility
{
public static IEnumerable<T> Repeat<T>(T value, int count)
{
for (var i = 0; i < count; i++) yield return value;
}
}
2 changes: 0 additions & 2 deletions Common/MasterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ public static class MasterManager
public static TimeSpan DailyResetTime => TimeSpan.FromHours(0);

public static DateTime Birthday => new(2003, 4, 24);

public static string BirthdayMessage => "† 誕 生 日 だ 祝 え カ ス †";
}
6 changes: 3 additions & 3 deletions Common/TimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
public static class TimeManager
{
/// <summary>
/// アプリ内の現在時刻を取得する
/// デバッグ機能により操作されることがある
/// アプリ内の現在時刻を取得する
/// デバッグ機能により操作されることがある
/// </summary>
public static DateTime GetNow()
{
return DateTime.Now.ToLocalTime();
}

/// <summary>
/// 過ぎていればtrue
/// 過ぎていればtrue
/// </summary>
public static bool IsExpired(DateTime time)
{
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /App
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/runtime:7.0 AS runtime
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
WORKDIR /App
COPY --from=build /App/out .
ENTRYPOINT ["dotnet", "king-server.dll"]
12 changes: 9 additions & 3 deletions Events/BirthPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
using Approvers.King.Common;
using Discord;

namespace Approvers.King.Events;

public class BirthPresenter : SchedulerJobPresenterBase
{
private static readonly string Message = $"""
{string.Join("", EnumerableUtility.Repeat(IssoUtility.SmileStamp, 16))}
{IssoUtility.SmileStamp}                    {IssoUtility.SmileStamp}
{IssoUtility.SmileStamp} ***† 誕 生 日 だ 祝 え カ ス †*** {IssoUtility.SmileStamp}
{IssoUtility.SmileStamp}                    {IssoUtility.SmileStamp}
{string.Join("", EnumerableUtility.Repeat(IssoUtility.SmileStamp, 16))}
""";

protected override async Task MainAsync()
{
var guild = DiscordManager.Client.GetGuild(SettingManager.DiscordTargetGuildId);
var message = Format.Italics(Format.Bold(MasterManager.BirthdayMessage));
await guild.GetTextChannel(SettingManager.DiscordMainChannelId).SendMessageAsync(message);
await guild.GetTextChannel(SettingManager.DiscordMainChannelId).SendMessageAsync(Message);
}
}
3 changes: 2 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ private static async Task BuildAsync(string[] args)

DiscordManager.Client.MessageReceived += OnMessageReceived;
SchedulerManager.RegisterDaily<GachaRateUpdatePresenter>(MasterManager.DailyResetTime);
SchedulerManager.RegisterYearly<BirthPresenter>(MasterManager.Birthday + MasterManager.DailyResetTime);
SchedulerManager.RegisterYearly<BirthPresenter>(MasterManager.Birthday + MasterManager.DailyResetTime +
TimeSpan.FromSeconds(1));

// 永久に待つ
await Task.Delay(-1);
Expand Down
2 changes: 1 addition & 1 deletion king-server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Approvers.King</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down

0 comments on commit cf90606

Please sign in to comment.