为 osu! 新人群提供各种功能服务,在其他群也可以使用一些基本的功能。
-
Ubuntu 18.04 / Docker
-
.NET 5.0 (Required)
-
MySQL / MariaDB (Required)
-
Chromium-based browser (Recommended)
- 运行好 go-cqhttp,检查并修改生成的配置文件,确保你理解并正确配置好
http_config
部分。 - 安装运行好 MySQL,确保可以连接,预留好要使用的数据库名,不要手动创建该数据库。
- 安装好 .NET 5.0 Runtime。
- (Optional, recommended) 安装一个 Chromium 内核浏览器。
- 安装最新版本的 Visual Studio,确保选中 “.NET Core 跨平台开发”。
- 运行以下命令
dotnet tool install --global dotnet-ef
- 克隆本 repo。
- 使用 Visual Studio 打开
OsuQqBotHttp.sln
,在Bleatingsheep.OsuQqBot.Database/Models
目录创建ServerInfo.cs
文件,内容如下。
namespace Bleatingsheep.OsuQqBot.Database.Models
{
internal class ServerInfo
{
public const string Server = "database.server.address";
public const int Port = 12345;
public const string Database = "database-name";
public const string User = "your-database-user";
public const string Password = "your-database-password";
}
}
- 在
Bleatingsheep.NewHydrant.Bot
项目创建HardcodedConfigure.cs
文件,内容如下。
using System;
namespace Bleatingsheep.NewHydrant
{
public sealed class HardcodedConfigure
{
public string ApiKey => "your-osu-api-key"; // osu! API key
public long SuperAdmin => 123456789; // 你的 QQ 账号(非机器人账号)
public string Listen => "http://+:8876"; // 与 go-cqhttp 配置中 `http_config.post_urls` 部分对应
public string ApiAddress => "http://cq:5700"; // 与 go-cqhttp 配置中 `http_config.host` 和 `http_config.host.port` 字段对应。
public string AccessToken => "your-access-token"; // 与 go-cqhttp 配置中 `access_token` 字段对应
public string Secret => "your-secret"; // 与 go-cqhttp 配置中 `secret` 部分对应
}
}
-
(Optional) 修改
Bleatingsheep.NewHydrant.Bot/啥玩意儿啊/Chrome.cs
文件,将ExecutablePath
改为 Chromium 内核浏览器的可执行文件位置。如果未正确设置,部分功能可能无法使用。 -
如果 MySQL 服务器未正确配置好 SSL 证书(会验证 CA 及域名是否匹配),在
Bleatingsheep.OsuQqBot.Database/Models/NewbieContext.cs
文件中删去SslMode=VerifyCA;
。 -
尝试编译
Bleatingsheep.NewHydrant.Bot
项目,根据提示消除编译错误 -
到这步还没完,先不要运行。
打开 Powershell,在 Bleatingsheep.OsuQqBot.Database
目录运行
dotnet ef migrations script
检查将要运行的 SQL 脚本,确认后运行
dotnet ef database update
创建数据库。
- 右键单击
Bleatingsheep.NewHydrant.Bot
项目,点“发布”。 - 目标选“文件夹”,然后选择合适的文件夹。
- 发布后,把该文件夹的文件全部复制到服务器上。
在服务器上打开 Powershell(或 bash 等任何 shell),运行
dotnet Bleatingsheep.NewHydrant.Bot.dll