From fbdcd2ee71d1aa32eedc55e17adf57a39e0974b2 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 8 May 2022 23:40:11 -0300 Subject: Modernize unlinking as well, and prepare to get Discord numeric ID laterâ„¢ The numeric ID allows you to change nickname without updating anything MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logmaster.py | 8 ++++++++ npc/commands/discord.txt | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/logmaster.py b/logmaster.py index 89071ffa3..a8afa075e 100755 --- a/logmaster.py +++ b/logmaster.py @@ -185,6 +185,14 @@ while running: w.execute(bf) #stdout("Query OK: %s" % bf) bf="" + ## Command: DISCORDID + ## Description: Replaces "?" with the Discord ID + ## For the associated argument. + ## Requires the API (WIP) + elif cmd == "DISCORDID": + ## FIXME: Query the API + bf=bf.replace("?%s" % cmd.replace("DISCORDID", ""), "") + pass ## Command: PING ## Description: Does nothing elif cmd == "PING": diff --git a/npc/commands/discord.txt b/npc/commands/discord.txt index 963acb4b3..a5773af77 100644 --- a/npc/commands/discord.txt +++ b/npc/commands/discord.txt @@ -91,8 +91,9 @@ OnCall: // Run SQL query (will halt execution on dupe) if (.@link) { if ($@HAS_API) { - apiasync("SQL", sprintf("UPDATE `discord` SET `discord_name` = '?1', `verified` = '0', `discord_id` = '' WHERE `account_id`='%d'", getcharid(3))); + apiasync("SQL", sprintf("UPDATE `discord` SET `discord_name` = '?1', `verified` = '0', `discord_id` = '?2' WHERE `account_id`='%d'", getcharid(3))); apiasync("SAD1", .@discord$); + apiasync("DISCORDID2", .@discord$); apiasync("SQLRUN", ""); } else { query_sql(sprintf("UPDATE `discord` SET `discord_name` = '%s', `verified` = '0', `discord_id` = '' WHERE `account_id`='%d'", @@ -100,8 +101,9 @@ OnCall: } } else { if ($@HAS_API) { - apiasync("SQL", sprintf("INSERT INTO `discord` (`discord_name`, `verified`, `discord_id`, `account_id`) VALUES ('?1', '0', '', '%d')", getcharid(3))); + apiasync("SQL", sprintf("INSERT INTO `discord` (`discord_name`, `verified`, `discord_id`, `account_id`) VALUES ('?1', '0', '?2', '%d')", getcharid(3))); apiasync("SAD1", .@discord$); + apiasync("DISCORDID2", .@discord$); apiasync("SQLRUN", ""); } else { query_sql(sprintf("INSERT INTO `discord` (`discord_name`, `verified`, `discord_id`, `account_id`) VALUES ('%s', '0', '', '%d')", @@ -126,10 +128,15 @@ OnCall: break; ///////////////////////////////////////////////////////////////////// case 2: - query_sql("DELETE FROM `discord` WHERE `account_id`='"+getcharid(3)+"'"); + if ($@HAS_API) { + apiasync("SQL", sprintf("DELETE FROM `discord` WHERE `account_id`='%d'", getcharid(3))); + apiasync("SQLRUN", ""); + } else { + query_sql("DELETE FROM `discord` WHERE `account_id`='"+getcharid(3)+"'"); + // Prevent setting a new linking right away + DISCTRL=gettimeparam(GETTIME_DAYOFMONTH)+1; + } .@discord$=""; - // Prevent setting a new linking right away - DISCTRL=gettimeparam(GETTIME_DAYOFMONTH)+1; // Update Cache htput(.discmem, str(getcharid(3)), ""); // TODO: Remove Adventurer role? -- cgit v1.2.3-60-g2f50