reformat
This commit is contained in:
parent
7ea945b427
commit
99c1587e7b
12 changed files with 35 additions and 35 deletions
|
|
@ -7,7 +7,7 @@ namespace Catalogger.Backend.Bot;
|
||||||
public static class DiscordUtils
|
public static class DiscordUtils
|
||||||
{
|
{
|
||||||
public static readonly Snowflake PkUserId = DiscordSnowflake.New(466378653216014359);
|
public static readonly Snowflake PkUserId = DiscordSnowflake.New(466378653216014359);
|
||||||
|
|
||||||
public static readonly Color Red = Color.FromArgb(231, 76, 60);
|
public static readonly Color Red = Color.FromArgb(231, 76, 60);
|
||||||
public static readonly Color Purple = Color.FromArgb(155, 89, 182);
|
public static readonly Color Purple = Color.FromArgb(155, 89, 182);
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ public class GuildCreateResponder(
|
||||||
await tx.CommitAsync(ct);
|
await tx.CommitAsync(ct);
|
||||||
|
|
||||||
_logger.Information("Joined new guild {GuildName} / {GuildId}", guildName, guildId);
|
_logger.Information("Joined new guild {GuildName} / {GuildId}", guildName, guildId);
|
||||||
|
|
||||||
if (config.Discord.GuildLogId != null && evt.Guild.IsT0)
|
if (config.Discord.GuildLogId != null && evt.Guild.IsT0)
|
||||||
await webhookExecutor.QueueLogAsync(config.Discord.GuildLogId.Value, new EmbedBuilder()
|
await webhookExecutor.QueueLogAsync(config.Discord.GuildLogId.Value, new EmbedBuilder()
|
||||||
.WithTitle("Joined new guild")
|
.WithTitle("Joined new guild")
|
||||||
|
|
@ -83,9 +83,9 @@ public class GuildCreateResponder(
|
||||||
_logger.Information("Left uncached guild {GuildId}", evt.ID);
|
_logger.Information("Left uncached guild {GuildId}", evt.ID);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Information("Left guild {GuildName} / {GuildId}", guild.Name, guild.ID);
|
_logger.Information("Left guild {GuildName} / {GuildId}", guild.Name, guild.ID);
|
||||||
|
|
||||||
if (config.Discord.GuildLogId != null)
|
if (config.Discord.GuildLogId != null)
|
||||||
await webhookExecutor.QueueLogAsync(config.Discord.GuildLogId.Value, new EmbedBuilder()
|
await webhookExecutor.QueueLogAsync(config.Discord.GuildLogId.Value, new EmbedBuilder()
|
||||||
.WithTitle("Left guild")
|
.WithTitle("Left guild")
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ public class ChannelCacheService
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGet(Snowflake id, [NotNullWhen(true)] out IChannel? channel) => _channels.TryGetValue(id, out channel);
|
public bool TryGet(Snowflake id, [NotNullWhen(true)] out IChannel? channel) =>
|
||||||
|
_channels.TryGetValue(id, out channel);
|
||||||
|
|
||||||
public void Remove(Snowflake? guildId, Snowflake id, out IChannel? channel)
|
public void Remove(Snowflake? guildId, Snowflake id, out IChannel? channel)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class GuildCacheService
|
||||||
private readonly ConcurrentDictionary<Snowflake, IGuild> _guilds = new();
|
private readonly ConcurrentDictionary<Snowflake, IGuild> _guilds = new();
|
||||||
|
|
||||||
public int Size => _guilds.Count;
|
public int Size => _guilds.Count;
|
||||||
|
|
||||||
public void Set(IGuild guild) => _guilds[guild.ID] = guild;
|
public void Set(IGuild guild) => _guilds[guild.ID] = guild;
|
||||||
public bool Remove(Snowflake id, [NotNullWhen(true)] out IGuild? guild) => _guilds.Remove(id, out guild);
|
public bool Remove(Snowflake id, [NotNullWhen(true)] out IGuild? guild) => _guilds.Remove(id, out guild);
|
||||||
public bool TryGet(Snowflake id, [NotNullWhen(true)] out IGuild? guild) => _guilds.TryGetValue(id, out guild);
|
public bool TryGet(Snowflake id, [NotNullWhen(true)] out IGuild? guild) => _guilds.TryGetValue(id, out guild);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Catalogger.Backend.Cache;
|
||||||
public class UserCacheService(IDiscordRestUserAPI userApi)
|
public class UserCacheService(IDiscordRestUserAPI userApi)
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<Snowflake, IUser> _cache = new();
|
private readonly ConcurrentDictionary<Snowflake, IUser> _cache = new();
|
||||||
|
|
||||||
public int Size => _cache.Count;
|
public int Size => _cache.Count;
|
||||||
|
|
||||||
public async Task<IUser?> GetUserAsync(Snowflake userId)
|
public async Task<IUser?> GetUserAsync(Snowflake userId)
|
||||||
|
|
|
||||||
|
|
@ -7,29 +7,29 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="App.Metrics" Version="4.3.0" />
|
<PackageReference Include="App.Metrics" Version="4.3.0"/>
|
||||||
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
|
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3"/>
|
||||||
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="8.1.2" />
|
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="8.1.2"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.7" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.7"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6"/>
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||||
<PackageReference Include="NodaTime" Version="3.1.11" />
|
<PackageReference Include="NodaTime" Version="3.1.11"/>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4"/>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="8.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="8.0.4"/>
|
||||||
<PackageReference Include="Polly.Core" Version="8.4.1" />
|
<PackageReference Include="Polly.Core" Version="8.4.1"/>
|
||||||
<PackageReference Include="Polly.RateLimiting" Version="8.4.1" />
|
<PackageReference Include="Polly.RateLimiting" Version="8.4.1"/>
|
||||||
<PackageReference Include="Remora.Discord" Version="2024.2.0" />
|
<PackageReference Include="Remora.Discord" Version="2024.2.0"/>
|
||||||
<PackageReference Include="Serilog" Version="4.0.1" />
|
<PackageReference Include="Serilog" Version="4.0.1"/>
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1"/>
|
||||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0"/>
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0"/>
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
|
<PackageReference Include="StackExchange.Redis" Version="2.8.0"/>
|
||||||
<PackageReference Include="StackExchange.Redis.Extensions.System.Text.Json" Version="10.2.0" />
|
<PackageReference Include="StackExchange.Redis.Extensions.System.Text.Json" Version="10.2.0"/>
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public static class CataloggerMetrics
|
||||||
MeasurementUnit = Unit.Items,
|
MeasurementUnit = Unit.Items,
|
||||||
Context = "Bot"
|
Context = "Bot"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static GaugeOptions UsersCached => new()
|
public static GaugeOptions UsersCached => new()
|
||||||
{
|
{
|
||||||
Name = "Users cached",
|
Name = "Users cached",
|
||||||
|
|
@ -50,7 +50,7 @@ public static class CataloggerMetrics
|
||||||
DurationUnit = TimeUnit.Milliseconds,
|
DurationUnit = TimeUnit.Milliseconds,
|
||||||
Context = "Bot"
|
Context = "Bot"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static GaugeOptions ProcessPhysicalMemory => new()
|
public static GaugeOptions ProcessPhysicalMemory => new()
|
||||||
{
|
{
|
||||||
Name = "Process physical memory",
|
Name = "Process physical memory",
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ public class Guild
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
public required ulong Id { get; init; }
|
public required ulong Id { get; init; }
|
||||||
|
|
||||||
[Column(TypeName = "jsonb")]
|
[Column(TypeName = "jsonb")] public ChannelConfig Channels { get; init; } = new();
|
||||||
public ChannelConfig Channels { get; init; } = new();
|
|
||||||
public List<string> BannedSystems { get; init; } = [];
|
public List<string> BannedSystems { get; init; } = [];
|
||||||
public List<ulong> KeyRoles { get; init; } = [];
|
public List<ulong> KeyRoles { get; init; } = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ public class Watchlist
|
||||||
public required ulong GuildId { get; init; }
|
public required ulong GuildId { get; init; }
|
||||||
public required ulong UserId { get; init; }
|
public required ulong UserId { get; init; }
|
||||||
public Instant AddedAt { get; init; }
|
public Instant AddedAt { get; init; }
|
||||||
|
|
||||||
public required ulong ModeratorId { get; set; }
|
public required ulong ModeratorId { get; set; }
|
||||||
public required string Reason { get; set; }
|
public required string Reason { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
||||||
namespace Catalogger.Backend.Database;
|
namespace Catalogger.Backend.Database;
|
||||||
|
|
@ -1 +1 @@
|
||||||
global using ILogger = Serilog.ILogger;
|
global using ILogger = Serilog.ILogger;
|
||||||
|
|
@ -16,7 +16,7 @@ public interface IWebhookCache
|
||||||
if (webhook != null) return webhook.Value;
|
if (webhook != null) return webhook.Value;
|
||||||
|
|
||||||
var discordWebhook = await fetch(DiscordSnowflake.New(channelId));
|
var discordWebhook = await fetch(DiscordSnowflake.New(channelId));
|
||||||
webhook = new Webhook { Id = discordWebhook.ID.ToUlong(), Token = discordWebhook.Token.Value};
|
webhook = new Webhook { Id = discordWebhook.ID.ToUlong(), Token = discordWebhook.Token.Value };
|
||||||
await SetWebhookAsync(channelId, webhook.Value);
|
await SetWebhookAsync(channelId, webhook.Value);
|
||||||
return webhook.Value;
|
return webhook.Value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue