From de3f845918d2c0b400e2e7633c419a2049740b6e Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 15 Dec 2023 01:59:19 +0100 Subject: [PATCH] fun dance (private reply for now) --- src/CMakeLists.txt | 3 +++ src/fun_commands.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++ src/fun_commands.hpp | 16 ++++++++++++++ src/main.cpp | 2 ++ 4 files changed, 71 insertions(+) create mode 100644 src/fun_commands.cpp create mode 100644 src/fun_commands.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f43e4b1..ed17f7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,9 @@ add_executable(totato ./tox_commands.hpp ./tox_commands.cpp + + ./fun_commands.hpp + ./fun_commands.cpp ) target_compile_features(totato PUBLIC cxx_std_17) diff --git a/src/fun_commands.cpp b/src/fun_commands.cpp new file mode 100644 index 0000000..5ce3626 --- /dev/null +++ b/src/fun_commands.cpp @@ -0,0 +1,50 @@ +#include "./managment_commands.hpp" + +#include +#include +//#include + +#include "./message_command_dispatcher.hpp" + +#include +//#include + +void registerFunCommands( + MessageCommandDispatcher& mcd, + ConfigModelI& conf, + Contact3Registry& cr, + RegistryMessageModel& rmm +) { + mcd.registerCommand( + "fun", "fun", + "dance", + [&](std::string_view params, Message3Handle m) -> bool { + static std::default_random_engine rng{std::random_device{}()}; + + const auto contact_from = m.get().c; + + static const std::array dances { + "DANCE", + "(~^.^)~", + "♪┌|∵|┘♪", + "~( °٢° )~", + "m/...(>.<)…m/", + "(~‾⌣‾)~", + "└[∵┌]└[ ∵ ]┘[┐∵]┘", + "♨(⋆‿⋆)♨", + "ヾ(*´∀`*)ノ", + "ლ(o◡oლ)", + "┌(★o☆)┘", + "ヘ(^_^ヘ)", + }; + rmm.sendText( + contact_from, + dances.at(rng()%dances.size()) + ); + return true; + }, + "Make totato dance.", + MessageCommandDispatcher::Perms::EVERYONE + ); +} + diff --git a/src/fun_commands.hpp b/src/fun_commands.hpp new file mode 100644 index 0000000..63fd01c --- /dev/null +++ b/src/fun_commands.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +// fwd +class MessageCommandDispatcher; +struct ConfigModelI; + +void registerFunCommands( + MessageCommandDispatcher& mcd, + ConfigModelI& conf, + Contact3Registry& cr, + RegistryMessageModel& rmm +); + diff --git a/src/main.cpp b/src/main.cpp index 1616012..e0e8a2c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,7 @@ #include "./managment_commands.hpp" #include "./config_commands.hpp" #include "./tox_commands.hpp" +#include "./fun_commands.hpp" //#include //#include @@ -247,6 +248,7 @@ int main(int argc, char** argv) { // TODO: finish impl //registerConfigCommands(mcd, conf, cr, rmm); registerToxCommands(mcd, conf, cr, rmm, tc, tpi); + registerFunCommands(mcd, conf, cr, rmm); conf.dump();