From 52fd4ea8bad5cd7d3940a41df4f8f54b4e72beae Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 7 Dec 2024 17:24:25 +0500 Subject: feat: a special class for command responses --- bot/src/handlers.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'bot/src/handlers.cpp') diff --git a/bot/src/handlers.cpp b/bot/src/handlers.cpp index c7820b4..e764652 100644 --- a/bot/src/handlers.cpp +++ b/bot/src/handlers.cpp @@ -36,18 +36,12 @@ namespace bot::handlers { auto response = command_loader.run(bundle, request.value()); if (response.has_value()) { - try { - auto str = std::get(*response); - bundle.irc_client.say(message.source.login, str); - } catch (const std::exception &e) { - } - - try { - auto strs = std::get>(*response); - for (const std::string &str : strs) { - bundle.irc_client.say(message.source.login, str); + if (response->is_single()) { + bundle.irc_client.say(message.source.login, response->get_single()); + } else if (response->is_multiple()) { + for (const std::string &msg : response->get_multiple()) { + bundle.irc_client.say(message.source.login, msg); } - } catch (const std::exception &e) { } } } catch (const std::exception &e) { -- cgit v1.2.3