49 const auto &input =
event.input;
51 if (input ==
"/help") {
55 if (input ==
"/peers") {
59 if (input ==
"/status") {
63 if (input ==
"/sessions") {
67 if (input ==
"/scan") {
71 if (input ==
"/version") {
75 if (input ==
"/identities") {
79 if (input ==
"/publish") {
83 if (input ==
"/unpublish") {
88 constexpr auto mode_cmd =
"/mode ";
89 if (input.starts_with(mode_cmd)) {
90 command_handler_->handle(
events::mode{ .
new_mode = input.substr(std::string_view(mode_cmd).length()) });
94 constexpr auto send_cmd =
"/send ";
95 if (input.starts_with(send_cmd)) {
96 const auto args = input.substr(std::string_view(send_cmd).length());
97 const auto first_space = args.find(
' ');
98 if (first_space != std::string::npos and not args.empty()) {
99 command_handler_->handle(
100 events::send{ .
peer = args.substr(0, first_space), .message = args.substr(first_space + 1) });
107 constexpr auto broadcast_cmd =
"/broadcast ";
108 if (input.starts_with(broadcast_cmd)) {
113 constexpr auto connect_cmd =
"/connect ";
114 if (input.starts_with(connect_cmd)) {
115 command_handler_->handle(
events::connect{ .
relay = input.substr(std::string_view(connect_cmd).length()) });
119 if (input ==
"/disconnect") {
124 constexpr auto trust_cmd =
"/trust ";
125 if (input.starts_with(trust_cmd)) {
126 const auto args = input.substr(std::string_view(trust_cmd).length());
127 const auto first_space = args.find(
' ');
128 if (first_space != std::string::npos and not args.empty()) {
129 command_handler_->handle(
130 events::trust{ .
peer = args.substr(0, first_space), .alias = args.substr(first_space + 1) });
137 constexpr auto verify_cmd =
"/verify ";
138 if (input.starts_with(verify_cmd)) {
139 command_handler_->handle(
events::verify{ .
peer = input.substr(std::string_view(verify_cmd).length()) });
143 constexpr auto chat_cmd =
"/chat ";
144 if (input.starts_with(chat_cmd)) {
145 command_handler_->handle(
events::chat{ .
contact = input.substr(std::string_view(chat_cmd).length()) });
149 if (input ==
"/leave") {