1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
package Plugin::Log;
use strict;
use warnings;
use Term::ANSIColor;
my $config;
my $root_config;
# FIXME turn theme into config parms?
my %t = (
bracket => color("white"),
nick => color("cyan"),
info => color("yellow"),
kick => color("red"),
host => color("magenta"),
channel => color("blue"),
message => color("reset"),
private => color("magenta"),
misc => color("bright_black"),
reset => color("reset")
);
sub configure {
my $self = shift;
shift; # cmdref
shift; # run_command
$config = shift;
$root_config = shift;
return $self;
}
# IRC 001
sub on_001_welcome {
my ($self, $logger, $server, $message, $irc) = @_;
$logger->("$t{info}Connected to $t{host}$server$t{info} --- \"$t{message}$message$t{info}\"$t{reset}");
}
# IRC 002
sub on_002_your_host {
my ($self, $logger, $message, $irc) = @_;
$logger->("$t{info} --- \"$t{message}$message$t{info}\"$t{reset}");
}
# IRC 003
sub on_003_created {
my ($self, $logger, $message, $irc) = @_;
$logger->("$t{info} --- \"$t{message}$message$t{info}\"$t{reset}");
}
# IRC 004
sub on_004_my_info {
my ($self, $logger, $message, $irc) = @_;
$logger->("$t{info} --- \"$t{message}$message$t{info}\"$t{reset}");
}
# IRC 251
sub on_251_user_client {
my ($self, $logger, $message, $irc) = @_;
$logger->("$t{info}Online: \"$t{message}$message$t{info}\"$t{reset}");
}
# IRC 252
sub on_252_user_op {
my ($self, $logger, $count, $message, $irc) = @_;
$logger->("$t{info}Online: \"$t{message}$count $message$t{info}\"$t{reset}");
}
# IRC 253
sub on_253_user_unknown {
my ($self, $logger, $count, $message, $irc) = @_;
$logger->("$t{info}Online: \"$t{message}$count $message$t{info}\"$t{reset}");
}
# IRC 254
sub on_254_user_channels {
my ($self, $logger, $count, $message, $irc) = @_;
$logger->("$t{info}Online: \"$t{message}$count $message$t{info}\"$t{reset}");
}
# IRC 255
sub on_255_user_me {
my ($self, $logger, $message, $irc) = @_;
$logger->("$t{info}Online: \"$t{message}$message$t{info}\"$t{reset}");
}
sub on_message {
my ($self, $logger, $who, $where, $raw_what, $what, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where->[0]$t{bracket}\] $t{nick}$who: $t{message}$what$t{reset}");
return;
}
sub on_privmsg {
my ($self, $logger, $who, $to, $raw_what, $what, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}private$t{bracket}\] $t{nick}$who$t{bracket}: $t{private}$what$t{reset}");
return;
}
sub on_action {
my ($self, $logger, $who, $where, $raw_what, $what, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where->[0]$t{bracket}\] $t{message}* $t{nick}$who $t{message}$raw_what$t{reset}");
return;
}
sub on_part {
my ($self, $logger, $who, $where, $why, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- $t{nick}$who $t{info}left ($why)$t{reset}");
return;
}
sub on_join {
my ($self, $logger, $who, $where, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- $t{nick}$who $t{info}joined$t{reset}");
return;
}
sub on_kick {
my ($self, $logger, $kicker, $where, $kickee, $why, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{kick} !!! $t{nick}$kicker $t{kick}kicked $t{nick}$kickee $t{kick}($why)$t{reset}");
return;
}
sub on_nick {
my ($self, $logger, $who, $new_nick, $irc) = @_;
$logger->("$t{nick}$who $t{info}changed nick to $t{nick}$new_nick$t{reset}");
return;
}
sub on_invite {
my ($self, $logger, $who, $where, $irc) = @_;
$logger->("$t{nick}$who $t{info}invited me to join $t{channel}$where$t{reset}");
return;
}
sub on_notice {
my ($self, $logger, $who, $where, $message, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- Notice: $t{nick}$who$t{info}: $t{message}$message$t{reset}");
return;
}
sub on_topic {
my ($self, $logger, $who, $where, $topic, $irc) = @_;
if ($topic) {
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- $t{nick}$who $t{info}set topic to $t{message}$topic$t{reset}");
} else {
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- $t{nick}$who $t{info}unset the topic$t{reset}");
}
return;
}
sub on_ping {
my ($self, $logger, $server, $irc) = @_;
$logger->("$t{misc}IRC ping from $server$t{reset}");
return;
}
sub on_331_rpl_notopic {
my ($self, $logger, $where, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- topic is not set$t{reset}");
return;
}
sub on_332_rpl_topic {
my ($self, $logger, $where, $topic, $irc) = @_;
$logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- topic is $t{message}$topic$t{reset}");
return;
}
sub on_372_motd_content {
my ($self, $logger, $server, $motd, $irc) = @_;
$logger->("$t{info}MOTD: $t{message}$motd$t{reset}");
return;
}
sub on_375_motd_begin {
my ($self, $logger, $server, $message, $irc) = @_;
$logger->("$t{info}$message$t{reset}");
return;
}
sub on_376_motd_end {
my ($self, $logger, $server, $message, $irc) = @_;
$logger->("$t{info}$message$t{reset}");
return;
}
1;
|