aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-08-02 10:13:51 -0400
committerZoffix Znet <cpan@zoffix.com>2016-08-02 10:13:51 -0400
commited6c6f01bd563df1c4f7ec1a7e6262bffb6c24cc (patch)
tree22d90e1c9fa9d271849bd53f605b73b66e9934e6
parent5d193e0c18f747f2f4f71d068f1baa31f94fe3aa (diff)
Add support for channel passwords
Closes #18
-rw-r--r--Changes1
-rw-r--r--docs/01-basics.md2
-rw-r--r--docs/03-method-reference.md14
-rw-r--r--lib/IRC/Client.pm63
-rw-r--r--lib/IRC/Client/Server.pm62
5 files changed, 16 insertions, 6 deletions
diff --git a/Changes b/Changes
index dda35bd..440878c 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for IRC::Client
unreleased
- Make nick grammar looser to match real-world use rather than RFC (#19)
- Fix missing user/channel info in debug output for PRIVMSG/NOTICE messages
+ - Add support for channel passwords (#18)
3.0003006 2016-07-31
- Fix issue with giving multiple values to channels
diff --git a/docs/01-basics.md b/docs/01-basics.md
index 5aabaca..d7ce0b4 100644
--- a/docs/01-basics.md
+++ b/docs/01-basics.md
@@ -86,7 +86,7 @@ the original message, prefixed with `You said `.
.run with IRC::Client.new:
:host<irc.freenode.net>
- :channels<#perl6bot #zofbot>
+ :channels('#perl6bot', '#zofbot', '#myown' => 's3cret')
:debug
:plugins(
class { method irc-to-me ($e) { "You said $e.text()"} }
diff --git a/docs/03-method-reference.md b/docs/03-method-reference.md
index 7b6ddb6..9c5f1fa 100644
--- a/docs/03-method-reference.md
+++ b/docs/03-method-reference.md
@@ -345,8 +345,9 @@ The label of this server.
#### `.channels`
-A list of strings containing all the channels the client is in on this
-server.
+A list of `Str` or `Pair` containing all the channels the client is in on this
+server. Pairs represent channels with channel passwords, where the key is
+the channel and the value is its password.
#### `.nick`
@@ -463,7 +464,14 @@ Instantiates a new `IRC::Client` object. Takes the following named arguments:
##### `:channels`
-A list of IRC channels to join. **Defaults to:** `#perl6`
+```perl6
+ :channels('#perl6bot', '#zofbot', '#myown' => 's3cret')
+```
+
+A list of `Str` or `Pair` containing the channels to join.
+Pairs represent channels with channel passwords, where the key is
+the channel and the value is its password.
+**Defaults to:** `#perl6`
##### `:debug`
diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6
index f2f73a7..486bfcd 100644
--- a/lib/IRC/Client.pm6
+++ b/lib/IRC/Client.pm6
@@ -75,7 +75,8 @@ submethod BUILD (
}
method join (*@channels, :$server) {
- self.send-cmd: 'JOIN', $_, :$server for @channels;
+ self.send-cmd: 'JOIN', ($_ ~~ Pair ?? .kv !! .Str), :$server
+ for @channels;
self;
}
diff --git a/lib/IRC/Client/Server.pm6 b/lib/IRC/Client/Server.pm6
index 1857fcc..f438d6d 100644
--- a/lib/IRC/Client/Server.pm6
+++ b/lib/IRC/Client/Server.pm6
@@ -1,6 +1,6 @@
unit class IRC::Client::Server;
-has @.channels where .all ~~ Str;
+has @.channels where .all ~~ Str|Pair;
has @.nick where .all ~~ Str;
has Int $.port where 0 <= $_ <= 65535;
has Str $.label;