aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-07-28 22:52:25 -0400
committerZoffix Znet <cpan@zoffix.com>2016-07-28 22:52:25 -0400
commitcf80b1b4392b849cb5529c1a40083170098f6460 (patch)
treeb3a322c2c6dabd2ad31af74face9135ddb899445
parent92e16c5d823c16267b42ae9ea056f931cec96de4 (diff)
Docs
-rw-r--r--docs/01-basics.md4
-rw-r--r--docs/02-event-reference.md48
-rw-r--r--docs/03-method-reference.md6
-rw-r--r--lib/IRC/Client.pm62
4 files changed, 60 insertions, 0 deletions
diff --git a/docs/01-basics.md b/docs/01-basics.md
index 10a0f60..36ae32f 100644
--- a/docs/01-basics.md
+++ b/docs/01-basics.md
@@ -130,3 +130,7 @@ by the `IRC::Client::Plugin` role to call method `.send` on the Client Object.
In the `:where` parameter, we specify we want to send the message to
channel `#perl6` and the `:text` parameter contains the text we want to send.
The bot will send that text every 3 seconds.
+
+## Up Next
+
+Read [the event reference](02-event-reference.md) next.
diff --git a/docs/02-event-reference.md b/docs/02-event-reference.md
new file mode 100644
index 0000000..e42a659
--- /dev/null
+++ b/docs/02-event-reference.md
@@ -0,0 +1,48 @@
+[[back to main docs]](../README.md#documentation-map)
+
+# Event Reference
+
+The module offers named, numeric, and convenience events. The named and
+numeric events correspond to IRC protocol events, while convenience events
+are an extra layer provided to make using the module easier. This means one
+IRC event can trigger several events of the module. For example, if someone
+addresses our bot in a channel, the following chain of events will be fired:
+
+ irc-addressed ▶ irc-to-me ▶ irc-privmsg-channel ▶ irc-privmsg ▶ irc-all
+
+The events are ordered from "narrowest" to "widest": `irc-addressed` can be
+triggered only in-channel, when our bot is addressed; `irc-to-me` can also
+be triggered via notice and private message, so it's wider;
+`irc-privmsg-channel` includes all channel messages, so it's wider still;
+and `irc-privmsg` also includes private messages to our bot. The chain ends
+by the widest event of them all: `irc-all`.
+
+## Event Map
+
+All event chains end with `irc-all`, which is not shown in the table below,
+for brevity. `irc-XXX` stands for numeric events where `XXX` is a
+three-digit number. See [this numerics
+table](https://www.alien.net.au/irc/irc2numerics.html) for meaning of codes,
+depending on the server used.
+
+```
+irc-addressed ▶ irc-to-me ▶ irc-privmsg-channel ▶ irc-privmsg
+ irc-mentioned ▶ irc-privmsg-channel ▶ irc-privmsg
+ irc-privmsg-channel ▶ irc-privmsg
+ irc-to-me ▶ irc-privmsg-me ▶ irc-privmsg
+
+irc-addressed ▶ irc-to-me ▶ irc-notice-channel ▶ irc-notice
+ irc-mentioned ▶ irc-notice-channel ▶ irc-notice
+ irc-notice-channel ▶ irc-notice
+ irc-to-me ▶ irc-notice-me ▶ irc-notice
+
+ irc-mode-channel ▶ irc-mode
+ irc-mode-me ▶ irc-mode
+
+ irc-connected ▶ irc-numeric ▶ irc-XXX
+ irc-numeric ▶ irc-XXX
+```
+
+## Up Next
+
+Read [the method reference](03-method-reference.md) next.
diff --git a/docs/03-method-reference.md b/docs/03-method-reference.md
new file mode 100644
index 0000000..bf4810c
--- /dev/null
+++ b/docs/03-method-reference.md
@@ -0,0 +1,6 @@
+[[back to main docs]](../README.md#documentation-map)
+
+
+## Up Next
+
+Read [the method reference](03-method-reference.md) next.
diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6
index 4055f1b..44393f3 100644
--- a/lib/IRC/Client.pm6
+++ b/lib/IRC/Client.pm6
@@ -158,6 +158,7 @@ method !connect-socket ($server) {
$!debug and debug-print 'Attempting to connect to server', :out, :$server;
IO::Socket::Async.connect($server.host, $server.port).then: sub ($prom) {
if $prom.status ~~ Broken {
+ $server.is-connected = False;
$!debug and debug-print 'Could not connect', :out, :$server;
sleep 5;
$!socket-pipe.send: $server;
@@ -188,6 +189,7 @@ method !connect-socket ($server) {
}
unless $server.has-quit {
+ $server.is-connected = False;
$!debug and debug-print "Connection closed", :in, :$server;
sleep 5;
}