[Discord] Add Discord webhook callback processing to world (#3322)

This commit is contained in:
Chris Miles
2023-04-29 19:49:06 -05:00
committed by GitHub
parent 95b306599f
commit ecf2a369cc
3 changed files with 31 additions and 0 deletions
+17
View File
@@ -300,6 +300,8 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
->SetLogPath(path.GetLogPath())
->LoadLogDatabaseSettings();
LogSys.SetDiscordHandler(&WorldBoot::DiscordWebhookMessageHandler);
if (!ignore_db) {
LogInfo("Checking Database Conversions");
database.CheckDatabaseConversions();
@@ -662,3 +664,18 @@ void WorldBoot::Shutdown()
safe_delete(mutex);
}
void WorldBoot::SendDiscordMessage(int webhook_id, const std::string &message)
{
if (UCSLink.IsConnected()) {
auto pack = new ServerPacket(ServerOP_DiscordWebhookMessage, sizeof(DiscordWebhookMessage_Struct) + 1);
auto *q = (DiscordWebhookMessage_Struct *) pack->pBuffer;
strn0cpy(q->message, message.c_str(), 2000);
q->webhook_id = webhook_id;
UCSLink.SendPacket(pack);
safe_delete(pack);
}
}