diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..cc1d10545 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +# Ignore all files +* + +# Use NadekoBot project +!src/NadekoBot/** +# Use NadekoBot.Coordinator project +!src/NadekoBot.Coordinator/** +# Use Ayu stuff +!src/ayu/** + +# ignore bin and obj folders in projects +src/**/bin/* +src/**/obj/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4d2286144 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /source + +COPY src/NadekoBot/*.csproj src/NadekoBot/ +COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/ +COPY src/ayu/Ayu.Discord.Voice/*.csproj src/ayu/Ayu.Discord.Voice/ +RUN dotnet restore src/NadekoBot/ + +COPY . . +WORKDIR /source/src/NadekoBot +RUN dotnet publish -c Release -o /app --no-restore + +# final stage/image +FROM mcr.microsoft.com/dotnet/aspnet:5.0 +ENV shard_id=0 +ENV total_shards=1 +WORKDIR /app +COPY --from=build /app ./ +VOLUME [ "/data" ] +ENTRYPOINT dotnet NadekoBot.dll "$shard_id" "$total_shards" \ No newline at end of file diff --git a/README.md b/README.md index 088808b7c..bdbd3f78d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Migration from 2.x -:warning: You **MUST** update to latest version of 2.x and **run yourbot at least once** before switching over to v3 +:warning: You **MUST** update to latest version of 2.x and **run your bot at least once** before switching over to v3 ## Changes @@ -13,12 +13,12 @@ - All database migrations and data (json file) migrations have been removed - As updating to the latest 2.x version before switching over to v3 is mandated (or fresh v3install), that means all migration code has ran and it can be safely removed - There are 2 projects: NadekoBot and NadekoBot.Coordinator - - NadekoBot is the regular bot with one shard, or if you can run it if you want to run your shards -- credentials.json moved to `creds.yml`, example is in `creds_example.yml`, most of the credentials from 2.x will be automatically migrated -- Guide will now instruct users to set build output to nadekobot/output instead of running from nadekobot/src/NadekoBot/bin/release/net5 -- todo: Reworked from source installation (linux/windows) guide -- todo: Added docker installation guide at -- todo?: votes functionality changed -- todo?: maybe use https://github.com/Humanizr/Humanizer for trimto, time printing, date printing, etc -- todo?: use guild locale more in the code (from guild settings) (for dates, currency, etc?) -- todo?: Write a sourcegen for response strings and use const/static fields (maybe even typed to enforce correct number of arguments) \ No newline at end of file + - You can directly run NadekoBot as the regular bot with one shard + - Run NadekoBot.Coordinator if you want more control over your shards and a grpc api for coordinator with which you can start, restart, kill and see status of shards +- credentials.json moved to `creds.yml` + - example is in `creds_example.yml` + - most of the credentials from 2.x will be automatically migrated +- Guides + - Now instruct users to set build output to nadekobot/output instead of running from nadekobot/src/NadekoBot/bin/release/net5 + - todo: Reworked from source installation (linux/windows) guide + - todo: Added docker support, installation guide at \ No newline at end of file diff --git a/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs b/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs index 7757028c5..a1ea1374c 100644 --- a/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs @@ -46,10 +46,12 @@ namespace NadekoBot.Modules.Gambling.Services } } + // todo future use votes api directly? private async Task BotlistUpvoteLoop() { if (string.IsNullOrWhiteSpace(_creds.VotesUrl)) return; + while (true) { await Task.Delay(TimeSpan.FromHours(1)).ConfigureAwait(false); diff --git a/src/NadekoBot/Program.cs b/src/NadekoBot/Program.cs index ee4f0f7ed..76725989c 100644 --- a/src/NadekoBot/Program.cs +++ b/src/NadekoBot/Program.cs @@ -11,7 +11,7 @@ if (args.Length > 0) { if (!int.TryParse(args[0], out shardId)) { - Console.Error.WriteLine("Invalid first argument (shard id)"); + Console.Error.WriteLine("Invalid first argument (shard id): {0}", args[0]); return; } @@ -19,7 +19,7 @@ if (args.Length > 0) { if (!int.TryParse(args[1], out var shardCount)) { - Console.Error.WriteLine("Invalid second argument (total shards)"); + Console.Error.WriteLine("Invalid second argument (total shards): {0}", args[1]); return; } diff --git a/src/NadekoBot/Services/Impl/Localization.cs b/src/NadekoBot/Services/Impl/Localization.cs index 7381d0c6b..0b6dd7e4a 100644 --- a/src/NadekoBot/Services/Impl/Localization.cs +++ b/src/NadekoBot/Services/Impl/Localization.cs @@ -11,6 +11,9 @@ using NadekoBot.Modules.Administration; namespace NadekoBot.Services { + // todo future use guild locale more in the code (from guild settings) (for dates, currency, etc?) + // todo future maybe Write a sourcegen for response strings + // and use const/static fields (maybe even typed to enforce correct number of arguments) public class Localization : ILocalization, INService { private readonly BotConfigService _bss; diff --git a/src/NadekoBot/_Extensions/StringExtensions.cs b/src/NadekoBot/_Extensions/StringExtensions.cs index 3a43c2bc3..cf4f6646a 100644 --- a/src/NadekoBot/_Extensions/StringExtensions.cs +++ b/src/NadekoBot/_Extensions/StringExtensions.cs @@ -32,6 +32,7 @@ namespace NadekoBot.Extensions return Regex.Replace(input, "<.*?>", String.Empty); } + // todo future maybe use humanizer lib for this kind of work public static string TrimTo(this string str, int maxLength, bool hideDots = false) { if (maxLength < 0)