Updated changelog, version upped to 5.1.9

This commit is contained in:
Toastie 2024-09-22 14:42:16 +12:00
parent 3be1105ea5
commit 2108e5435d
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
3 changed files with 72 additions and 46 deletions

View file

@ -2,6 +2,19 @@
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o
## [5.1.9] - 21.09.2024
### Fixed
- Fixed `.greettest`, and other `.*test` commands if you didn't have them enabled.
- Fixed `.greetdmtest` sending messages twice.
- Fixed a serious bug which caused greet messages to be jumbled up, and wrong ones to be sent for the wrong events.
- There is no database issue, all greet messages are safe, the cache was caching any setting every 3 seconds with no regard for the type of the event
- This also caused `.greetdm` messages to not be sent if `.greet` is enabled
- This bug was introduced in 5.1.8. PLEASE UPDATE if you are on 5.1.8
- Selfhosters only: Fixed marmalade dependency loading
- Note: Make sure to not publish any other DLLs besides the ones you are sure you will need, as there can be version conflicts which didn't happen before.
## [5.1.8] - 20.09.2024 ## [5.1.8] - 20.09.2024
### Added ### Added

View file

@ -4,7 +4,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings> <ImplicitUsings>true</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Version>5.1.8</Version> <Version>5.1.9</Version>
<!-- Output/build --> <!-- Output/build -->
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
@ -129,6 +129,10 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Grpc\" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'GlobalEllie' "> <PropertyGroup Condition=" '$(Configuration)' == 'GlobalEllie' ">
<!-- Define trace doesn't seem to affect the build at all so I had to remove $(DefineConstants)--> <!-- Define trace doesn't seem to affect the build at all so I had to remove $(DefineConstants)-->

View file

