aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-08-07 22:58:46 -0400
committerZoffix Znet <cpan@zoffix.com>2016-08-07 22:58:46 -0400
commitb1e795877f2447bc634cbb4b269f9ac8bebd67f3 (patch)
treecfc45f9e3f861f911d0d7294b9434956ad659e35 /lib
parent8bb81d24b338773f0c56916f919e0457e0182970 (diff)
Add `:alias` feature3.006001
Closes #22
Diffstat (limited to 'lib')
-rw-r--r--lib/IRC/Client.pm615
-rw-r--r--lib/IRC/Client/Server.pm61
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6
index 7dbadf9..34e6f54 100644
--- a/lib/IRC/Client.pm6
+++ b/lib/IRC/Client.pm6
@@ -41,6 +41,7 @@ submethod BUILD (
Str :$password,
Str:D :$host = 'localhost',
:$nick = ['P6Bot'],
+ :$alias = [],
Str:D :$username = 'Perl6IRC',
Str:D :$userhost = 'localhost',
Str:D :$userreal = 'Perl6 IRC Client',
@@ -50,7 +51,7 @@ submethod BUILD (
@!plugins = @$plugins;
my %servers = %$servers;
- my %all-conf = :$port, :$password, :$host, :$nick,
+ my %all-conf = :$port, :$password, :$host, :$nick, :$alias,
:$username, :$userhost, :$userreal, :$channels;
%servers = '_' => {} unless %servers;
@@ -61,6 +62,7 @@ submethod BUILD (
:$label,
:channels( @($conf<channels> // %all-conf<channels>) ),
:nick[ |($conf<nick> // %all-conf<nick>) ],
+ :alias[ |($conf<alias> // %all-conf<alias>) ],
|%(
<host password port username userhost userreal>
.map: { $_ => $conf{$_} // %all-conf{$_} }
@@ -234,11 +236,16 @@ method !handle-event ($e) {
my @events = flat gather {
given $event-name {
when 'irc-privmsg-channel' | 'irc-notice-channel' {
- my $nick = $s.current-nick;
- if $e.text.subst-mutate: /^ $nick <[,:]> \s* /, '' {
+ my $nick = $s.current-nick;
+ my @aliases = $s.alias;
+ if $e.text.subst-mutate:
+ /^ [ $nick | @aliases ] <[,:]> \s* /, ''
+ {
take 'irc-addressed', ('irc-to-me' if $s.is-connected);
}
- elsif $e.text ~~ / << $nick >> / and $s.is-connected {
+ elsif $e.text ~~ / << [ $nick | @aliases ] >> /
+ and $s.is-connected
+ {
take 'irc-mentioned';
}
take $event-name, $event-name eq 'irc-privmsg-channel'
diff --git a/lib/IRC/Client/Server.pm6 b/lib/IRC/Client/Server.pm6
index f438d6d..2ed5d69 100644
--- a/lib/IRC/Client/Server.pm6
+++ b/lib/IRC/Client/Server.pm6
@@ -2,6 +2,7 @@ unit class IRC::Client::Server;
has @.channels where .all ~~ Str|Pair;
has @.nick where .all ~~ Str;
+has @.alias where .all ~~ Str|Regex;
has Int $.port where 0 <= $_ <= 65535;
has Str $.label;
has Str $.host;