1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 16:33:36 +03:00

Merge branch 'master' into left-guild-message

This commit is contained in:
Macintxsh 2023-12-20 19:50:14 +03:00 committed by GitHub
commit 3759816273
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 35 additions and 55 deletions

View file

@ -400,7 +400,7 @@
<value>Octobot's source code</value>
</data>
<data name="AboutBot" xml:space="preserve">
<value>About Octobot</value>
<value>About {0}</value>
</data>
<data name="AboutDeveloper@mctaylors" xml:space="preserve">
<value>developer &amp; designer, Octobot's Wiki creator</value>

View file

@ -400,7 +400,7 @@
<value>Исходный код Octobot</value>
</data>
<data name="AboutBot" xml:space="preserve">
<value>Об Octobot</value>
<value>О боте {0}</value>
</data>
<data name="AboutDeveloper@neroduckale" xml:space="preserve">
<value>разработчик</value>

View file

@ -400,7 +400,7 @@
<value>репа Octobot (тык)</value>
</data>
<data name="AboutBot" xml:space="preserve">
<value>немного об Octobot</value>
<value>немного об {0}</value>
</data>
<data name="AboutDeveloper@mctaylors" xml:space="preserve">
<value>скучный девелопер + дизайнер создавший Octobot's Wiki</value>

View file

@ -28,11 +28,11 @@ namespace Octobot.Commands;
public class AboutCommandGroup : CommandGroup
{
private static readonly (string Username, Snowflake Id)[] Developers =
{
[
("Octol1ttle", new Snowflake(504343489664909322)),
("mctaylors", new Snowflake(326642240229474304)),
("neroduckale", new Snowflake(474943797063843851))
};
];
private readonly ICommandContext _context;
private readonly IFeedbackService _feedback;
@ -96,7 +96,8 @@ public class AboutCommandGroup : CommandGroup
builder.AppendBulletPointLine($"{tag} — {$"AboutDeveloper@{dev.Username}".Localized()}");
}
var embed = new EmbedBuilder().WithSmallTitle(Messages.AboutBot, bot)
var embed = new EmbedBuilder()
.WithSmallTitle(string.Format(Messages.AboutBot, bot.Username), bot)
.WithDescription(builder.ToString())
.WithColour(ColorsList.Cyan)
.WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png")

View file

@ -33,12 +33,12 @@ public class BanCommandGroup : CommandGroup
private readonly IDiscordRestGuildAPI _guildApi;
private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi;
private readonly UtilityService _utility;
private readonly Utility _utility;
public BanCommandGroup(
ICommandContext context, IDiscordRestChannelAPI channelApi, GuildDataService guildData,
IFeedbackService feedback, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi,
UtilityService utility)
Utility utility)
{
_context = context;
_channelApi = channelApi;

View file

@ -30,11 +30,11 @@ public class ClearCommandGroup : CommandGroup
private readonly IFeedbackService _feedback;
private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi;
private readonly UtilityService _utility;
private readonly Utility _utility;
public ClearCommandGroup(
IDiscordRestChannelAPI channelApi, ICommandContext context, GuildDataService guildData,
IFeedbackService feedback, IDiscordRestUserAPI userApi, UtilityService utility)
IFeedbackService feedback, IDiscordRestUserAPI userApi, Utility utility)
{
_channelApi = channelApi;
_context = context;

View file

@ -30,12 +30,12 @@ public class KickCommandGroup : CommandGroup
private readonly IDiscordRestGuildAPI _guildApi;
private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi;
private readonly UtilityService _utility;
private readonly Utility _utility;
public KickCommandGroup(
ICommandContext context, IDiscordRestChannelAPI channelApi, GuildDataService guildData,
IFeedbackService feedback, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi,
UtilityService utility)
Utility utility)
{
_context = context;
_channelApi = channelApi;

View file

@ -32,11 +32,11 @@ public class MuteCommandGroup : CommandGroup
private readonly IDiscordRestGuildAPI _guildApi;
private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi;
private readonly UtilityService _utility;
private readonly Utility _utility;
public MuteCommandGroup(
ICommandContext context, GuildDataService guildData, IFeedbackService feedback,
IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi, UtilityService utility)
IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi, Utility utility)
{
_context = context;
_guildData = guildData;

View file

@ -36,7 +36,7 @@ public class SettingsCommandGroup : CommandGroup
/// that the orders match.
/// </remarks>
private static readonly IOption[] AllOptions =
{
[
GuildSettings.Language,
GuildSettings.WelcomeMessage,
GuildSettings.LeaveMessage,
@ -52,17 +52,17 @@ public class SettingsCommandGroup : CommandGroup
GuildSettings.MuteRole,
GuildSettings.EventNotificationRole,
GuildSettings.EventEarlyNotificationOffset
};
];
private readonly ICommandContext _context;
private readonly IFeedbackService _feedback;
private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi;
private readonly UtilityService _utility;
private readonly Utility _utility;
public SettingsCommandGroup(
ICommandContext context, GuildDataService guildData,
IFeedbackService feedback, IDiscordRestUserAPI userApi, UtilityService utility)
IFeedbackService feedback, IDiscordRestUserAPI userApi, Utility utility)
{
_context = context;
_guildData = guildData;

View file

@ -393,7 +393,7 @@ public class ToolsCommandGroup : CommandGroup
}
private static readonly TimestampStyle[] AllStyles =
{
[
TimestampStyle.ShortDate,
TimestampStyle.LongDate,
TimestampStyle.ShortTime,
@ -401,7 +401,7 @@ public class ToolsCommandGroup : CommandGroup
TimestampStyle.ShortDateTime,
TimestampStyle.LongDateTime,
TimestampStyle.RelativeTime
};
];
/// <summary>
/// A slash command that shows the current timestamp with an optional offset in all styles supported by Discord.