@ -75,11 +75,19 @@ public class GreetService : IEService, IReadyExecutor
_client.GuildMemberUpdated += ClientOnGuildMemberUpdated; _client.GuildMemberUpdated += ClientOnGuildMemberUpdated;
var timer = new PeriodicTimer(TimeSpan.FromSeconds(2)); while (true)
while (await timer.WaitForNextTickAsync())
{ {
var (conf, user, ch) = await _greetQueue.Reader.ReadAsync(); try
await GreetUsers(conf, ch, user); {
var (conf, user, ch) = await _greetQueue.Reader.ReadAsync();
await GreetUsers(conf, ch, user);
}
catch (Exception ex)
{
Log.Error(ex, "Greet Loop almost crashed. Please report this!");
}
await Task.Delay(2016);
} }
} }
@ -155,10 +163,11 @@ public class GreetService : IEService, IReadyExecutor
return Task.CompletedTask; return Task.CompletedTask;
} }
private readonly TypedKey<GreetSettings?> _greetSettingsKey = new("greet_settings"); private TypedKey<GreetSettings?> GreetSettingsKey(GreetType type)
=> new($"greet_settings:{type}");
public async Task<GreetSettings?> GetGreetSettingsAsync(ulong gid, GreetType type) public async Task<GreetSettings?> GetGreetSettingsAsync(ulong gid, GreetType type)
=> await _cache.GetOrAddAsync<GreetSettings?>(_greetSettingsKey, => await _cache.GetOrAddAsync<GreetSettings?>(GreetSettingsKey(type),
() => InternalGetGreetSettingsAsync(gid, type), () => InternalGetGreetSettingsAsync(gid, type),
TimeSpan.FromSeconds(3)); TimeSpan.FromSeconds(3));
@ -217,14 +226,6 @@ public class GreetService : IEService, IReadyExecutor
} }
} }
private async Task<bool> GreetDmUser(GreetSettings conf, IGuildUser user)
{
var completionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
await _greetQueue.Writer.WriteAsync((conf, user, null));
return await completionSource.Task;
}
private async Task<bool> GreetDmUserInternal(GreetSettings conf, IGuildUser user) private async Task<bool> GreetDmUserInternal(GreetSettings conf, IGuildUser user)
{ {
try try
@ -280,9 +281,9 @@ public class GreetService : IEService, IReadyExecutor
{ {
// if there is less than 10 embeds, add an embed with footer only // if there is less than 10 embeds, add an embed with footer only
seta.Embeds = seta.Embeds.Append(new SmartEmbedArrayElementText() seta.Embeds = seta.Embeds.Append(new SmartEmbedArrayElementText()
{ {
Footer = CreateFooterSource(user) Footer = CreateFooterSource(user)
}) })
.ToArray(); .ToArray();
} }
} }
@ -311,21 +312,28 @@ public class GreetService : IEService, IReadyExecutor
{ {
try try
{ {
var conf = await GetGreetSettingsAsync(user.GuildId, GreetType.Greet); if (_enabled[GreetType.Greet].Contains(user.GuildId))
if (conf is not null && conf.IsEnabled && conf.ChannelId is { } channelId)
{ {
var channel = await user.Guild.GetTextChannelAsync(channelId); var conf = await GetGreetSettingsAsync(user.GuildId, GreetType.Greet);
if (channel is not null) if (conf?.ChannelId is ulong cid)
{ {
await _greetQueue.Writer.WriteAsync((conf, user, channel)); var channel = await user.Guild.GetTextChannelAsync(cid);
if (channel is not null)
{
await _greetQueue.Writer.WriteAsync((conf, user, channel));
}
} }
} }
var confDm = await GetGreetSettingsAsync(user.GuildId, GreetType.GreetDm);
if (confDm?.IsEnabled ?? false) if (_enabled[GreetType.GreetDm].Contains(user.GuildId))
await GreetDmUser(confDm, user); {
var confDm = await GetGreetSettingsAsync(user.GuildId, GreetType.GreetDm);
if (confDm is not null)
{
await _greetQueue.Writer.WriteAsync((confDm, user, null));
}
}
} }
catch catch
{ {
@ -354,20 +362,20 @@ public class GreetService : IEService, IReadyExecutor
{ {
await using var uow = _db.GetDbContext(); await using var uow = _db.GetDbContext();
var q = uow.GetTable<GreetSettings>(); var q = uow.GetTable<GreetSettings>();
if(value is null) if (value is null)
value = !_enabled[greetType].Contains(guildId); value = !_enabled[greetType].Contains(guildId);
if (value is { } v) if (value is { } v)
{ {
await q await q
.InsertOrUpdateAsync(() => new() .InsertOrUpdateAsync(() => new()
{ {
GuildId = guildId, GuildId = guildId,
GreetType = greetType, GreetType = greetType,
IsEnabled = v, IsEnabled = v,
ChannelId = channelId, ChannelId = channelId,
}, },
(old) => new() (old) => new()
{ {
IsEnabled = v, IsEnabled = v,
@ -397,11 +405,11 @@ public class GreetService : IEService, IReadyExecutor
{ {
await uow.GetTable<GreetSettings>() await uow.GetTable<GreetSettings>()
.InsertOrUpdateAsync(() => new() .InsertOrUpdateAsync(() => new()
{ {
GuildId = guildId, GuildId = guildId,
GreetType = greetType, GreetType = greetType,
MessageText = message MessageText = message
}, },
x => new() x => new()
{ {
MessageText = message MessageText = message
@ -427,11 +435,11 @@ public class GreetService : IEService, IReadyExecutor
{ {
await uow.GetTable<GreetSettings>() await uow.GetTable<GreetSettings>()
.InsertOrUpdateAsync(() => new() .InsertOrUpdateAsync(() => new()
{ {
GuildId = guildId, GuildId = guildId,
GreetType = greetType, GreetType = greetType,
AutoDeleteTimer = timer, AutoDeleteTimer = timer,
}, },
x => new() x => new()
{ {
AutoDeleteTimer = timer AutoDeleteTimer = timer
@ -477,7 +485,8 @@ public class GreetService : IEService, IReadyExecutor
{ {
if (conf.GreetType == GreetType.GreetDm) if (conf.GreetType == GreetType.GreetDm)
{ {
return await GreetDmUser(conf, user); await _greetQueue.Writer.WriteAsync((conf, user, null));
return true;
} }
if (channel is not ITextChannel ch) if (channel is not ITextChannel ch)