mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
feature - (#1100) Linking of "trusted" accounts to allow altbot-control apart from own account or guild (#1267)
* Add table to store the security keys for accounts. * Add table to store relationships between accounts. * Add a new configuration option to enable or disable trusted account bots. * add checks for linked accounts * Handle account linking and chat commands * fix uppercase typo * change query & fix chatcommandtable * add missing functions to header * move account linking to updates dir * moved table creation to correct updates folder * use playerbots db instead of character db * fix db * fix install? * remove duplicated logic and add hashing to stored securityKey * add object before call * change chat variable * rename SQL file for correct execution order * add header include for ubuntu compatibility * remove old sql
This commit is contained in:
@@ -33,12 +33,21 @@ public:
|
||||
static ChatCommandTable playerbotsDebugCommandTable = {
|
||||
{"bg", HandleDebugBGCommand, SEC_GAMEMASTER, Console::Yes},
|
||||
};
|
||||
|
||||
static ChatCommandTable playerbotsAccountCommandTable = {
|
||||
{"setKey", HandleSetSecurityKeyCommand, SEC_PLAYER, Console::No},
|
||||
{"link", HandleLinkAccountCommand, SEC_PLAYER, Console::No},
|
||||
{"linkedAccounts", HandleViewLinkedAccountsCommand, SEC_PLAYER, Console::No},
|
||||
{"unlink", HandleUnlinkAccountCommand, SEC_PLAYER, Console::No},
|
||||
};
|
||||
|
||||
static ChatCommandTable playerbotsCommandTable = {
|
||||
{"bot", HandlePlayerbotCommand, SEC_PLAYER, Console::No},
|
||||
{"gtask", HandleGuildTaskCommand, SEC_GAMEMASTER, Console::Yes},
|
||||
{"pmon", HandlePerfMonCommand, SEC_GAMEMASTER, Console::Yes},
|
||||
{"rndbot", HandleRandomPlayerbotCommand, SEC_GAMEMASTER, Console::Yes},
|
||||
{"debug", playerbotsDebugCommandTable},
|
||||
{"account", playerbotsAccountCommandTable},
|
||||
};
|
||||
|
||||
static ChatCommandTable commandTable = {
|
||||
@@ -101,6 +110,103 @@ public:
|
||||
{
|
||||
return BGTactics::HandleConsoleCommand(handler, args);
|
||||
}
|
||||
|
||||
static bool HandleSetSecurityKeyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!args || !*args)
|
||||
{
|
||||
handler->PSendSysMessage("Usage: .playerbots account setKey <securityKey>");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
std::string key = args;
|
||||
|
||||
PlayerbotMgr* mgr = sPlayerbotsMgr->GetPlayerbotMgr(player);
|
||||
if (mgr)
|
||||
{
|
||||
mgr->HandleSetSecurityKeyCommand(player, key);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("PlayerbotMgr instance not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleLinkAccountCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!args || !*args)
|
||||
return false;
|
||||
|
||||
char* accountName = strtok((char*)args, " ");
|
||||
char* key = strtok(nullptr, " ");
|
||||
|
||||
if (!accountName || !key)
|
||||
{
|
||||
handler->PSendSysMessage("Usage: .playerbots account link <accountName> <securityKey>");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
PlayerbotMgr* mgr = sPlayerbotsMgr->GetPlayerbotMgr(player);
|
||||
if (mgr)
|
||||
{
|
||||
mgr->HandleLinkAccountCommand(player, accountName, key);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("PlayerbotMgr instance not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleViewLinkedAccountsCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
PlayerbotMgr* mgr = sPlayerbotsMgr->GetPlayerbotMgr(player);
|
||||
if (mgr)
|
||||
{
|
||||
mgr->HandleViewLinkedAccountsCommand(player);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("PlayerbotMgr instance not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleUnlinkAccountCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!args || !*args)
|
||||
return false;
|
||||
|
||||
char* accountName = strtok((char*)args, " ");
|
||||
if (!accountName)
|
||||
{
|
||||
handler->PSendSysMessage("Usage: .playerbots account unlink <accountName>");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
PlayerbotMgr* mgr = sPlayerbotsMgr->GetPlayerbotMgr(player);
|
||||
if (mgr)
|
||||
{
|
||||
mgr->HandleUnlinkAccountCommand(player, accountName);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("PlayerbotMgr instance not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_playerbots_commandscript() { new playerbots_commandscript(); }
|
||||
|
||||
Reference in New Issue
Block a user