| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Jaipo::UI::Console; |
|
2
|
1
|
|
|
1
|
|
1282
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
16
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use Jaipo; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
5
|
1
|
|
|
1
|
|
18
|
use utf8; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
1
|
|
|
1
|
|
34
|
use feature qw(:5.10); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
107
|
|
|
7
|
1
|
|
|
1
|
|
554
|
use Term::ReadLine; |
|
|
1
|
|
|
|
|
2149
|
|
|
|
1
|
|
|
|
|
28
|
|
|
8
|
1
|
|
|
1
|
|
508
|
use Time::HiRes qw( setitimer ITIMER_REAL ITIMER_PROF time ); |
|
|
1
|
|
|
|
|
1135
|
|
|
|
1
|
|
|
|
|
3
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
744
|
no if $] >= 5.017011, warnings => 'experimental::smartmatch'; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
6
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
to enter Jaipo console: |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ jaipo console |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
> use Twitter # enable Twitter service plugin |
|
21
|
|
|
|
|
|
|
> use Plurk # enable Plurk service plugin |
|
22
|
|
|
|
|
|
|
> use RSS # enable RSS plugin |
|
23
|
|
|
|
|
|
|
> use IRC # enable IRC plugin |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Jaipo will automatically save your configuration, you only need to use 'use' |
|
26
|
|
|
|
|
|
|
at first time. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
to update status |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
> :çªç¶ä¸èµ·å¤§é¨ã |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
to read all messeges |
|
33
|
|
|
|
|
|
|
> r |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Service | User | Message |
|
36
|
|
|
|
|
|
|
twitter c9s oh hohoho ! |
|
37
|
|
|
|
|
|
|
plurk xxx ååå®åå¡. |
|
38
|
|
|
|
|
|
|
... |
|
39
|
|
|
|
|
|
|
... |
|
40
|
|
|
|
|
|
|
... |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
to read messages on Jaiku.com |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
> jaiku r |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
to read someone's messages on Jaiku.com |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
> jaiku r UnitedNation |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
to read public timeline |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
> p |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
to check user's profile |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
> jaiku w IsYourDaddy |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
setup location on Jaiku |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
> jaiku l æå¨å¢¾ä¸ï¼å¤©æ°£æ
ã |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
to update post to Twitter |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
> twitter :é¨åäº |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
to reply to someone's post on Twiwter |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
> twitter reply Someone å丸æ±ç
®å¥½æ£ |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
to send direct message to someone on twitter |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
> twitter send mama åª½ï¼æé¿éå¦ï¼ |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
to follow someone on twitter |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
> twitter follow mama |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
to send a message to a channel on Jaiku |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
> jaiku #TVshow åª½ï¼æä¸é»è¦äºï¼(æ®æ) |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
create a regular expression filter for twitter timeline |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
> filter /cor[a-z]*s/i :twitter |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
enter service-only mode |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
> only twitter |
|
89
|
|
|
|
|
|
|
:twitter> |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
> only jaiku |
|
92
|
|
|
|
|
|
|
:jaiku> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 Command Reference |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 Global Commands |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item m |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
read user updates |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item p |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
read friend updates |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item g |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
read global updates |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 Service Commands |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
[SERVICE] :[MESSAGE] |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
[SERVICE] [ACTION] [ ARGUMENTS .. ] |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head3 Jaiku |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 Functions |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 new |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $jobj; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$|=1; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub new { |
|
130
|
1
|
|
|
1
|
1
|
579
|
my $class = shift; |
|
131
|
1
|
|
|
|
|
2
|
my %args = @_; |
|
132
|
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
2
|
my $self = {}; |
|
134
|
1
|
|
|
|
|
2
|
bless $self, $class; |
|
135
|
1
|
|
|
|
|
4
|
$self->_pre_init; |
|
136
|
1
|
|
|
|
|
2
|
return $self; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 _pre_init |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _pre_init { |
|
144
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
|
145
|
|
|
|
|
|
|
# binmode STDOUT,":utf8"; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 setup service |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub setup_service { |
|
153
|
0
|
|
|
0
|
0
|
0
|
my ( $self , $args , $opt ) = @_; |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
0
|
print "Init " , $args->{package_name} , ":\n"; |
|
156
|
0
|
|
|
|
|
0
|
for my $column ( @{ $args->{require_args} } ) { |
|
|
0
|
|
|
|
|
0
|
|
|
157
|
0
|
|
|
|
|
0
|
my ($column_name , $column_option ) = each %$column; |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
0
|
print $column_option->{label} , ":" ; |
|
160
|
0
|
|
|
|
|
0
|
my $val = <STDIN>; |
|
161
|
0
|
|
|
|
|
0
|
chomp $val; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
0
|
$opt->{$column_name} = $val; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 init |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub init { |
|
172
|
1
|
|
|
1
|
1
|
450
|
my $self = shift; |
|
173
|
1
|
|
|
|
|
4
|
$self->print_welcome; |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# init Jaipo here |
|
176
|
1
|
|
|
|
|
12
|
$jobj = Jaipo->new; |
|
177
|
1
|
|
|
|
|
6
|
$jobj->init( $self ); |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 print_help |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub print_help { |
|
185
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
0
|
print <<HELP ; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
m|mine to read updates of your own |
|
190
|
|
|
|
|
|
|
p|public to read public messages (from friends,channels) |
|
191
|
|
|
|
|
|
|
g|global to read global messages (from the whole world) |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
:[message] update a message to all services. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
eval eval a part of code. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
conf edit edit configuration |
|
198
|
|
|
|
|
|
|
conf load load configuration |
|
199
|
|
|
|
|
|
|
conf save save configuration |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
use [service trigger] |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
f create create a filter |
|
204
|
|
|
|
|
|
|
? print help |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
[service] [message] |
|
207
|
|
|
|
|
|
|
[service] :[action] [arguments] |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
HELP |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 print_welcome |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub print_welcome { |
|
219
|
1
|
|
|
1
|
1
|
165
|
print "Jaipo Console (version ". $Jaipo::VERSION .")\n"; |
|
220
|
1
|
|
|
|
|
190
|
print <<'END'; |
|
221
|
|
|
|
|
|
|
_________________________________________ |
|
222
|
|
|
|
|
|
|
Type ? for help |
|
223
|
|
|
|
|
|
|
Type [service] ? for service plugin help |
|
224
|
|
|
|
|
|
|
Type :[message] to send a message |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
END |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 process_built_in_commands |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=cut |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub process_built_in_commands { |
|
236
|
0
|
|
|
0
|
1
|
|
my ($self ,$line ) = @_; |
|
237
|
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
$line =~ s/^://; |
|
239
|
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
given ($line) { |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# eval code |
|
243
|
|
|
|
|
|
|
# such like: eval $jobj->_list_trigger; |
|
244
|
0
|
|
|
|
|
|
when ( m/^eval (.*)$/i ) { |
|
245
|
|
|
|
|
|
|
# eval a code |
|
246
|
0
|
|
|
|
|
|
my $code = $1; |
|
247
|
0
|
|
|
|
|
|
eval $1; |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
when ( m/^conf\s+edit$/i ) { |
|
251
|
0
|
|
0
|
|
|
|
my $editor = $ENV{EDITOR} || 'nano' ; |
|
252
|
0
|
|
|
|
|
|
my $file = Jaipo->config->app_config_path; |
|
253
|
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
print "Launching editor .. $editor\n"; |
|
255
|
0
|
|
|
|
|
|
qx{$editor $file}; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
when ( m/^conf\s+save$/i ) { |
|
259
|
|
|
|
|
|
|
# TODO |
|
260
|
|
|
|
|
|
|
# save configuration |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
0
|
|
|
|
|
|
when ( m/^conf\s+load$/i ) { |
|
264
|
|
|
|
|
|
|
# TODO |
|
265
|
|
|
|
|
|
|
# load configuration |
|
266
|
|
|
|
|
|
|
# when user modify configuration by self, user can reload |
|
267
|
|
|
|
|
|
|
# configuration |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
|
when ( m/^list$/i ) { |
|
271
|
0
|
|
|
|
|
|
$jobj->list_triggers; |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
# built-in commands |
|
276
|
|
|
|
|
|
|
# TODO: |
|
277
|
|
|
|
|
|
|
# |
|
278
|
0
|
|
|
|
|
|
when (m/^(?:u|use)\s*/i) { |
|
279
|
0
|
|
|
|
|
|
$line =~ s/;$//; |
|
280
|
0
|
|
|
|
|
|
my @ops = split /\s+/,$line; |
|
281
|
0
|
|
|
|
|
|
shift @ops; # shift out use command |
|
282
|
0
|
|
|
|
|
|
my ( $service_name , $trigger_name ) = @ops; |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# init service plugins |
|
285
|
|
|
|
|
|
|
# TODO: |
|
286
|
|
|
|
|
|
|
# check if user specify trigger name |
|
287
|
0
|
0
|
|
|
|
|
if ( !$service_name ) { |
|
288
|
0
|
|
|
|
|
|
$jobj->list_triggers; |
|
289
|
|
|
|
|
|
|
} else { |
|
290
|
0
|
|
|
|
|
|
$service_name = ucfirst $service_name; |
|
291
|
0
|
|
0
|
|
|
|
$trigger_name ||= lc $service_name; |
|
292
|
0
|
|
|
|
|
|
print "Trying to load $service_name => $trigger_name\n"; |
|
293
|
0
|
|
|
|
|
|
$jobj->runtime_load_service ( $self, $service_name, $trigger_name ); |
|
294
|
0
|
|
|
|
|
|
print "Done\n"; |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
} |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# Global Actions |
|
300
|
|
|
|
|
|
|
# |
|
301
|
|
|
|
|
|
|
|
|
302
|
0
|
|
|
|
|
|
when ( m/^(s|send)/i ) { |
|
303
|
0
|
|
|
|
|
|
$jobj->action( "send_msg", $line ); |
|
304
|
|
|
|
|
|
|
} |
|
305
|
|
|
|
|
|
|
|
|
306
|
0
|
|
|
|
|
|
when ( m/^(m|mine)/i ) { |
|
307
|
0
|
|
|
|
|
|
$jobj->action( "read_user_timeline", $line ); |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
when ( m/^(p|public)/i ) { |
|
311
|
0
|
|
|
|
|
|
$jobj->action( "read_public_timeline", $line ); |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
|
|
314
|
0
|
|
|
|
|
|
when ( m/^(g|global)/i ) { |
|
315
|
0
|
|
|
|
|
|
$jobj->action( "read_global_timeline", $line ); |
|
316
|
|
|
|
|
|
|
} |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
# XXX: let -p , -m works |
|
319
|
0
|
|
|
|
|
|
when (m/^-$/) { |
|
320
|
0
|
|
|
|
|
|
$jobj->cache_clear; |
|
321
|
0
|
|
|
|
|
|
Jaipo->logger->info("Cache Flushed"); |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
when (m/^mark\s+as\s+read/i) { |
|
325
|
0
|
|
|
|
|
|
$jobj->cache_clear(); |
|
326
|
0
|
|
|
|
|
|
Jaipo->logger->info("Cache Flushed"); |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# something like filter create /regexp/ :twitter:public |
|
331
|
0
|
|
|
|
|
|
when (m/^(f|filter)\s/i) { |
|
332
|
0
|
|
|
|
|
|
my ( $cmd, $action, @params ) = split /\s+/, $line; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
0
|
|
|
|
|
|
when ('?') { |
|
336
|
0
|
|
|
|
|
|
$self->print_help; |
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
# try to find the trigger , if match then do it |
|
340
|
|
|
|
|
|
|
# or show up command not found |
|
341
|
0
|
|
|
|
|
|
default { |
|
342
|
|
|
|
|
|
|
# dispatch to service |
|
343
|
0
|
|
|
|
|
|
my ( $service_tg, $rest_line ) = ( $line =~ m/^(\w+)\s*(.*)/i ); |
|
344
|
0
|
|
|
|
|
|
$jobj->dispatch_to_service( $service_tg, $rest_line ); |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub parse { |
|
350
|
0
|
|
|
0
|
0
|
|
my ($self,$line) = @_; |
|
351
|
|
|
|
|
|
|
|
|
352
|
0
|
|
|
|
|
|
$line =~ s/^\s*//g; |
|
353
|
0
|
|
|
|
|
|
$line =~ s/\s*$//g; |
|
354
|
|
|
|
|
|
|
|
|
355
|
0
|
0
|
|
|
|
|
return unless $line; |
|
356
|
|
|
|
|
|
|
|
|
357
|
0
|
0
|
|
|
|
|
if( $line =~ m/^:/ ) { |
|
358
|
|
|
|
|
|
|
# do update status message if string start with ":" |
|
359
|
0
|
|
|
|
|
|
$line =~ s/^://; |
|
360
|
0
|
|
|
|
|
|
$jobj->action ( "send_msg", $line ); |
|
361
|
|
|
|
|
|
|
} else { |
|
362
|
0
|
|
|
|
|
|
$self->process_built_in_commands( $line ); |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub auto_update { |
|
368
|
0
|
|
|
0
|
0
|
|
print "Auto-Update Mode\n"; |
|
369
|
|
|
|
|
|
|
$SIG{ALRM} = sub { |
|
370
|
0
|
|
|
0
|
|
|
print "Updating ... \r"; |
|
371
|
0
|
|
|
|
|
|
$jobj->action( "read_public_timeline" ); |
|
372
|
0
|
|
|
|
|
|
print "Done" . ' ' x 10 . "\r"; |
|
373
|
0
|
|
|
|
|
|
}; |
|
374
|
0
|
|
|
|
|
|
setitimer(ITIMER_REAL , 1 , 10); |
|
375
|
|
|
|
|
|
|
} |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub run { |
|
378
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
379
|
0
|
|
|
|
|
|
my $prompt = "jaipo> "; |
|
380
|
1
|
|
|
1
|
|
1214
|
use utf8; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
381
|
|
|
|
|
|
|
# XXX: Term::ReadLine doesnt support UTF-8 |
|
382
|
|
|
|
|
|
|
# my $term = new Term::ReadLine; # 'Simple Perl'; |
|
383
|
|
|
|
|
|
|
# my $OUT = $term->OUT || \*STDOUT; |
|
384
|
|
|
|
|
|
|
# binmode $OUT,":utf8"; |
|
385
|
0
|
|
|
|
|
|
binmode STDIN,":utf8"; |
|
386
|
0
|
|
|
|
|
|
binmode STDOUT,":utf8"; |
|
387
|
|
|
|
|
|
|
# while ( defined ($_ = $term->readline($prompt)) ) { |
|
388
|
0
|
|
|
|
|
|
while ( 1 ) { |
|
389
|
0
|
|
|
|
|
|
print $prompt; |
|
390
|
0
|
|
|
|
|
|
my $line = <STDIN>; |
|
391
|
0
|
|
|
|
|
|
chomp $line; |
|
392
|
0
|
0
|
|
|
|
|
unless( $line ) { |
|
393
|
0
|
|
|
|
|
|
$self->auto_update; |
|
394
|
0
|
|
|
|
|
|
<STDIN>; |
|
395
|
0
|
|
|
|
|
|
$SIG{ALRM} = undef; |
|
396
|
0
|
|
|
|
|
|
setitimer(ITIMER_REAL , 0 ); |
|
397
|
|
|
|
|
|
|
} |
|
398
|
0
|
0
|
|
|
|
|
chomp $line if( $line ); |
|
399
|
0
|
|
|
|
|
|
eval( q{ $self->parse ( $line ); } ); |
|
400
|
0
|
0
|
|
|
|
|
warn $@ if $@; |
|
401
|
|
|
|
|
|
|
# print $OUT $res, "\n" unless $@; |
|
402
|
|
|
|
|
|
|
# $term->addhistory($_) if /\S/; |
|
403
|
|
|
|
|
|
|
} |
|
404
|
|
|
|
|
|
|
} |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
1; |