| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Convos::Core::Commands; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Convos::Core::Commands - Translate to IRC commands |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
29
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use Mojo::JSON; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
30
|
|
|
12
|
1
|
|
|
1
|
|
307
|
use Convos::Core::Util 'as_id'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1234
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 close |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub close { |
|
21
|
0
|
|
|
0
|
1
|
|
my ($self, $target, $dom) = @_; |
|
22
|
0
|
|
|
|
|
|
my $login = $self->session('login'); |
|
23
|
0
|
|
|
|
|
|
my $state = $dom->{state}; |
|
24
|
0
|
|
|
|
|
|
my $id; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
0
|
|
|
|
$target ||= $dom->{target}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
0
|
0
|
|
|
|
if ($target =~ /^[#&]/ and $state eq 'connected') { |
|
29
|
0
|
|
|
|
|
|
return "PART $target"; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
else { |
|
32
|
0
|
|
|
|
|
|
$id = as_id $dom->{network}, $target; |
|
33
|
|
|
|
|
|
|
$self->redis->zrem( |
|
34
|
|
|
|
|
|
|
"user:$login:conversations", |
|
35
|
|
|
|
|
|
|
$id, |
|
36
|
|
|
|
|
|
|
sub { |
|
37
|
0
|
|
|
0
|
|
|
$self->send_partial('event/remove_conversation', %$dom, target => $target); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
0
|
|
|
|
|
|
); |
|
40
|
0
|
|
|
|
|
|
return; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 help |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub help { |
|
49
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
50
|
0
|
|
|
|
|
|
$self->send_partial('event/help'); |
|
51
|
0
|
|
|
|
|
|
return; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 j |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 join |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 list |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub list { |
|
63
|
0
|
|
|
0
|
1
|
|
my ($self, $filter, $dom) = @_; |
|
64
|
0
|
|
|
|
|
|
my $login = $self->session('login'); |
|
65
|
0
|
|
|
|
|
|
my $state = $dom->{state}; |
|
66
|
0
|
|
|
|
|
|
my $id; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ($filter) { |
|
69
|
0
|
|
|
|
|
|
$self->send_partial('event/channel_list' => %$dom, channels => {}); |
|
70
|
0
|
|
|
|
|
|
return "LIST $filter"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$self->redis->hgetall( |
|
74
|
|
|
|
|
|
|
"convos:irc:$dom->{network}:channels", |
|
75
|
|
|
|
|
|
|
sub { |
|
76
|
0
|
|
|
0
|
|
|
my ($redis, $channels) = @_; |
|
77
|
0
|
|
|
|
|
|
$_ = Mojo::JSON::j($_) for values %$channels; |
|
78
|
0
|
|
|
|
|
|
$self->send_partial('event/channel_list' => %$dom, channels => $channels); |
|
79
|
0
|
0
|
|
|
|
|
return if %$channels; |
|
80
|
0
|
|
|
|
|
|
my $key = "convos:user:$login:$dom->{network}"; |
|
81
|
0
|
|
|
|
|
|
$self->logf(debug => '[%s] < %s', $key, "$dom->{uuid} LIST"); |
|
82
|
0
|
|
|
|
|
|
$self->redis->publish($key, "$dom->{uuid} LIST"); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
0
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 me |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 mode |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 msg |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 names |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 nick |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 oper |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 part |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 query |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub query { |
|
108
|
0
|
|
|
0
|
1
|
|
my ($self, $target, $dom) = @_; |
|
109
|
0
|
|
|
|
|
|
my $login = $self->session('login'); |
|
110
|
0
|
|
|
|
|
|
my $id = as_id $dom->{network}, $target; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ($target =~ /^[#&]?[\w_-]+$/) { |
|
113
|
|
|
|
|
|
|
$self->redis->zadd( |
|
114
|
|
|
|
|
|
|
"user:$login:conversations", |
|
115
|
|
|
|
|
|
|
time, $id, |
|
116
|
|
|
|
|
|
|
sub { |
|
117
|
0
|
|
|
0
|
|
|
$self->send_partial('event/add_conversation', %$dom, target => $target); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
0
|
|
|
|
|
|
); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
else { |
|
122
|
0
|
|
0
|
|
|
|
$target ||= 'Missing'; |
|
123
|
0
|
|
|
|
|
|
$self->send_partial( |
|
124
|
|
|
|
|
|
|
'event/server_message', %$dom, |
|
125
|
|
|
|
|
|
|
status => 400, |
|
126
|
|
|
|
|
|
|
message => "Invalid target: $target", |
|
127
|
|
|
|
|
|
|
timestamp => time |
|
128
|
|
|
|
|
|
|
); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
return; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 reconnect |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub reconnect { |
|
139
|
0
|
|
|
0
|
1
|
|
my ($self, $arg, $dom) = @_; |
|
140
|
0
|
|
|
0
|
|
|
$self->app->core->control(restart => $self->session('login'), $dom->{network}, sub { }); |
|
|
0
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 say |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 t |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 topic |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 kick |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 w |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 whois |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
0
|
1
|
|
sub join {"JOIN $_[1]"} |
|
159
|
0
|
|
|
0
|
1
|
|
sub kick {"KICK $_[2]->{target} $_[1]"} |
|
160
|
0
|
|
|
0
|
1
|
|
sub me {"PRIVMSG $_[2]->{target} :\x{1}ACTION $_[1]\x{1}"} |
|
161
|
0
|
|
|
0
|
1
|
|
sub mode {"MODE $_[1]"} |
|
162
|
0
|
|
|
0
|
1
|
|
sub msg { $_[1] =~ s!^(\w+)\s*!!; "PRIVMSG $1 :$_[1]" } |
|
|
0
|
|
|
|
|
|
|
|
163
|
0
|
|
0
|
0
|
1
|
|
sub names { "NAMES " . ($_[1] || $_[2]->{target}) } |
|
164
|
0
|
|
|
0
|
1
|
|
sub nick {"NICK $_[1]"} |
|
165
|
0
|
|
|
0
|
1
|
|
sub oper {"OPER $_[1]"} |
|
166
|
0
|
|
0
|
0
|
1
|
|
sub part { "PART " . ($_[1] || $_[2]->{target}) } |
|
167
|
0
|
|
|
0
|
1
|
|
sub say {"PRIVMSG $_[2]->{target} :$_[1]"} |
|
168
|
0
|
0
|
|
0
|
1
|
|
sub topic { "TOPIC $_[2]->{target}" . ($_[1] ? " :$_[1]" : "") } |
|
169
|
0
|
|
|
0
|
1
|
|
sub whois {"WHOIS $_[1]"} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
{ |
|
172
|
1
|
|
|
1
|
|
7
|
no warnings 'once'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
75
|
|
|
173
|
|
|
|
|
|
|
*j = \&join; |
|
174
|
|
|
|
|
|
|
*t = \&topic; |
|
175
|
|
|
|
|
|
|
*w = \&whois; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Jan Henning Thorsen - C |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |