@@ -40,12 +40,20 @@ struct command_result
40
40
string_view msgtype {" m.notice" };
41
41
};
42
42
43
+ conf::item<bool >
44
+ command_typing
45
+ {
46
+ { " name" , " ircd.m.command.typing" },
47
+ { " default" , false },
48
+ };
49
+
43
50
static command_result
44
51
execute_command (const mutable_buffer &buf,
45
52
const m::user &user,
46
53
const m::room &room,
47
54
const string_view &cmd,
48
- const m::event::id &reply_to);
55
+ const m::event::id &reply_to,
56
+ const bool public_response);
49
57
50
58
void
51
59
handle_command (const m::event &event,
153
161
154
162
const auto &[html, alt, msgtype]
155
163
{
156
- execute_command (buf, user, room_id, cmd, reply_id)
164
+ execute_command (buf, user, room_id, cmd, reply_id, public_response )
157
165
};
158
166
159
167
if (!html && !alt)
@@ -307,9 +315,30 @@ execute_command(const mutable_buffer &buf,
307
315
const m::user &user,
308
316
const m::room &room,
309
317
const string_view &cmd,
310
- const m::event::id &reply_id)
318
+ const m::event::id &reply_id,
319
+ const bool public_response)
311
320
try
312
321
{
322
+ m::typing::edu typing
323
+ {
324
+ { " room_id" , room.room_id },
325
+ { " typing" , true },
326
+ { " user_id" , user.user_id },
327
+ { " timeout" , (30000ms).count () },
328
+ };
329
+
330
+ if (public_response && command_typing)
331
+ m::typing::commit{typing};
332
+
333
+ const unwind done_typing{[&]
334
+ {
335
+ if (public_response && command_typing)
336
+ {
337
+ json::get<" typing" _>(typing) = false ;
338
+ m::typing::commit{typing};
339
+ }
340
+ }};
341
+
313
342
if (startswith (cmd, ' #' ))
314
343
return command__control (buf, user, room, lstrip (cmd, ' #' ));
315
344
0 commit comments