mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
dev: removed docker_compose.yml as you don't need redis.
dev: Removed aws package as we don't need gencmdlist to upload commands anymore, have to find a new way though.
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
version: "3.7"
|
|
||||||
|
|
||||||
services:
|
|
||||||
nadeko:
|
|
||||||
image: insert-image-name-here:latest
|
|
||||||
depends_on:
|
|
||||||
- redis
|
|
||||||
environment:
|
|
||||||
TZ: Europe/Paris
|
|
||||||
NadekoBot_RedisOptions: redis,name=nadeko
|
|
||||||
#NadekoBot_ShardRunCommand: dotnet
|
|
||||||
#NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1}
|
|
||||||
volumes:
|
|
||||||
- /srv/nadeko/conf:/app/conf:ro
|
|
||||||
- /srv/nadeko/data:/app/data
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:4-alpine
|
|
||||||
sysctls:
|
|
||||||
- net.core.somaxconn=511
|
|
||||||
command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru
|
|
||||||
volumes:
|
|
||||||
- /srv/nadeko/redis-data:/data
|
|
@@ -1,12 +1,9 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using Amazon.S3;
|
|
||||||
using NadekoBot.Modules.Help.Common;
|
using NadekoBot.Modules.Help.Common;
|
||||||
using NadekoBot.Modules.Help.Services;
|
using NadekoBot.Modules.Help.Services;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
|
||||||
using Nadeko.Common.Medusa;
|
using Nadeko.Common.Medusa;
|
||||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Help;
|
namespace NadekoBot.Modules.Help;
|
||||||
|
|
||||||
@@ -427,90 +424,8 @@ public sealed partial class Help : NadekoModule<HelpService>
|
|||||||
.ToList());
|
.ToList());
|
||||||
|
|
||||||
var readableData = JsonConvert.SerializeObject(cmdData, Formatting.Indented);
|
var readableData = JsonConvert.SerializeObject(cmdData, Formatting.Indented);
|
||||||
var uploadData = JsonConvert.SerializeObject(cmdData, Formatting.None);
|
|
||||||
|
// send the indented file to chat
|
||||||
// for example https://nyc.digitaloceanspaces.com (without your space name)
|
|
||||||
var serviceUrl = Environment.GetEnvironmentVariable("do_spaces_address");
|
|
||||||
|
|
||||||
// generate spaces access key on https://cloud.digitalocean.com/account/api/tokens
|
|
||||||
// you will get 2 keys, first, shorter one is id, longer one is secret
|
|
||||||
var accessKey = Environment.GetEnvironmentVariable("do_access_key_id");
|
|
||||||
var secretAcccessKey = Environment.GetEnvironmentVariable("do_access_key_secret");
|
|
||||||
|
|
||||||
// if all env vars are set, upload the unindented file (to save space) there
|
|
||||||
if (!(serviceUrl is null || accessKey is null || secretAcccessKey is null))
|
|
||||||
{
|
|
||||||
var config = new AmazonS3Config
|
|
||||||
{
|
|
||||||
ServiceURL = serviceUrl
|
|
||||||
};
|
|
||||||
|
|
||||||
using var dlClient = new AmazonS3Client(accessKey, secretAcccessKey, config);
|
|
||||||
|
|
||||||
using (var client = new AmazonS3Client(accessKey, secretAcccessKey, config))
|
|
||||||
{
|
|
||||||
await client.PutObjectAsync(new()
|
|
||||||
{
|
|
||||||
BucketName = "nadeko-pictures",
|
|
||||||
ContentType = "application/json",
|
|
||||||
ContentBody = uploadData,
|
|
||||||
// either use a path provided in the argument or the default one for public nadeko, other/cmds.json
|
|
||||||
Key = $"cmds/{StatsService.BotVersion}.json",
|
|
||||||
CannedACL = S3CannedACL.PublicRead
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var versionListString = "[]";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var oldVersionObject = await dlClient.GetObjectAsync(new()
|
|
||||||
{
|
|
||||||
BucketName = "nadeko-pictures",
|
|
||||||
Key = "cmds/versions.json"
|
|
||||||
});
|
|
||||||
|
|
||||||
await using var ms = new MemoryStream();
|
|
||||||
await oldVersionObject.ResponseStream.CopyToAsync(ms);
|
|
||||||
versionListString = Encoding.UTF8.GetString(ms.ToArray());
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Log.Information("No old version list found. Creating a new one");
|
|
||||||
}
|
|
||||||
|
|
||||||
var versionList = JsonSerializer.Deserialize<List<string>>(versionListString);
|
|
||||||
if (versionList is not null && !versionList.Contains(StatsService.BotVersion))
|
|
||||||
{
|
|
||||||
// save the file with new version added
|
|
||||||
// versionList.Add(StatsService.BotVersion);
|
|
||||||
versionListString = JsonSerializer.Serialize(versionList.Prepend(StatsService.BotVersion),
|
|
||||||
new JsonSerializerOptions
|
|
||||||
{
|
|
||||||
WriteIndented = true
|
|
||||||
});
|
|
||||||
|
|
||||||
// upload the updated version list
|
|
||||||
using var client = new AmazonS3Client(accessKey, secretAcccessKey, config);
|
|
||||||
await client.PutObjectAsync(new()
|
|
||||||
{
|
|
||||||
BucketName = "nadeko-pictures",
|
|
||||||
ContentType = "application/json",
|
|
||||||
ContentBody = versionListString,
|
|
||||||
// either use a path provided in the argument or the default one for public nadeko, other/cmds.json
|
|
||||||
Key = "cmds/versions.json",
|
|
||||||
CannedACL = S3CannedACL.PublicRead
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Warning(
|
|
||||||
"Version {Version} already exists in the version file. " + "Did you forget to increment it?",
|
|
||||||
StatsService.BotVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// also send the file, but indented one, to chat
|
|
||||||
await using var rDataStream = new MemoryStream(Encoding.ASCII.GetBytes(readableData));
|
await using var rDataStream = new MemoryStream(Encoding.ASCII.GetBytes(readableData));
|
||||||
await ctx.Channel.SendFileAsync(rDataStream, "cmds.json", GetText(strs.commandlist_regen));
|
await ctx.Channel.SendFileAsync(rDataStream, "cmds.json", GetText(strs.commandlist_regen));
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<Publish>True</Publish>
|
<Publish>True</Publish>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="AWSSDK.S3" Version="3.7.307"/>
|
|
||||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6"/>
|
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6"/>
|
||||||
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
|
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
|
||||||
<PackageReference Include="Discord.Net" Version="3.204.0"/>
|
<PackageReference Include="Discord.Net" Version="3.204.0"/>
|
||||||
@@ -93,7 +92,7 @@
|
|||||||
<PackageReference Include="linq2db.EntityFrameworkCore" Version="8.1.0"/>
|
<PackageReference Include="linq2db.EntityFrameworkCore" Version="8.1.0"/>
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4"/>
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4"/>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2"/>
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4"/>
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>
|
||||||
|
|
||||||
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3"/>
|
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3"/>
|
||||||
|
Reference in New Issue
Block a user