Skip to content

Commit

Permalink
Merge branch 'master' into warn
Browse files Browse the repository at this point in the history
# Conflicts:
#	locale/Messages.tt-ru.resx
  • Loading branch information
mctaylors committed Apr 8, 2024
2 parents 5ff2372 + 508edcb commit 1350c65
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 818 deletions.
801 changes: 0 additions & 801 deletions locale/Messages.tt-ru.resx

This file was deleted.

8 changes: 4 additions & 4 deletions src/Commands/AboutCommandGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ private async Task<Result> SendAboutBotAsync(IUser bot, Snowflake guildId, Cance
.WithSmallTitle(string.Format(Messages.AboutBot, bot.Username), bot)
.WithDescription(builder.ToString())
.WithColour(ColorsList.Cyan)
.WithImageUrl("https://i.ibb.co/fS6wZhh/octobot-banner.png")
.WithImageUrl("https://raw.githubusercontent.com/TeamOctolings/Octobot/HEAD/docs/octobot-banner.png")
.WithFooter(string.Format(Messages.Version, BuildInfo.Version))
.Build();

var repositoryButton = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonOpenRepository,
new PartialEmoji(Name: "🌐"),
new PartialEmoji(Name: "\ud83c\udf10"), // 'GLOBE WITH MERIDIANS' (U+1F310)
URL: BuildInfo.RepositoryUrl
);

var wikiButton = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonOpenWiki,
new PartialEmoji(Name: "📖"),
new PartialEmoji(Name: "\ud83d\udcd6"), // 'OPEN BOOK' (U+1F4D6)
URL: BuildInfo.WikiUrl
);

Expand All @@ -123,7 +123,7 @@ private async Task<Result> SendAboutBotAsync(IUser bot, Snowflake guildId, Cance
BuildInfo.IsDirty
? Messages.ButtonDirty
: Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
new PartialEmoji(Name: "\u26a0\ufe0f"), // 'WARNING SIGN' (U+26A0)
URL: BuildInfo.IssuesUrl,
IsDisabled: BuildInfo.IsDirty
);
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Events/ErrorLoggingPostExecutionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task<Result> AfterExecutionAsync(
BuildInfo.IsDirty
? Messages.ButtonDirty
: Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
new PartialEmoji(Name: "\u26a0\ufe0f"), // 'WARNING SIGN' (U+26A0)
URL: BuildInfo.IssuesUrl,
IsDisabled: BuildInfo.IsDirty
);
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Options/LanguageOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public sealed class LanguageOption : Option<CultureInfo>
private static readonly Dictionary<string, CultureInfo> CultureInfoCache = new()
{
{ "en", new CultureInfo("en-US") },
{ "ru", new CultureInfo("ru-RU") },
{ "mctaylors-ru", new CultureInfo("tt-RU") }
{ "ru", new CultureInfo("ru-RU") }
};

public LanguageOption(string name, string defaultValue) : base(name, CultureInfoCache[defaultValue]) { }
Expand Down
2 changes: 1 addition & 1 deletion src/Responders/GuildLoadedResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private async Task<Result> SendDataLoadFailed(IGuild guild, GuildData data, IUse
BuildInfo.IsDirty
? Messages.ButtonDirty
: Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
new PartialEmoji(Name: "\u26a0\ufe0f"), // 'WARNING SIGN' (U+26A0)
URL: BuildInfo.IssuesUrl,
IsDisabled: BuildInfo.IsDirty
);
Expand Down
18 changes: 16 additions & 2 deletions src/Services/GuildDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToke
var settingsPath = $"{path}/Settings.json";
var scheduledEventsPath = $"{path}/ScheduledEvents.json";

MigrateGuildData(guildId, path);
MigrateDataDirectory(guildId, path);

Directory.CreateDirectory(path);

Expand Down Expand Up @@ -106,6 +106,11 @@ private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToke
dataLoadFailed = true;
}

if (jsonSettings is not null)
{
FixJsonSettings(jsonSettings);
}

await using var eventsStream = File.OpenRead(scheduledEventsPath);
Dictionary<ulong, ScheduledEventData>? events = null;
try
Expand Down Expand Up @@ -155,7 +160,7 @@ private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToke
return finalData;
}

private void MigrateGuildData(Snowflake guildId, string newPath)
private void MigrateDataDirectory(Snowflake guildId, string newPath)
{
var oldPath = $"{guildId}";

Expand All @@ -169,6 +174,15 @@ private void MigrateGuildData(Snowflake guildId, string newPath)
}
}

private static void FixJsonSettings(JsonNode settings)
{
var language = settings[GuildSettings.Language.Name]?.GetValue<string>();
if (language is "mctaylors-ru")
{
settings[GuildSettings.Language.Name] = "ru";
}
}

public async Task<JsonNode> GetSettings(Snowflake guildId, CancellationToken ct = default)
{
return (await GetData(guildId, ct)).Settings;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Update/ScheduledEventUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private async Task<Result> SendScheduledEventCreatedMessage(
var button = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonOpenEventInfo,
new PartialEmoji(Name: "📋"),
new PartialEmoji(Name: "\ud83d\udccb"), // 'CLIPBOARD' (U+1F4CB)
URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}"
);

Expand Down
31 changes: 25 additions & 6 deletions src/Services/Update/SongUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ private static readonly (string Author, string Name, TimeSpan Duration)[] SongLi
("Off the Hook", "Fly Octo Fly ~ Ebb & Flow (Octo)", new TimeSpan(0, 3, 5))
];

private static readonly (string Author, string Name, TimeSpan Duration)[] SpecialSongList =
[
("Squid Sisters", "Maritime Memory", new TimeSpan(0, 2, 47))
];

private readonly List<Activity> _activityList = [new Activity("with Remora.Discord", ActivityType.Game)];

private readonly DiscordGatewayClient _client;
Expand All @@ -54,19 +59,33 @@ protected override async Task ExecuteAsync(CancellationToken ct)

while (!ct.IsCancellationRequested)
{
var nextSong = SongList[_nextSongIndex];
var nextSong = NextSong();
_activityList[0] = new Activity($"{nextSong.Name} / {nextSong.Author}",
ActivityType.Listening);
_client.SubmitCommand(
new UpdatePresence(
UserStatus.Online, false, DateTimeOffset.UtcNow, _activityList));
_nextSongIndex++;
if (_nextSongIndex >= SongList.Length)
{
_nextSongIndex = 0;
}

await Task.Delay(nextSong.Duration, ct);
}
}

private (string Author, string Name, TimeSpan Duration) NextSong()
{
var today = DateTime.Today;
// Discontinuation of Online Services for Nintendo Wii U
if (today.Day is 8 or 9 && today.Month is 4)
{
return SpecialSongList[0]; // Maritime Memory / Squid Sisters
}

var nextSong = SongList[_nextSongIndex];
_nextSongIndex++;
if (_nextSongIndex >= SongList.Length)
{
_nextSongIndex = 0;
}

return nextSong;
}
}

0 comments on commit 1350c65

Please sign in to comment.