Skip to content

Commit bbcba70

Browse files
committed
Expose user list
Sort of. Method list-users will return a promise with a list of users (hopefully). If it times out it will return previous data that it had.
1 parent c897589 commit bbcba70

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Whateverable/Replaceable.pm6

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ method make-believe($msg, @nicks, &play, :$timeout = 4) {
4444
Nil
4545
}
4646

47+
method list-users($msg, $channel=$msg.channel, :$timeout = 4) {
48+
my $update-promise = Promise.new;
49+
$!update-promise-channel.send: $update-promise;
50+
$msg.irc.send-cmd: NAMES, $msg.channel;
51+
start {
52+
await Promise.anyof: $update-promise, Promise.in: $timeout;
53+
$!users-lock.protect: {
54+
%!users{$channel}.clone
55+
}
56+
}
57+
}
58+
59+
4760
method irc-n353($e) { # one or more messages
4861
my $irc-channel = $e.args[2];
4962
# Try to filter out privileges ↓

0 commit comments

Comments
 (0)