mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
Merge branch 'v5' of https://gitlab.com/Kwoth/nadekobot into v5
This commit is contained in:
@@ -13,19 +13,14 @@ w# Setting up NadekoBot on Linux
|
|||||||
|
|
||||||
#### Operating System Compatibility
|
#### Operating System Compatibility
|
||||||
|
|
||||||
It is recommended that you use **Ubuntu 20.04**, as there have been nearly no problems with it. Also, **32-bit systems are incompatible**.
|
|
||||||
|
|
||||||
|
|
||||||
### Ubuntu 22.04 is ruled as incompatible so double check which ubuntu version you are using.
|
|
||||||
|
|
||||||
##### Compatible operating systems:
|
##### Compatible operating systems:
|
||||||
|
|
||||||
- Ubuntu: 16.04, 18.04, 20.04
|
- Ubuntu: 18.04, 20.04, 22.04, 22.10
|
||||||
- Mint: 19, 20
|
- Mint: 19, 20, 21
|
||||||
- Debian: 10, 11
|
- Debian: 10, 11
|
||||||
- CentOS: 7
|
- CentOS: 7
|
||||||
- openSUSE
|
- openSUSE 15
|
||||||
- Fedora: 33, 34, 35
|
- ~~Fedora: 33, 34, 35~~ (Fedora is Pending Support)
|
||||||
|
|
||||||
## Linux From Source
|
## Linux From Source
|
||||||
|
|
||||||
|
@@ -10,11 +10,9 @@
|
|||||||
|
|
||||||
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
|
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
|
||||||
|
|
||||||
*If you have Windows 7 or a 32-bit system, please refer to the [From Source](#windows-from-source)) guide.*
|
|
||||||
|
|
||||||
#### Prerequisites
|
#### Prerequisites
|
||||||
|
|
||||||
- Windows 8 or later (64-bit)
|
- Windows 10 or later (64-bit)
|
||||||
- [Create a Discord Bot application and invite the bot to your server](../creds-guide.md)
|
- [Create a Discord Bot application and invite the bot to your server](../creds-guide.md)
|
||||||
|
|
||||||
**Optional**
|
**Optional**
|
||||||
@@ -31,10 +29,8 @@
|
|||||||

|

|
||||||
- Click on **`DOWNLOAD`** at the lower right
|
- Click on **`DOWNLOAD`** at the lower right
|
||||||

|

|
||||||
- Click on **`Install`** next to **`Redis`**.
|
- **Note: Redis is optional. install Redis manually here: [Redis] Download and run the **`.msi`** file.**
|
||||||
- **(Note: Redis is optional unless you are are using the bot on 2000+ servers)**
|
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DLP`**.
|
||||||
- Note: If Redis fails to install, install Redis manually here: [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) Download and run the **`.msi`** file.
|
|
||||||
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DL`**.
|
|
||||||
- If any dependencies fail to install, you can temporarily disable your Windows Defender/AV until you install them. If you don't want to, then read [the last section of this guide](#Manual-Prerequisite-Installation).
|
- If any dependencies fail to install, you can temporarily disable your Windows Defender/AV until you install them. If you don't want to, then read [the last section of this guide](#Manual-Prerequisite-Installation).
|
||||||
- When installation is finished, click on **`CREDS`** to the left of **`RUN`** at the lower right.
|
- When installation is finished, click on **`CREDS`** to the left of **`RUN`** at the lower right.
|
||||||
- Follow the guide on how to [Set up the creds.yml](../../creds-guide) file.
|
- Follow the guide on how to [Set up the creds.yml](../../creds-guide) file.
|
||||||
@@ -60,9 +56,9 @@
|
|||||||
|
|
||||||
You can still install them manually:
|
You can still install them manually:
|
||||||
|
|
||||||
- [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) - Download and run the **`.msi`** file
|
- [Redis] (OPTIONAL) - Download and run the **`.msi`** file
|
||||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, then just move the `ffmpeg.exe` file to NadekoBot/system
|
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, then just move the `ffmpeg.exe` file to NadekoBot/system
|
||||||
- [youtube-dl] - Click to download the file. Then put `youtube-dl.exe` in a path that's in your PATH environment variable. If you don't know what that is, then just move the `youtube-dl.exe` file to NadekoBot/system
|
- [youtube-dlp] - Click to download the `yt-dlp.exe` file then put `yt-dlp.exe` in a path that's in your PATH environment variable. If you don't know what that is, then just move the `yt-dlp.exe` file to NadekoBot/system
|
||||||
|
|
||||||
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
||||||
|
|
||||||
@@ -71,15 +67,15 @@ You can still install them manually:
|
|||||||
##### Prerequisites
|
##### Prerequisites
|
||||||
|
|
||||||
**Install these before proceeding or your bot will not work!**
|
**Install these before proceeding or your bot will not work!**
|
||||||
- [.net 6](https://dotnet.microsoft.com/download/dotnet/6.0) - needed to compile and run the bot
|
- [.net 7](https://dotnet.microsoft.com/en-us/download) - needed to compile and run the bot
|
||||||
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
||||||
- [redis](https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi) - to cache things needed by some features and persist through restarts
|
- [Redis] (OPTIONAL)- to cache things needed by some features and persist through restarts
|
||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
||||||
|
|
||||||
1. `git clone https://gitlab.com/kwoth/nadekobot -b v4 --depth 1`
|
1. `git clone https://gitlab.com/kwoth/nadekobot -b v5 --depth 1`
|
||||||
2. `cd nadekobot`
|
2. `cd nadekobot`
|
||||||
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
||||||
4. `cd output`
|
4. `cd output`
|
||||||
@@ -119,16 +115,14 @@ Open PowerShell as described above and run the following commands:
|
|||||||
🎉 Enjoy
|
🎉 Enjoy
|
||||||
|
|
||||||
#### Music prerequisites
|
#### Music prerequisites
|
||||||
In order to use music commands, you need ffmpeg and youtube-dl installed.
|
In order to use music commands, you need ffmpeg and yt-dlp installed.
|
||||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
||||||
- [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`.
|
- [youtube-dlp] - Click to download the `yt-dlp.exe` file, then move `yt-dlp.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `yt-dlp.exe` file to `NadekoBot/system`.
|
||||||
|
|
||||||
[Updater]: https://dl.nadeko.bot/
|
[Updater]: https://dl.nadeko.bot/
|
||||||
[Notepad++]: https://notepad-plus-plus.org/
|
|
||||||
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0
|
|
||||||
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
||||||
[Visual C++ 2010 (x86)]: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe
|
[Visual C++ 2010 (x86)]: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe
|
||||||
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
||||||
[ffmpeg-32bit]: https://cdn.nadeko.bot/dl/ffmpeg-32.zip
|
[ffmpeg-32bit]: https://cdn.nadeko.bot/dl/ffmpeg-32.zip
|
||||||
[ffmpeg-64bit]: https://cdn.nadeko.bot/dl/ffmpeg-64.zip
|
[ffmpeg-64bit]: https://cdn.nadeko.bot/dl/ffmpeg-64.zip
|
||||||
[youtube-dl]: https://yt-dl.org/downloads/latest/youtube-dl.exe
|
[youtube-dlp]: https://github.com/yt-dlp/yt-dlp/releases
|
||||||
|
@@ -7,9 +7,6 @@ using NadekoBot.Db;
|
|||||||
using NadekoBot.Modules.Utility;
|
using NadekoBot.Modules.Utility;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Extensions.Conventions;
|
|
||||||
using Ninject.Extensions.Conventions.Syntax;
|
|
||||||
using Ninject.Infrastructure.Language;
|
|
||||||
using Ninject.Planning;
|
using Ninject.Planning;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -140,24 +137,7 @@ public sealed class Bot
|
|||||||
kernel.Bind<ICoordinator, IReadyExecutor>().To<RemoteGrpcCoordinator>().InSingletonScope();
|
kernel.Bind<ICoordinator, IReadyExecutor>().To<RemoteGrpcCoordinator>().InSingletonScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel.Bind(scan =>
|
kernel.AddLifetimeServices();
|
||||||
{
|
|
||||||
scan.FromThisAssembly()
|
|
||||||
.SelectAllClasses()
|
|
||||||
.Where(c => (c.IsAssignableTo(typeof(INService))
|
|
||||||
|| c.IsAssignableTo(typeof(IExecOnMessage))
|
|
||||||
|| c.IsAssignableTo(typeof(IInputTransformer))
|
|
||||||
|| c.IsAssignableTo(typeof(IExecPreCommand))
|
|
||||||
|| c.IsAssignableTo(typeof(IExecPostCommand))
|
|
||||||
|| c.IsAssignableTo(typeof(IExecNoCommand)))
|
|
||||||
&& !c.HasAttribute<DontAddToIocContainerAttribute>()
|
|
||||||
#if GLOBAL_NADEK
|
|
||||||
&& !c.HasAttribute<NoPublicBotAttribute>()
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
.BindToSelfWithInterfaces()
|
|
||||||
.Configure(c => c.InSingletonScope());
|
|
||||||
});
|
|
||||||
|
|
||||||
kernel.Bind<IServiceProvider>().ToConstant(kernel).InSingletonScope();
|
kernel.Bind<IServiceProvider>().ToConstant(kernel).InSingletonScope();
|
||||||
|
|
||||||
@@ -339,6 +319,7 @@ public sealed class Bot
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(toExec.GetType().FullName);
|
||||||
await toExec.OnReadyAsync();
|
await toExec.OnReadyAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@@ -18,6 +18,7 @@ public sealed record MedusaStats(string Name,
|
|||||||
IReadOnlyCollection<SnekStats> Sneks);
|
IReadOnlyCollection<SnekStats> Sneks);
|
||||||
|
|
||||||
public sealed record SnekStats(string Name,
|
public sealed record SnekStats(string Name,
|
||||||
|
string? Prefix,
|
||||||
IReadOnlyCollection<SnekCommandStats> Commands);
|
IReadOnlyCollection<SnekCommandStats> Commands);
|
||||||
|
|
||||||
public sealed record SnekCommandStats(string Name);
|
public sealed record SnekCommandStats(string Name);
|
@@ -79,7 +79,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
|
|||||||
commands.Add(new SnekCommandStats(command.Aliases.First()));
|
commands.Add(new SnekCommandStats(command.Aliases.First()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sneks.Add(new SnekStats(snekInfos.Name, commands));
|
sneks.Add(new SnekStats(snekInfos.Name, snekInfos.Instance.Prefix, commands));
|
||||||
}
|
}
|
||||||
|
|
||||||
toReturn.Add(new MedusaStats(name, resolvedData.Strings.GetDescription(culture), sneks));
|
toReturn.Add(new MedusaStats(name, resolvedData.Strings.GetDescription(culture), sneks));
|
||||||
|
@@ -150,9 +150,10 @@ public partial class Medusa : NadekoModule<IMedusaLoaderService>
|
|||||||
|
|
||||||
var cmdCount = found.Sneks.Sum(x => x.Commands.Count);
|
var cmdCount = found.Sneks.Sum(x => x.Commands.Count);
|
||||||
var cmdNames = found.Sneks
|
var cmdNames = found.Sneks
|
||||||
.SelectMany(x => x.Commands)
|
.SelectMany(x => Format.Code(string.IsNullOrWhiteSpace(x.Prefix)
|
||||||
.Select(x => Format.Code(x.Name))
|
? x.Name
|
||||||
.Join(" | ");
|
: $"{x.Prefix} {x.Name}"))
|
||||||
|
.Join("\n");
|
||||||
|
|
||||||
var eb = _eb.Create(ctx)
|
var eb = _eb.Create(ctx)
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
|
@@ -60,6 +60,7 @@ public class CommandHandler : INService, IReadyExecutor
|
|||||||
|
|
||||||
public async Task OnReadyAsync()
|
public async Task OnReadyAsync()
|
||||||
{
|
{
|
||||||
|
Log.Information("Command handler runnning on ready");
|
||||||
// clear users on short cooldown every GLOBAL_COMMANDS_COOLDOWN miliseconds
|
// clear users on short cooldown every GLOBAL_COMMANDS_COOLDOWN miliseconds
|
||||||
using var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(GLOBAL_COMMANDS_COOLDOWN));
|
using var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(GLOBAL_COMMANDS_COOLDOWN));
|
||||||
while (await timer.WaitForNextTickAsync())
|
while (await timer.WaitForNextTickAsync())
|
||||||
|
@@ -9,6 +9,8 @@ using Ninject.Extensions.Conventions.Syntax;
|
|||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using NadekoBot.Common.ModuleBehaviors;
|
||||||
|
using Ninject.Infrastructure.Language;
|
||||||
|
|
||||||
namespace NadekoBot.Extensions;
|
namespace NadekoBot.Extensions;
|
||||||
|
|
||||||
@@ -125,4 +127,25 @@ public static class ServiceCollectionExtensions
|
|||||||
|
|
||||||
public static IConfigureSyntax BindToSelfWithInterfaces(this IJoinExcludeIncludeBindSyntax matcher)
|
public static IConfigureSyntax BindToSelfWithInterfaces(this IJoinExcludeIncludeBindSyntax matcher)
|
||||||
=> matcher.BindSelection((type, types) => types.Append(type));
|
=> matcher.BindSelection((type, types) => types.Append(type));
|
||||||
|
|
||||||
|
public static IKernel AddLifetimeServices(this IKernel kernel)
|
||||||
|
{
|
||||||
|
Assembly.GetExecutingAssembly()
|
||||||
|
.ExportedTypes
|
||||||
|
.Where(x => x.IsPublic && x.IsClass && !x.IsAbstract)
|
||||||
|
.Where(c => (c.IsAssignableTo(typeof(INService))
|
||||||
|
|| c.IsAssignableTo(typeof(IExecOnMessage))
|
||||||
|
|| c.IsAssignableTo(typeof(IInputTransformer))
|
||||||
|
|| c.IsAssignableTo(typeof(IExecPreCommand))
|
||||||
|
|| c.IsAssignableTo(typeof(IExecPostCommand))
|
||||||
|
|| c.IsAssignableTo(typeof(IExecNoCommand)))
|
||||||
|
&& !c.HasAttribute<DontAddToIocContainerAttribute>()
|
||||||
|
#if GLOBAL_NADEKO
|
||||||
|
&& !c.HasAttribute<NoPublicBotAttribute>()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
return kernel;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user