diff options
| author | ilotterytea <iltsu@alright.party> | 2025-07-03 23:12:11 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-07-03 23:12:11 +0500 |
| commit | ea5210e15bd7a19367e4cdbb97688b0905946964 (patch) | |
| tree | c2aef7757950931331b5d9ccbe05a0fafe8a9fc5 | |
| parent | ada1621a841de3e86fdd2d2ef930d595fea1f714 (diff) | |
upd: huge changes in actions table
| -rw-r--r-- | bot/src/commands/command.cpp | 17 | ||||
| -rw-r--r-- | migrations/2024-05-11T02-53-05_init/up.sql | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/bot/src/commands/command.cpp b/bot/src/commands/command.cpp index 2d34212..50cef59 100644 --- a/bot/src/commands/command.cpp +++ b/bot/src/commands/command.cpp @@ -18,6 +18,7 @@ #include "database.hpp" #include "request.hpp" #include "response.hpp" +#include "utils/string.hpp" namespace bot { namespace command { @@ -122,14 +123,24 @@ namespace bot { arguments += request.message.value(); } + Response response = (*command)->run(bundle, request); + + std::string response_action; + if (response.is_single()) { + response_action = response.get_single(); + } else if (response.is_multiple()) { + auto &v = response.get_multiple(); + response_action = utils::string::str(v.begin(), v.end(), '\n'); + } + conn->exec( "INSERT INTO actions(user_id, channel_id, command, arguments, " - "full_message) VALUES ($1, $2, $3, $4, $5)", + "response) VALUES ($1, $2, $3, $4, $5)", {std::to_string(request.requester.user.get_id()), std::to_string(request.requester.channel.get_id()), - request.command_id, arguments, request.irc_message.message}); + request.command_id, arguments, response_action}); - return (*command)->run(bundle, request); + return response; } } } diff --git a/migrations/2024-05-11T02-53-05_init/up.sql b/migrations/2024-05-11T02-53-05_init/up.sql index afb26b7..b33f1e4 100644 --- a/migrations/2024-05-11T02-53-05_init/up.sql +++ b/migrations/2024-05-11T02-53-05_init/up.sql @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS actions ( channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE, command TEXT NOT NULL, arguments TEXT, - full_message TEXT NOT NULL, + response TEXT, sent_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP ); |
