aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-07-27 08:23:07 -0400
committerZoffix Znet <cpan@zoffix.com>2016-07-27 08:23:07 -0400
commit7fa988fc8586bcc5ea800326921f323f8078c318 (patch)
tree6772a6e84055b8a86221f335f553c839b412d116
parent25c5e8262227e76b2a3cf914f8be3ffbfb169952 (diff)
Organize source
-rw-r--r--lib/IRC/Client.pm653
1 files changed, 31 insertions, 22 deletions
diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6
index aa1d132..942418a 100644
--- a/lib/IRC/Client.pm6
+++ b/lib/IRC/Client.pm6
@@ -88,10 +88,6 @@ method run {
await Promise.allof: %!servers.values».<promise>;
}
-# method emit-custom (|c) {
-# $!event-pipe.send: c;
-# }
-
method send (:$where!, :$text!, :$server, :$notice) {
for $server || |%!servers.keys.sort {
self.send-cmd: $notice ?? 'NOTICE' !! 'PRIVMSG', $where, $text,
@@ -126,16 +122,12 @@ method send-cmd ($cmd, *@args is copy, :$prefix = '', :$server) {
}
}
-method !prep-servers {
- %!servers = '*' => {} unless %!servers;
-
- for %!servers.values -> $s {
- $s{$_} //= self."$_"()
- for <host password port nick username userhost userreal>;
- $s<channels> = @.channels;
- $s<socket> = Nil;
- }
-}
+###############################################################################
+###############################################################################
+###############################################################################
+###############################################################################
+###############################################################################
+###############################################################################
method !handle-event ($e) {
given $e.command {
@@ -196,8 +188,7 @@ method !handle-event ($e) {
my $res = ."$event"($e);
next if $res ~~ IRC_FLAG_NEXT;
- # Bail out on bogus return values
- # dd [ $res, $res ~~ IRC::Client, $res ~~ IRC::Client | Supply | Channel];
+ # Do not .reply with bogus return values
last EVENT if $res ~~ IRC::Client | Supply | Channel;
if $res ~~ Promise {
@@ -212,6 +203,13 @@ method !handle-event ($e) {
}
}
+method !parse (Str:D $str, :$server) {
+ return |IRC::Client::Grammar.parse(
+ $str,
+ :actions( IRC::Client::Grammar::Actions.new: :irc(self), :$server )
+ ).made;
+}
+
method !plugs-that-can ($method, $e) {
gather {
for @!plugins -> $plug {
@@ -221,6 +219,17 @@ method !plugs-that-can ($method, $e) {
}
}
+method !prep-servers {
+ %!servers = '*' => {} unless %!servers;
+
+ for %!servers.values -> $s {
+ $s{$_} //= self."$_"()
+ for <host password port nick username userhost userreal>;
+ $s<channels> = @.channels;
+ $s<socket> = Nil;
+ }
+}
+
method !ssay (Str:D $msg, :$server is copy) {
$server //= '*';
$!debug and debug-print $msg, :out, :$server;
@@ -228,12 +237,12 @@ method !ssay (Str:D $msg, :$server is copy) {
self;
}
-method !parse (Str:D $str, :$server) {
- return |IRC::Client::Grammar.parse(
- $str,
- :actions( IRC::Client::Grammar::Actions.new: :irc(self), :$server )
- ).made;
-}
+###############################################################################
+###############################################################################
+###############################################################################
+###############################################################################
+###############################################################################
+###############################################################################
sub debug-print (Str(Any) $str, :$in, :$out, :$sys, :$server) {
my $server-str = $server