mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 10:23:59 +00:00
account delete command
This commit is contained in:
@@ -222,9 +222,16 @@ public class HelpTextCHS
|
|||||||
public class AccountTextCHS
|
public class AccountTextCHS
|
||||||
{
|
{
|
||||||
public string Desc => "管理 SDK 登录使用的账号映射";
|
public string Desc => "管理 SDK 登录使用的账号映射";
|
||||||
public string Usage => "用法: /account create <邮箱> <UID>";
|
public string Usage =>
|
||||||
|
"用法: /account create <邮箱> <UID>\n" +
|
||||||
|
"用法: /account delete <邮箱|UID>\n" +
|
||||||
|
"用法: /account list";
|
||||||
public string Created => "已创建账号映射: {0} -> UID {1}";
|
public string Created => "已创建账号映射: {0} -> UID {1}";
|
||||||
public string CreateFailed => "创建账号映射失败: {0}";
|
public string CreateFailed => "创建账号映射失败: {0}";
|
||||||
|
public string Deleted => "已删除账号映射: {0} -> UID {1}";
|
||||||
|
public string DeleteFailed => "删除账号映射失败: {0}";
|
||||||
|
public string DeleteOnline => "账号在线时无法删除: {0} -> UID {1}";
|
||||||
|
public string NotFound => "未找到账号: {0}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -222,9 +222,16 @@ public class HelpTextCHT
|
|||||||
public class AccountTextCHT
|
public class AccountTextCHT
|
||||||
{
|
{
|
||||||
public string Desc => "管理 SDK 登入使用的帳號映射";
|
public string Desc => "管理 SDK 登入使用的帳號映射";
|
||||||
public string Usage => "用法: /account create <郵箱> <UID>";
|
public string Usage =>
|
||||||
|
"用法: /account create <郵箱> <UID>\n" +
|
||||||
|
"用法: /account delete <郵箱|UID>\n" +
|
||||||
|
"用法: /account list";
|
||||||
public string Created => "已建立帳號映射: {0} -> UID {1}";
|
public string Created => "已建立帳號映射: {0} -> UID {1}";
|
||||||
public string CreateFailed => "建立帳號映射失敗: {0}";
|
public string CreateFailed => "建立帳號映射失敗: {0}";
|
||||||
|
public string Deleted => "已刪除帳號映射: {0} -> UID {1}";
|
||||||
|
public string DeleteFailed => "刪除帳號映射失敗: {0}";
|
||||||
|
public string DeleteOnline => "帳號在線時無法刪除: {0} -> UID {1}";
|
||||||
|
public string NotFound => "未找到帳號: {0}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -188,9 +188,16 @@ public class HelpTextEN
|
|||||||
public class AccountTextEN
|
public class AccountTextEN
|
||||||
{
|
{
|
||||||
public string Desc => "Manage account mappings for SDK logins";
|
public string Desc => "Manage account mappings for SDK logins";
|
||||||
public string Usage => "Usage: /account create <email> <uid>";
|
public string Usage =>
|
||||||
|
"Usage: /account create <email> <uid>\n" +
|
||||||
|
"Usage: /account delete <email|uid>\n" +
|
||||||
|
"Usage: /account list";
|
||||||
public string Created => "Created account mapping: {0} -> UID {1}";
|
public string Created => "Created account mapping: {0} -> UID {1}";
|
||||||
public string CreateFailed => "Failed to create account mapping: {0}";
|
public string CreateFailed => "Failed to create account mapping: {0}";
|
||||||
|
public string Deleted => "Deleted account mapping: {0} -> UID {1}";
|
||||||
|
public string DeleteFailed => "Failed to delete account mapping: {0}";
|
||||||
|
public string DeleteOnline => "Cannot delete account while online: {0} -> UID {1}";
|
||||||
|
public string NotFound => "Account not found: {0}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using MikuSB.Database;
|
|||||||
using MikuSB.Database.Account;
|
using MikuSB.Database.Account;
|
||||||
using MikuSB.Enums.Player;
|
using MikuSB.Enums.Player;
|
||||||
using MikuSB.Internationalization;
|
using MikuSB.Internationalization;
|
||||||
|
using MikuSB.GameServer.Server;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Command.Commands;
|
namespace MikuSB.GameServer.Command.Commands;
|
||||||
@@ -37,6 +38,42 @@ public class CommandAccount : ICommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandMethod("delete")]
|
||||||
|
public async ValueTask Delete(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckArgCnt(1))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var identifier = arg.Args[0].Trim();
|
||||||
|
var account = int.TryParse(identifier, out var uid) && uid > 0
|
||||||
|
? AccountData.GetAccountByUid(uid)
|
||||||
|
: AccountData.GetAccountByUserName(identifier);
|
||||||
|
|
||||||
|
if (account == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.NotFound", identifier));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Listener.GetActiveConnection(account.Uid) != null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.DeleteOnline", account.Username,
|
||||||
|
account.Uid.ToString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountData.DeleteAccount(account.Uid);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.Deleted", account.Username,
|
||||||
|
account.Uid.ToString()));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.DeleteFailed", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[CommandMethod("list")]
|
[CommandMethod("list")]
|
||||||
public async ValueTask List(CommandArg arg)
|
public async ValueTask List(CommandArg arg)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user