View file

@ -87,7 +87,7 @@ public sealed class Octobot
.AddPostExecutionEvent<ErrorLoggingPostExecutionEvent>()
// Services
.AddSingleton<GuildDataService>()
.AddSingleton<UtilityService>()
.AddSingleton<Utility>()
.AddHostedService<MemberUpdateService>()
.AddHostedService<ScheduledEventUpdateService>()
.AddHostedService<SongUpdateService>()

View file

@ -25,11 +25,11 @@ public class GuildLoadedResponder : IResponder<IGuildCreate>
private readonly GuildDataService _guildData;
private readonly ILogger<GuildLoadedResponder> _logger;
private readonly IDiscordRestUserAPI _userApi;
private readonly UtilityService _utility;
private readonly Utility _utility;
public GuildLoadedResponder(
IDiscordRestChannelAPI channelApi, GuildDataService guildData, ILogger<GuildLoadedResponder> logger,
IDiscordRestUserAPI userApi, UtilityService utility)
IDiscordRestUserAPI userApi, Utility utility)
{
_channelApi = channelApi;
_guildData = guildData;

View file

@ -11,7 +11,7 @@ namespace Octobot.Services;
/// <summary>
/// Handles saving, loading, initializing and providing <see cref="GuildData" />.
/// </summary>
public sealed class GuildDataService : IHostedService
public sealed class GuildDataService
{
private readonly ConcurrentDictionary<Snowflake, GuildData> _datas = new();
private readonly ILogger<GuildDataService> _logger;
@ -24,16 +24,6 @@ public sealed class GuildDataService : IHostedService
lifetime.ApplicationStopping.Register(ApplicationStopping);
}
public Task StartAsync(CancellationToken ct)
{
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken ct)
{
return Task.CompletedTask;
}
private void ApplicationStopping()
{
SaveAsync(CancellationToken.None).GetAwaiter().GetResult();

View file

@ -16,7 +16,7 @@ namespace Octobot.Services.Update;
public sealed partial class MemberUpdateService : BackgroundService
{
private static readonly string[] GenericNicknames =
{
[
"Albatross", "Alpha", "Anchor", "Banjo", "Bell", "Beta", "Blackbird", "Bulldog", "Canary",
"Cat", "Calf", "Cyclone", "Daisy", "Dalmatian", "Dart", "Delta", "Diamond", "Donkey", "Duck",
"Emu", "Eclipse", "Flamingo", "Flute", "Frog", "Goose", "Hatchet", "Heron", "Husky", "Hurricane",
@ -24,16 +24,16 @@ public sealed partial class MemberUpdateService : BackgroundService
"Nautilus", "Ostrich", "Octopus", "Pelican", "Puffin", "Pyramid", "Rattle", "Robin", "Rose",
"Salmon", "Seal", "Shark", "Sheep", "Snake", "Sonar", "Stump", "Sparrow", "Toaster", "Toucan",
"Torus", "Violet", "Vortex", "Vulture", "Wagon", "Whale", "Woodpecker", "Zebra", "Zigzag"
};
];
private readonly IDiscordRestChannelAPI _channelApi;
private readonly IDiscordRestGuildAPI _guildApi;
private readonly GuildDataService _guildData;
private readonly ILogger<MemberUpdateService> _logger;
private readonly UtilityService _utility;
private readonly Utility _utility;
public MemberUpdateService(IDiscordRestChannelAPI channelApi, IDiscordRestGuildAPI guildApi,
GuildDataService guildData, ILogger<MemberUpdateService> logger, UtilityService utility)
GuildDataService guildData, ILogger<MemberUpdateService> logger, Utility utility)
{
_channelApi = channelApi;
_guildApi = guildApi;

View file

@ -19,10 +19,10 @@ public sealed class ScheduledEventUpdateService : BackgroundService
private readonly IDiscordRestGuildScheduledEventAPI _eventApi;
private readonly GuildDataService _guildData;
private readonly ILogger<ScheduledEventUpdateService> _logger;
private readonly UtilityService _utility;
private readonly Utility _utility;
public ScheduledEventUpdateService(IDiscordRestChannelAPI channelApi, IDiscordRestGuildScheduledEventAPI eventApi,
GuildDataService guildData, ILogger<ScheduledEventUpdateService> logger, UtilityService utility)
GuildDataService guildData, ILogger<ScheduledEventUpdateService> logger, Utility utility)
{
_channelApi = channelApi;
_eventApi = eventApi;

View file

@ -9,7 +9,7 @@ namespace Octobot.Services.Update;
public sealed class SongUpdateService : BackgroundService
{
private static readonly (string Author, string Name, TimeSpan Duration)[] SongList =
{
[
("Yoko & the Gold Bazookas", "Rockagilly Blues", new TimeSpan(0, 2, 52)),
("Deep Cut", "Big Betrayal", new TimeSpan(0, 5, 55)),
("Squid Sisters", "Tomorrow's Nostalgia Today", new TimeSpan(0, 3, 7)),
@ -30,7 +30,7 @@ public sealed class SongUpdateService : BackgroundService
("Turquoise October", "Octoling Rendezvous", new TimeSpan(0, 1, 57)),
("Damp Socks feat. Off the Hook", "Tentacle to the Metal", new TimeSpan(0, 2, 51)),
("Off the Hook", "Fly Octo Fly ~ Ebb & Flow (Octo)", new TimeSpan(0, 3, 5))
};
];
private readonly List<Activity> _activityList = [new Activity("with Remora.Discord", ActivityType.Game)];

View file

@ -1,7 +1,6 @@
using System.Drawing;
using System.Text;
using System.Text.Json.Nodes;
using Microsoft.Extensions.Hosting;
using Octobot.Data;
using Octobot.Extensions;
using Remora.Discord.API.Abstractions.Objects;
@ -17,14 +16,14 @@ namespace Octobot.Services;
/// Provides utility methods that cannot be transformed to extension methods because they require usage
/// of some Discord APIs.
/// </summary>
public sealed class UtilityService : IHostedService
public sealed class Utility
{
private readonly IDiscordRestChannelAPI _channelApi;
private readonly IDiscordRestGuildScheduledEventAPI _eventApi;
private readonly IDiscordRestGuildAPI _guildApi;
private readonly IDiscordRestUserAPI _userApi;
public UtilityService(
public Utility(
IDiscordRestChannelAPI channelApi, IDiscordRestGuildScheduledEventAPI eventApi, IDiscordRestGuildAPI guildApi,
IDiscordRestUserAPI userApi)
{
@ -34,16 +33,6 @@ public sealed class UtilityService : IHostedService
_userApi = userApi;
}
public Task StartAsync(CancellationToken ct)
{
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken ct)
{
return Task.CompletedTask;
}
/// <summary>
/// Checks whether or not a member can interact with another member
/// </summary>