From 03c3109f2da45f2d87c51146c180302ecf24fc3d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 14 Jun 2025 23:01:32 +0200 Subject: Matrix: add /bot and /whoami commands --- src/QuickMedia.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 7cd5d8d..3a2f2f5 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -6319,7 +6319,9 @@ namespace QuickMedia { "/me [text]: Send a message of type \"m.emote\".\n" "/react [text]: React to the selected message (also works if you are replying to a message).\n" "/id: Show the room id.\n" - "/encrypt [text]: Send a message encrypted with gpg. gpg needs to be installed to do this. Uses the gpg key specified by the user id in your config variable \"matrix.gpg_user_id\"."; + "/whoami: Show your user id.\n" + "/encrypt [text]: Send a message encrypted with gpg. gpg needs to be installed to do this. Uses the gpg key specified by the user id in your config variable \"matrix.gpg_user_id\".\n" + "/bot [text]: Send a message as a bot would."; message->timestamp = time(nullptr) * 1000; // TODO: What if the user has broken local time? matrix->append_system_message(current_room, std::move(message)); @@ -6335,6 +6337,18 @@ namespace QuickMedia { message->timestamp = time(nullptr) * 1000; // TODO: What if the user has broken local time? matrix->append_system_message(current_room, std::move(message)); + chat_input.set_editable(false); + chat_state = ChatState::NAVIGATING; + matrix->get_room_extra_data(current_room).editing_message_id.clear(); + return true; + } else if(text == "/whoami") { + auto message = std::make_shared(); + message->type = MessageType::SYSTEM; + message->user = me; + message->body = me->user_id; + message->timestamp = time(nullptr) * 1000; // TODO: What if the user has broken local time? + matrix->append_system_message(current_room, std::move(message)); + chat_input.set_editable(false); chat_state = ChatState::NAVIGATING; matrix->get_room_extra_data(current_room).editing_message_id.clear(); @@ -6342,6 +6356,9 @@ namespace QuickMedia { } else if(strncmp(text.c_str(), "/me ", 4) == 0) { msgtype = "m.emote"; text.erase(text.begin(), text.begin() + 4); + } else if(strncmp(text.c_str(), "/bot ", 5) == 0) { + msgtype = "m.notice"; + text.erase(text.begin(), text.begin() + 5); } else if(strncmp(text.c_str(), "/react ", 7) == 0) { msgtype = "m.reaction"; text.erase(text.begin(), text.begin() + 7); -- cgit v1.2.3-70-g09d2