-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix numeric events being unsubscrabable due to incorrect identifiers
Fixes #31
- Loading branch information
1 parent
acd52a7
commit 4411e6f
Showing
3 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use lib <lib>; | ||
use IRC::Client; | ||
|
||
.run with IRC::Client.new: | ||
:nick<MahBot> | ||
:host(%*ENV<IRC_CLIENT_HOST> // 'irc.freenode.net') | ||
:channels<#zofbot> | ||
:2debug | ||
:plugins(class :: does IRC::Client::Plugin { | ||
my class NameLookup { has $.channel; has @.users; has $.e; } | ||
has %.lookups of NameLookup; | ||
|
||
method irc-to-me ($e where /^ 'users in ' $<channel>=\S+/) { | ||
my $channel = ~$<channel>; | ||
return 'Look up of this channel is already in progress' | ||
if %!lookups{$channel}; | ||
|
||
%!lookups{$channel} = NameLookup.new: :$channel :$e; | ||
$.irc.send-cmd: 'NAMES', $channel; | ||
Nil; | ||
} | ||
method irc-n353 ($e where so %!lookups{ $e.args[2] }) { | ||
%!lookups{ $e.args[2] }.users.append: $e.args[3].words; | ||
Nil; | ||
} | ||
method irc-n366 ($e where so %!lookups{ $e.args[1] }) { | ||
my $lookup = %!lookups{ $e.args[1] }:delete; | ||
$lookup.e.reply: "Users in $lookup.channel(): $lookup.users()[]"; | ||
Nil; | ||
} | ||
|
||
}.new) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters