mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 02:31:03 +00:00
[Discord Integration] Native Discord Integration (#2140)
* Start of discord integration work * more testing * Discord client work * More discord work * Cleanup * Handle retry timer response and max retries * Update base retry timer * Move Discord queue handler to UCS, add queuer to own thread * Post merge * Send up Zone::SendDiscordMessage * Start of discord integration work * more testing * Discord client work * More discord work * Cleanup * Move Discord queue handler to UCS, add queuer to own thread * Post merge * Push up tables * Quest API stuff. * Update 2022_05_07_discord_webhooks.sql * Post merge fixes * Push up manifest * Flip logging signs in logic from copy / paste of inverse logic before * Make sure we add new line to quest api sourced messages Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
This commit is contained in:
+35
-1
@@ -655,7 +655,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid) {
|
||||
|
||||
void Zone::GetMerchantDataForZoneLoad() {
|
||||
LogInfo("Loading Merchant Lists");
|
||||
|
||||
|
||||
auto query = fmt::format(
|
||||
SQL (
|
||||
SELECT
|
||||
@@ -1209,6 +1209,11 @@ bool Zone::Init(bool is_static) {
|
||||
//MODDING HOOK FOR ZONE INIT
|
||||
mod_init();
|
||||
|
||||
// logging origination information
|
||||
LogSys.origination_info.zone_short_name = zone->short_name;
|
||||
LogSys.origination_info.zone_long_name = zone->long_name;
|
||||
LogSys.origination_info.instance_id = zone->instanceid;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2776,3 +2781,32 @@ void Zone::SendReloadMessage(std::string reload_type)
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
void Zone::SendDiscordMessage(int webhook_id, const std::string& message)
|
||||
{
|
||||
if (worldserver.Connected()) {
|
||||
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;
|
||||
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::SendDiscordMessage(const std::string& webhook_name, const std::string &message)
|
||||
{
|
||||
bool not_found = true;
|
||||
for (auto & w : LogSys.discord_webhooks) {
|
||||
if (w.webhook_name == webhook_name) {
|
||||
SendDiscordMessage(w.id, message + "\n");
|
||||
not_found = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (not_found) {
|
||||
LogDiscord("[SendDiscordMessage] Did not find valid webhook by webhook name [{}]", webhook_name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user