Skip to content
Newer
Older
100755 901 lines (785 sloc) 23.3 KB
44269eb @thepeopleseason updated
thepeopleseason authored
1 #!/usr/bin/perl -s
dc5896e @thepeopleseason initial commit
thepeopleseason authored
2
44269eb @thepeopleseason updated
thepeopleseason authored
3 use strict;
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
4 use vars qw($channel $mynick $data $irc $conn $james $trans);
44269eb @thepeopleseason updated
thepeopleseason authored
5 use lib qw(/home/james/devel/cim/projects/01_olga);
dc5896e @thepeopleseason initial commit
thepeopleseason authored
6 use Net::IRC;
44269eb @thepeopleseason updated
thepeopleseason authored
7 use Text::Wrap qw(fill $columns);
8 use LWP::Simple;
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
9 use XML::RSS;
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
10 use XML::Simple;
11 use JSON::XS;
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
12 use Data::Dumper;
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
13
dc5896e @thepeopleseason initial commit
thepeopleseason authored
14 require "movie_quotes.pl";
44269eb @thepeopleseason updated
thepeopleseason authored
15 require "movie_trivia.pl";
16
dc5896e @thepeopleseason initial commit
thepeopleseason authored
17 $columns = 450;
18
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
19 my @spacerobots =
20 (
21 "I am the Pusher robot.",
22 "I am the Shover robot.",
23 "Pushing will protect you from the terrible secret of space.",
24 "Shoving will protect you from the terrible secret of space.",
25 );
26
313b01d @thepeopleseason updated to add refresh and params to fails
thepeopleseason authored
27 my %bParams = qw(ELLINGTON_BRANCH Ell TEMPLATE_BRANCH MT
28 YOUR_NAME Who BRANCH SV);
29
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
30 $channel = $ARGV[0] ? "#$ARGV[0]" : '#all';
dc5896e @thepeopleseason initial commit
thepeopleseason authored
31 $mynick = $ARGV[1];
32 print "channel: $channel\n";
33 $irc = new Net::IRC;
34 $mynick = 'olga' if (!$mynick);
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
35 $conn = $irc->newconn(
36 Nick => "$mynick",
37 Server => 'irc.cmgdigital.com',
38 Port => 6667,
39 Ircname => 'Whatcha lookin at, bichachi?',
40 Username => "$mynick",
41 Password => 'xXxXxXxXxXx',
42 );
dc5896e @thepeopleseason initial commit
thepeopleseason authored
43
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
44 $data->{userhost} = '(james\@.*\.coxinc\.com|James_Hsi\@.*direcpath.com)';
45 $data->{jsonfile} = "${mynick}_dat.json";
46 &init_data($conn);
47
dc5896e @thepeopleseason initial commit
thepeopleseason authored
48 $conn->add_handler(['376', '422'], \&on_connect);
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
49 $conn->add_global_handler('disconnect', \&on_disconnect);
dc5896e @thepeopleseason initial commit
thepeopleseason authored
50 $conn->add_handler('public', \&on_public);
51 $conn->add_handler('msg', \&on_public);
52 $conn->add_handler('join', \&on_join);
44269eb @thepeopleseason updated
thepeopleseason authored
53 $conn->add_handler('nick', \&on_nick);
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
54 $conn->add_handler('ping', \&on_ping, 2);
dc5896e @thepeopleseason initial commit
thepeopleseason authored
55 $conn->add_global_handler(353, \&on_names);
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
56
dc5896e @thepeopleseason initial commit
thepeopleseason authored
57 $irc->start;
58
44269eb @thepeopleseason updated
thepeopleseason authored
59 sub on_connect {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
60 my $self = shift;
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
61
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
62 print "Attempting to join $channel\n";
63 eval { $self->join("$channel"); };
64 if ($@) {
65 print "$@";
66 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
67 $trans->{stfu}->{$channel} = 0;
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
68
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
69 if ($mynick eq 'olga') {
70 eval { $self->join("#qa"); };
71 if ($@) {
72 print "$@";
73 }
74 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
75 $trans->{stfu}->{'#qa'} = 0;
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
76
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
77 srand($$);
dc5896e @thepeopleseason initial commit
thepeopleseason authored
78 }
79
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
80 # Reconnect to the server when we die.
81 sub on_disconnect {
82 my ($self, $event) = @_;
83
84 print "Disconnected from ". $event->from(), " (".
85 ($event->args())[0]. "). Attempting to reconnect...\n";
86 $self->connect();
87 }
88
dc5896e @thepeopleseason initial commit
thepeopleseason authored
89 sub on_join {
44269eb @thepeopleseason updated
thepeopleseason authored
90 my ($self, $event) = @_;
91 my ($channel) = ($event->to)[0];
dc5896e @thepeopleseason initial commit
thepeopleseason authored
92
44269eb @thepeopleseason updated
thepeopleseason authored
93 printf "*** %s (%s) has joined channel %s\n",
94 $event->nick, $event->userhost, $channel;
dc5896e @thepeopleseason initial commit
thepeopleseason authored
95
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
96 my @ops = qw( croddy mholcomb mchace jbruce rbronosky jheady
97 dviti cheisel golliher zmcghee jpreyer );
98 my $mgr_hosts = sprintf('(%s)\@cei-gla-cpk2\.coxinc\.com',
99 join('|', @ops));
100
101 if ($event->userhost =~ m/$mgr_hosts$/i) {
44269eb @thepeopleseason updated
thepeopleseason authored
102 $self->mode("$channel", "+o", $event->nick);
103 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
104
105 if ($event->userhost =~ m/$data->{userhost}$/i) {
106 push @{$trans->{master}}, $event->nick;
107 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
108 }
109
110 sub on_names {
111 my ($self, $event) = @_;
112 my (@list) = $event->args ();
113
114 print "names: @list\n";
dc5896e @thepeopleseason initial commit
thepeopleseason authored
115 }
116
117 sub on_nick {
44269eb @thepeopleseason updated
thepeopleseason authored
118 my ($self, $event) = @_;
119 my ($channel) = ($event->to)[0];
dc5896e @thepeopleseason initial commit
thepeopleseason authored
120
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
121 if ($event->userhost =~ m/$data->{userhost}$/i) {
122 print Dumper($event);
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
123
124 my ($newnick, $oldnick) = (($event->args())[0], $event->nick);
125 my @nicks = grep { !/$oldnick/ } @{$trans->{master}};
126 push @nicks, $newnick;
127 $trans->{master} = \@nicks;
44269eb @thepeopleseason updated
thepeopleseason authored
128 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
129 }
130
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
131 sub on_ping {
132 my ($self, $event) = @_;
133
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
134 &update_latest();
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
135 &update_horoscopes();
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
136 &update_bugs($self);
137 &update_resolves($self);
216c159 @thepeopleseason added closed ticket tracking
thepeopleseason authored
138 &update_closed($self);
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
139 &update_fails($self);
140
141 my $time = time();
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
142 for my $channel (keys %{$trans->{stfu}}) {
143 if ($time - $trans->{stfu}->{$channel} > 300) {
144 $trans->{stfu}->{$channel} = 0;
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
145 }
146 }
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
147
148 &write_data();
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
149 }
150
dc5896e @thepeopleseason initial commit
thepeopleseason authored
151 sub on_public {
44269eb @thepeopleseason updated
thepeopleseason authored
152 my ($self, $event) = @_;
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
153 my ($nick, $userhost, $arg, $type) =
154 ($event->nick, $event->userhost, $event->args, $event->type);
155 my $msg = "$nick, ";
156
157 my $to;
158 my $channel = ($event->to)[0];
159 if ($type eq 'msg') {
160 $to = $nick;
161 }
162 else {
163 $to = $channel;
164 }
44269eb @thepeopleseason updated
thepeopleseason authored
165
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
166 if (($type eq "msg") && ($userhost !~ m/$data->{userhost}$/i)) {
167 print Dumper($event);
168 }
44269eb @thepeopleseason updated
thepeopleseason authored
169
170 if (($type eq "msg") || ($arg =~ /^$mynick/i)) {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
171 $arg =~ s/^$mynick\s*[,:]?\s*//;
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
172
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
173 if ($arg =~ /^bugcount\s*(.*)/) {
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
174 my $filter = $1;
175 my $count;
176 if ($filter) {
177 $count = scalar(grep {/$filter/i} keys %{$data->{bugs}});
178 $filter .= ' ';
179 }
180 else {
181 $count = scalar(keys %{$data->{bugs}});
182 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
183 $msg .= "\U$filter\EBug count at $count\n";
184 }
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
185 elsif ($arg =~ /^(latest|lb)\s+(.*)/) {
186 $msg .= $data->{latest}->{lc($2)}
187 }
5356558 @thepeopleseason added lastreset command for last medley-dev-reset
thepeopleseason authored
188 elsif ($arg =~ /^(lastreset)/) {
189 $msg .= $data->{latest}->{'medley-dev-reset'}
190 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
191 elsif ($arg =~ /^(stock|quote)\s+(.*)/) {
192 # if (($1 eq "quote") && ($2 =~ /jay/i)) {
193 # my @askquotes = @jayquotes;
194 # $msg .= $askquotes[rand(@askquotes)];
195 # }
196 for my $line (split(/\n/, &get_stockprice($2))) {
197 $self->privmsg($to, $line);
198 sleep 1;
199 }
200 undef $msg;
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
201 }
7bc7205 @thepeopleseason updated dow/nasdaq and scopes: pull all into data
thepeopleseason authored
202 elsif ($arg =~ /^(dow|nasdaq|s&p)/i) {
203 my %index =
204 ( 'dow', '^DJI', 'nasdaq', '^IXIC', 's&p', '^SPX', );
205 $msg = &get_stockprice($index{$1});
206 }
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
207 elsif ($arg =~ m/^haiku\s*(.*)/i) {
2cd12fe @thepeopleseason added jsondump, fixed repeat haiku, and secrets
thepeopleseason authored
208 if ($1) {
209 &haiku($self, $to, $1);
210 }
211 else {
212 &compose_poem($self, $to);
213 }
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
214 }
e51b799 @thepeopleseason added tanka and removed remove from usage
thepeopleseason authored
215 elsif ($arg =~ m/^tanka/i) {
2cd12fe @thepeopleseason added jsondump, fixed repeat haiku, and secrets
thepeopleseason authored
216 &compose_poem($self, $to, 1);
e51b799 @thepeopleseason added tanka and removed remove from usage
thepeopleseason authored
217 }
44269eb @thepeopleseason updated
thepeopleseason authored
218 elsif ($arg =~ /^mquote (.+)/) {
219 my ($quote, $line);
220 my ($title, $pos) = find_title_quotes ($1);
221 if ($title && $pos) {
222 ($title, $quote) = pick_quote ($title, $pos);
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
223 $msg = "$title:\n" . join(' ', @$quote);
44269eb @thepeopleseason updated
thepeopleseason authored
224 }
225 else {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
226 $msg = "Sorry, $nick. I missed that one.\n";
44269eb @thepeopleseason updated
thepeopleseason authored
227 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
228 }
44269eb @thepeopleseason updated
thepeopleseason authored
229 elsif ($arg =~ /^trivia (.+)/) {
230 my ($trivia, $line);
231 my ($title, $pos) = find_title_trivia ($1);
232 if ($title && $pos) {
233 ($title, $trivia) = pick_trivia ($title, $pos);
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
234 $msg = "$title Trivia:\n" . join(' ', @$trivia);
44269eb @thepeopleseason updated
thepeopleseason authored
235 }
236 else {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
237 $msg = "Sorry, $nick. No soup for you.\n";
44269eb @thepeopleseason updated
thepeopleseason authored
238 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
239 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
240 elsif ($arg =~ /^scope\s*(.*)/i) {
7bc7205 @thepeopleseason updated dow/nasdaq and scopes: pull all into data
thepeopleseason authored
241 $msg = $data->{horoscopes}->{lc($1)};
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
242 }
44269eb @thepeopleseason updated
thepeopleseason authored
243 # elsif ($arg =~ /^countdown\s+(\d+)/) {
244 # if ($1 < 180) {
245 # sleep $1;
246 # $msg .= "this is your reminder.";
247 # }
248 # }
249 elsif ($arg =~ /^websters\s+black\s+crappie/) {
250 $msg .= q(you can't even do that, so don't even try.);
dc5896e @thepeopleseason initial commit
thepeopleseason authored
251 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
252 elsif ($arg =~ /^(saurus|roget)\s+(.*)/) {
253 $msg .= &saurus($2);
7bc7205 @thepeopleseason updated dow/nasdaq and scopes: pull all into data
thepeopleseason authored
254 }
44269eb @thepeopleseason updated
thepeopleseason authored
255 elsif ($arg =~ /^sniglet(.*)/) {
7bc7205 @thepeopleseason updated dow/nasdaq and scopes: pull all into data
thepeopleseason authored
256 $msg .= &get_sniglet($1);
257 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
258 elsif ($arg =~ /^abuse\s+([^ ]*)/) {
259 $msg = "$1, " . &get_abuse();
dc5896e @thepeopleseason initial commit
thepeopleseason authored
260 }
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
261 elsif (($arg =~ /^stfu/i) && ($type eq 'public')) {
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
262 $trans->{stfu}->{$channel} = time();
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
263 $msg = 'Right-o.';
264 }
265 elsif (($arg =~ /^speak/i) && ($type eq 'public')) {
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
266 $trans->{stfu}->{$channel} = 0;
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
267 $msg = 'Zug-zug.';
268 }
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
269 # elsif ($arg =~ /^rhetorical(.*)/) {
270 # $msg .= q(because they're stupid...);
271 # }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
272 elsif ($arg =~ /^morse\s+(.*)/) {
44269eb @thepeopleseason updated
thepeopleseason authored
273 $msg .= &get_morse($1)
dc5896e @thepeopleseason initial commit
thepeopleseason authored
274 }
44269eb @thepeopleseason updated
thepeopleseason authored
275 elsif ($arg =~ /^horoscope\s+([^\s]+)/) {
276 my $sagscope = "Dear Teeth-Shaking, Glass-Breaking,
277 Rump-Roasting Bun-Toasting Flash of Liquid Lightning: I
278 dreamed you finally revealed your secret identity after
279 all these years--you know, about how you came from the
280 planet Lovemania in order to teach all earthlings how to
281 feel horny for clouds, trees, tigers, and even the ocean
282 itself! Is my dream true? Please say it is! Tell me
283 you're really ready to drop your overly respectable pose
284 so that you may spread erotic healing throughout the
285 land! Dare to become the sublimely lustful worshiper of
286 beauty and truth you were born to be!";
287
288 if ($1 !~ /sagittarius/i) {
289 $msg = "$1, you're gonna die";
290 $msg .= " . . . twice" if ($1 =~ /gemini/i);
291 $msg .= ".";
292 }
293 else {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
294 $msg = "Sagittarius: $sagscope";
44269eb @thepeopleseason updated
thepeopleseason authored
295 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
296 }
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
297 elsif ($arg =~ /^forget\s+(.*)/) {
298 delete $data->{facts}->{$1};
299 $msg .= "baleeted.";
300 }
301 elsif ($arg =~ /^help/) {
302 my @funcs = qw(bugcount stock quote dow nasdaq s&p haiku tanka
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
303 scope saurus roget sniglet abuse morse
304 horoscope forget latest);
305 $msg .= sprintf("Usage: $mynick <%s>", join('|', @funcs));
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
306 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
307 # master commands
308 elsif ($userhost =~ m/$data->{userhost}$/i) {
44269eb @thepeopleseason updated
thepeopleseason authored
309 if ($arg =~ /^say (\S+) (.+)/i) {
310 $to = $1;
311 $msg = $2;
312 }
313 elsif ($arg =~ /^join (.*)/) {
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
314 my $newchan = $1;
315 $newchan = "#$newchan" unless $newchan =~ m/^#/;
316 $self->join($newchan);
317
318 $trans->{stfu}->{$newchan} = 0;
319 $msg .= "joining $newchan";
44269eb @thepeopleseason updated
thepeopleseason authored
320 }
321 elsif ($arg =~ /^deop (\S+) (.+)/) {
322 $to = $2;
323 $self->mode("$2", "-o", $1);
324 $msg = 'The Lord giveth and the lord taketh away...';
325 }
326 elsif ($arg =~ /^op (\S+) (.+)/) {
327 $to = $nick;
328 $self->mode("$2", "+o", $1);
329 $msg .= "op $1 on $2";
330 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
331 elsif ($arg =~ /^dumptrans\s*(.*)/) {
332 if ($1) {
333 $to = $nick;
334 $msg = Dumper($trans->{$1});
335 }
336 else {
337 print Dumper($trans);
338 undef $msg;
339 }
340 }
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
341 elsif ($arg =~ /^dump\s*(.*)/) {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
342 if ($1) {
343 $to = $nick;
344 $msg = Dumper($data->{$1});
345 }
346 else {
347 print Dumper($data);
348 undef $msg;
349 }
350 }
313b01d @thepeopleseason updated to add refresh and params to fails
thepeopleseason authored
351 elsif ($arg =~ /^refresh/) {
352 delete $data->{bugs};
353 delete $data->{hudson};
354
355 &update_bugs($self, 1);
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
356 &update_resolves($self, 1);
216c159 @thepeopleseason added closed ticket tracking
thepeopleseason authored
357 &update_closed($self, 1);
313b01d @thepeopleseason updated to add refresh and params to fails
thepeopleseason authored
358 &update_fails($self, 1);
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
359 &update_latest();
313b01d @thepeopleseason updated to add refresh and params to fails
thepeopleseason authored
360 }
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
361 elsif ($arg =~ /^cleanfacts/) {
362 for my $key (keys %{$data->{facts}}) {
363 if ($key =~ m/\s/) {
364 delete $data->{facts}->{$key};
365 }
366 }
367 }
2cd12fe @thepeopleseason added jsondump, fixed repeat haiku, and secrets
thepeopleseason authored
368 elsif ($arg =~ /^jsondump/) {
369 &write_data();
370 $msg = "Dumped.";
371 }
4fb31a2 @thepeopleseason added forget and URL to bug reports
thepeopleseason authored
372 elsif ($arg =~ /^die/) {
373 &write_data();
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
374 for my $chan (keys %{$trans->{stfu}}) {
375 for my $master (@{$trans->{master}}, "pendingo") {
376 $self->mode($chan, "+o", $master);
377 }
378 }
4fb31a2 @thepeopleseason added forget and URL to bug reports
thepeopleseason authored
379 exit();
380 }
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
381 elsif ($arg =~ /^setdata\s+(\S*)\s+(\S*)/) {
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
382 my ($k, $v) = ($1, $2);
383 if ($k =~ m/__/) {
384 my ($k1, $k2) = split(/__/, $k);
385 $data->{$k1}->{$k2} = $v;
386 }
387 else {
388 $data->{$k} = $v;
389 }
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
390 $msg = "Updated";
391 }
392 elsif ($arg =~ /^killdata\s+(\S*)/) {
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
393 my $k = $1;
394 if ($k =~ m/__/) {
395 my ($k1, $k2) = split(/__/, $k);
396 delete $data->{$k1}->{$k2};
397 }
398 else {
399 delete $data->{$1};
400 }
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
401 $msg .= "baleeted.";
402 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
403 elsif ($arg =~ /^keys/) {
404 $msg = join(', ', keys %$data);
405 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
406 }
44269eb @thepeopleseason updated
thepeopleseason authored
407 else {
408 my (@wit) =
409 (
410 "PAK CHOOIE UNF",
411 "I'll be in my bunk...",
412 "hey, how's it goin?",
413 "You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.",
414 );
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
415 push @wit, @spacerobots;
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
416 $msg .= $wit[rand(@wit)] if (rand() < $data->{talkback});
dc5896e @thepeopleseason initial commit
thepeopleseason authored
417 }
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
418 &fill_output($self, $msg, $to) unless $msg eq "$nick, ";
44269eb @thepeopleseason updated
thepeopleseason authored
419 }
216c159 @thepeopleseason added closed ticket tracking
thepeopleseason authored
420
421 if ($arg =~ /^(sudo )?(ls( .*)?|pwd|cd( .*)?|rm( .*)?)$/) {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
422 $msg = "this ain\'t your shell window";
423 $self->privmsg($to, "$msg\n")
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
424 unless ($trans->{stfu}->{$channel});
44269eb @thepeopleseason updated
thepeopleseason authored
425 }
426 elsif ($arg =~ /^(\:wq)$/) {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
427 $msg = "this ain\'t your vi";
428 $self->privmsg($to, "$msg\n")
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
429 unless ($trans->{stfu}->{$channel});
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
430 }
431 elsif ($arg =~ /PAK.*UNF/) {
432 $msg = $spacerobots[rand(@spacerobots)];
433 $self->privmsg($to, "$msg\n")
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
434 unless ($trans->{stfu}->{$channel});
44269eb @thepeopleseason updated
thepeopleseason authored
435 }
436 elsif ($arg =~ /pythonpath/i) {
437 $msg = "If you're mucking with your PYTHONPATH, you're doing it wrong.";
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
438 $self->privmsg($to,"$msg\n")
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
439 unless ($trans->{stfu}->{$channel});
44269eb @thepeopleseason updated
thepeopleseason authored
440 }
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
441 elsif ($arg =~ /time\.sleep/i) {
442 $msg = "If you're using time.sleep, you're doing it wrong.";
443 $self->privmsg($to,"$msg\n")
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
444 unless ($trans->{stfu}->{$channel});
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
445 }
2cd12fe @thepeopleseason added jsondump, fixed repeat haiku, and secrets
thepeopleseason authored
446 elsif ($arg =~ m/^You're a towel!/) {
447 if ($nick eq "Towelie") {
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
448 $msg = "No, you're a towel!" if (rand() < $data->{towel});
2cd12fe @thepeopleseason added jsondump, fixed repeat haiku, and secrets
thepeopleseason authored
449 }
450 }
1d7efb1 @thepeopleseason updated to make facts single word and fix non-ids
thepeopleseason authored
451 elsif ($arg =~ m/((CMS[A-Z]+|CHR|GUR|WD|FR|HELPDESK)-[0-9]+)/) {
44269eb @thepeopleseason updated
thepeopleseason authored
452 my $ticket = $1;
453 if ($arg !~ m{browse/$1}) {
454 # record recent tickets
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
455 my $time = time();
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
456 if ($time - $trans->{recent}->{$ticket}->{time} > 10*60) {
457 $trans->{recent}->{$ticket}->{time} = time();
458 $trans->{recent}->{$ticket}->{count} = 1;
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
459 }
460 else {
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
461 if ($time - $trans->{recent}->{$ticket}->{time} < 20) {
462 $trans->{recent}->{$ticket}->{count}++;
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
463 }
464 }
44269eb @thepeopleseason updated
thepeopleseason authored
465
466 # check message type
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
467 if ($trans->{recent}->{$ticket}->{count} > 4) {
44269eb @thepeopleseason updated
thepeopleseason authored
468 undef $msg;
469 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
470 elsif ($trans->{recent}->{$ticket}->{count} > 3) {
44269eb @thepeopleseason updated
thepeopleseason authored
471 $msg = "Seriously, dude. That's annoying. Quit it.";
472 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
473 elsif ($trans->{recent}->{$ticket}->{count} > 2) {
44269eb @thepeopleseason updated
thepeopleseason authored
474 $msg = "Dude, quit it.";
475 }
476 else {
477 $msg =
478 "$nick may be talking about: " .
479 "http://jira.ddtc.cmgdigital.com/browse/$1";
480 }
481
482 # output message
483 if ($msg) {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
484 $self->privmsg($to, "$msg\n")
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
485 unless ($trans->{stfu}->{$channel});
44269eb @thepeopleseason updated
thepeopleseason authored
486 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
487 }
44269eb @thepeopleseason updated
thepeopleseason authored
488 }
f83a258 @thepeopleseason updated to add trans data struct and other changes
thepeopleseason authored
489 elsif ($arg =~ m/^((\S*?)\s+(is|are|=)\s+([^;\?]*))$/i) {
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
490 my ($sentence, $subject, $predicate) = ($1, $2, $4);
449fd69 @thepeopleseason updated to be non-greedy with facts and block backticks
thepeopleseason authored
491 if ($predicate =~ m/\`/) {
492 $self->privmsg($to, "You can't even do that, so don't even try.");
493 }
494 elsif ($predicate =~ m/^<reply>\s*/) {
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
495 $predicate =~ s/^<reply>\s*//;
496 $data->{facts}->{lc($subject)} = "$predicate ($nick)";
497 }
498 else {
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
499 $data->{facts}->{lc($subject)} = "$sentence ($nick)"
500 unless $data->{facts}->{lc($subject)};
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
501 }
502 }
503 elsif ($arg =~ m/^(.*)\?$/) {
504 $self->privmsg($to, $data->{facts}->{lc($1)});
505 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
506 }
507
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
508 sub fill_output {
509 my ($self, $msg, $to) = @_;
44269eb @thepeopleseason updated
thepeopleseason authored
510
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
511 # kill existing lines
512 $msg =~ s/\n/ /g;
44269eb @thepeopleseason updated
thepeopleseason authored
513
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
514 my @result = split(/\n/, fill('', '', $msg));
515 for my $line (@result) {
516 $self->privmsg($to, $line);
517 sleep 1;
44269eb @thepeopleseason updated
thepeopleseason authored
518 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
519 }
520
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
521 sub haiku {
522 my ($conn, $to, $args) = @_;
523
e51b799 @thepeopleseason added tanka and removed remove from usage
thepeopleseason authored
524 my $usage = "Usage: haiku add (fives|sevens) <phrase>\n";
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
525
526
527 if ($args) {
528 $args =~ m/^(\S*)\s+(\S*)\s+(.*)$/;
529 my ($proc, $type, $phrase) = ($1, $2, $3);
530
531 if (($proc !~ m/^(add|remove)/i) || ($type !~ m/^(five|seven)s/i)) {
532 $conn->privmsg($to, $usage);
533 return;
534 }
535 if ($proc =~ m/^add$/i) {
536 push @{$data->{haiku}->{lc($type)}}, $phrase;
537 $conn->privmsg($to, "Added.\n");
538 }
539 else {
540 @{$data->{haiku}->{lc($type)}} =
541 grep {!/$phrase/} @{$data->{haiku}->{lc($type)}};
542 $conn->privmsg($to, "Removed.\n");
543 }
544 }
545 }
546
2cd12fe @thepeopleseason added jsondump, fixed repeat haiku, and secrets
thepeopleseason authored
547 sub compose_poem {
548 my ($conn, $to, $type) = @_;
549
550 my @fives;
551 my @sevens;
552 push @fives, @{$data->{haiku}->{fives}};
553 push @sevens, @{$data->{haiku}->{sevens}};
554
555 my $five = $fives[rand(@fives)];
556 @fives = grep {!/$five/} @fives;
557
558 my $seven1 = $sevens[rand(@sevens)];
559 @sevens = grep {!/$seven1/} @sevens;
560 my $seven2 = $sevens[rand(@sevens)];
561 @sevens = grep {!/$seven2/} @sevens;
562
563 $conn->privmsg($to, $five);
564 $conn->privmsg($to, $seven1);
565 $conn->privmsg($to, $fives[rand(@fives)]);
566 $conn->privmsg($to, $seven2) if ($type);
567 $conn->privmsg($to, $sevens[rand(@sevens)]) if ($type);
568 }
c6f3431 @thepeopleseason added haiku, facts
thepeopleseason authored
569
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
570 sub saurus {
571 my @args = @_;
44269eb @thepeopleseason updated
thepeopleseason authored
572
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
573 my %rtypes = qw( sim similar syn synonyms ant antonyms usr user-submitted );
44269eb @thepeopleseason updated
thepeopleseason authored
574
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
575 my $apikey = q(ab4c2716b98b1c76f4b889014214dadb);
576 my $url = sprintf(qq(http://words.bighugelabs.com/api/2/%s/%s/json),
577 $apikey, $args[0]
578 );
44269eb @thepeopleseason updated
thepeopleseason authored
579
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
580 my $hash = decode_json(get($url));
44269eb @thepeopleseason updated
thepeopleseason authored
581
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
582 my $result = "$args[0]: ";
583 for my $key (keys %$hash) {
584 next if $args[1] && $key ne $args[1];
44269eb @thepeopleseason updated
thepeopleseason authored
585
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
586 for my $type (keys %{$hash->{$key}}) {
587 $result .= "* $rtypes{$type} ($key) - " .
588 join(', ', @{$hash->{$key}->{$type}}) . "\n";
589 }
44269eb @thepeopleseason updated
thepeopleseason authored
590 }
591 return $result;
dc5896e @thepeopleseason initial commit
thepeopleseason authored
592 }
593
594 sub get_stockprice {
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
595 my ($args) = @_;
dc5896e @thepeopleseason initial commit
thepeopleseason authored
596
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
597 my $stocks =
598 get(sprintf('http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=snl1c1',
599 join('+', split(/\s/, $args)))
600 );
44269eb @thepeopleseason updated
thepeopleseason authored
601
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
602 $stocks =~ s/,/\t/g;
603 $stocks =~ s/"//g;
44269eb @thepeopleseason updated
thepeopleseason authored
604
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
605 return $stocks;
44269eb @thepeopleseason updated
thepeopleseason authored
606
35eabca @thepeopleseason updated olga with stock & horoscopes
thepeopleseason authored
607 print $stocks;
44269eb @thepeopleseason updated
thepeopleseason authored
608
dc5896e @thepeopleseason initial commit
thepeopleseason authored
609 }
610
44269eb @thepeopleseason updated
thepeopleseason authored
611 sub get_morse {
612 my $inarg = shift;
613 my ($result, $trans, $splitter);
614
615 my %alpha2morse =
616 ( 'a', '.-', 'b', '-...', 'c', '-.-.', 'd', '-..', 'e', '.', 'f',
617 '..-.', 'g', '--.', 'h', '....', 'i', '..', 'j', '.---', 'k',
618 '-.-', 'l', '.-..', 'm', '--', 'n', '-.', 'o', '---', 'p',
619 '.--.', 'q', '--.-', 'r', '.-.', 's', '...', 't', '-', 'u',
620 '..-', 'v', '...-', 'w', '.--', 'x', '-..-', 'y', '-.--', 'z',
621 '--..', '1', '.----', '2', '..---', '3', '...--', '4', '....-',
622 '5', '.....', '6', '-....', '7', '--...', '8', '---..', '9',
623 '----.', '0', '-----', "\n", "\n", ' ', ' ',);
624
dc5896e @thepeopleseason initial commit
thepeopleseason authored
625 my %morse2alpha = reverse %alpha2morse;
626
627 if ($inarg =~ /[A-Za-z0-9]/) {
628 $inarg = lc($inarg);
629 $trans = \%alpha2morse;
630 $splitter = "";
631 }
632 else {
44269eb @thepeopleseason updated
thepeopleseason authored
633 $inarg =~ s/\_/\-/g;
dc5896e @thepeopleseason initial commit
thepeopleseason authored
634 $trans = \%morse2alpha;
635 $splitter = " ";
636 }
637 my @morsey = split (/$splitter/, $inarg);
44269eb @thepeopleseason updated
thepeopleseason authored
638
dc5896e @thepeopleseason initial commit
thepeopleseason authored
639 foreach my $elem (@morsey) {
640 $result .= $trans->{"$elem"}," ";
641 }
44269eb @thepeopleseason updated
thepeopleseason authored
642
643 return $result;
644 }
645
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
646 sub update_horoscopes {
7bc7205 @thepeopleseason updated dow/nasdaq and scopes: pull all into data
thepeopleseason authored
647 my $time = time();
648 if ($time - $data->{horoscopes}->{update} > 86400) {
649 my $page =
650 get(q(http://www.freewillastrology.com/horoscopes/printer-friendly.html));
651
652 my $cursign;
653 for my $line (split(/\n/, $page)) {
654 next unless ($line =~ m/div class="body-bold">(\S*)\s+\(/i ..
655 $line =~ m%<p>%i);
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
656 if ($1) {
657 $cursign = lc($1);
658 delete $data->{horoscopes}->{$cursign};
659 }
7bc7205 @thepeopleseason updated dow/nasdaq and scopes: pull all into data
thepeopleseason authored
660 $line =~ s/<[^>]*>//g;
661 $line =~ s/\)/\) /g;
662
663 $data->{horoscopes}->{$cursign} .= $line;
664 }
665 $data->{horoscopes}->{update} = time();
44269eb @thepeopleseason updated
thepeopleseason authored
666 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
667 }
668
669 sub get_sniglet {
44269eb @thepeopleseason updated
thepeopleseason authored
670 my $wordlet = shift;
671 my ($sniglets) = ("/home/james/devel/cim/projects/01_olga/data/sniglets.txt");
672 my ($result);
673
674 $wordlet =~ s/\s*//g;
675
676 open(SNG,"<$sniglets") || warn "can't open $sniglets: $!";
677 if ($wordlet) {
678 while (<SNG>) {
679 if (/^$wordlet/i) {
680 chomp($_);
681 $result = $_;
682 last;
683 }
dc5896e @thepeopleseason initial commit
thepeopleseason authored
684 }
44269eb @thepeopleseason updated
thepeopleseason authored
685 }
686 else {
687 rand($.) < 1 && ($result = $_) while <SNG>;
688 }
689 close SNG;
690 $result = "I dunno..." if (!$result);
691 return $result;
dc5896e @thepeopleseason initial commit
thepeopleseason authored
692 }
693
44269eb @thepeopleseason updated
thepeopleseason authored
694 sub get_abuse {
695 my @styles = (0, 3);
696 my $style = $styles[rand(@styles)];
697 my $url = sprintf('http://www.webinsult.com/index.php?style=%s',
698 $style);
699
700 my ($insult) = grep {/id="insult"/} split(/\n/,get($url));
701 $insult =~ s/<[^>]*>//g;
702 return lcfirst($insult);
dc5896e @thepeopleseason initial commit
thepeopleseason authored
703 }
704
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
705 sub update_bugs {
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
706 my ($self, $init) = @_;
707
708 my $bugs_rss = 'http://jira.ddtc.cmgdigital.com/sr/jira.issueviews:searchrequest-xml/10204/SearchRequest-10204.xml';
709
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
710 eval {
711 my $rss = XML::RSS->new;
712 $rss->parse(get($bugs_rss));
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
713
6e53657 @thepeopleseason added bug squashing
thepeopleseason authored
714 my %confirmed;
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
715 for my $item (@{$rss->{'items'}}) {
6e53657 @thepeopleseason added bug squashing
thepeopleseason authored
716 $confirmed{$item->{key}} = 1;
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
717 unless ($data->{bugs}->{$item->{key}}) {
718 $data->{bugs}->{$item->{key}} = $item->{title};
4fb31a2 @thepeopleseason added forget and URL to bug reports
thepeopleseason authored
719
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
720 unless ($init) {
721 my $id = $item->{key};
722 $id =~ s/[\[\]]//g;
723 my $url = sprintf("http://jira.ddtc.cmgdigital.com/browse/%s",
724 $id);
4fb31a2 @thepeopleseason added forget and URL to bug reports
thepeopleseason authored
725 $self->privmsg($channel,
df9f3f6 @thepeopleseason removed cmheisel from new bug notification
thepeopleseason authored
726 sprintf("*** New bug! %s %s\n",
4fb31a2 @thepeopleseason added forget and URL to bug reports
thepeopleseason authored
727 $item->{title}, $url)
728 );
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
729 }
730 }
731 }
6e53657 @thepeopleseason added bug squashing
thepeopleseason authored
732 for my $key (keys %{$data->{bugs}}) {
733 delete ($data->{bugs}->{$key})
734 unless $confirmed{$key};
735 }
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
736 };
737 if ($@) {
738 print "$@";
739 }
740 }
741
742 sub update_resolves {
743 my ($self, $init) = @_;
744
745 my $resolved_rss = 'http://jira.ddtc.cmgdigital.com/sr/jira.issueviews:searchrequest-xml/10239/SearchRequest-10239.xml?tempMax=25';
746
747 eval {
748 my $rss = XML::RSS->new;
749 $rss->parse(get($resolved_rss));
750
751
752 for my $item (@{$rss->{'items'}}) {
753 unless ($data->{resolves}->{$item->{key}}) {
754 $data->{resolves}->{$item->{key}} = $item->{title};
755
756 unless ($init) {
757 my $id = $item->{key};
758 $id =~ s/[\[\]]//g;
759 my $url = sprintf("http://jira.ddtc.cmgdigital.com/browse/%s",
760 $id);
761 $self->privmsg("#qa",
762 sprintf("*** Resolved! %s %s\n",
763 $item->{title}, $url)
764 );
765 }
4fb31a2 @thepeopleseason added forget and URL to bug reports
thepeopleseason authored
766 }
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
767 }
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
768 };
769 if ($@) {
770 print "$@";
2c53dfd @thepeopleseason olga updates
thepeopleseason authored
771 }
772 }
773
216c159 @thepeopleseason added closed ticket tracking
thepeopleseason authored
774 sub update_closed {
775 my ($self, $init) = @_;
776
777 my $closed_rss = 'http://jira.ddtc.cmgdigital.com/sr/jira.issueviews:searchrequest-xml/10303/SearchRequest-10303.xml?tempMax=1000';
778
779 eval {
780 my $rss = XML::RSS->new;
781 $rss->parse(get($closed_rss));
782
783 for my $item (@{$rss->{'items'}}) {
784 unless (grep { /^$item->{key}$/ } @{$data->{closed}}) {
785 push @{$data->{closed}}, $item->{key};
786
787 unless ($init) {
788 my $id = $item->{key};
789 $id =~ s/[\[\]]//g;
790 $self->privmsg("#all",
791 sprintf("*** Closed! %s %s\n",
792 $item->{title}, $id)
793 );
794 }
795 }
796 }
797 };
798 if ($@) {
799 print "$@";
800 }
801 }
802
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
803 sub update_fails {
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
804 my ($self, $init) = @_;
805
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
806 eval {
807 my $feed = XMLin(
808 get('http://vcs.ddtc.cmgdigital.com:9191/hudson/rssFailed')
809 );
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
810
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
811 my $skipfails = join('|', qw( gitstat newmaster.signin ));
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
812
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
813 for my $key (keys %{$feed->{entry}}) {
814 my $entry = $feed->{entry}->{$key};
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
815
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
816 unless ($data->{hudson}->{$entry->{title}}) {
817 $data->{hudson}->{$entry->{title}} = $entry->{link}->{href};
818 unless ($init) {
819 my $params = get($entry->{link}->{href});
820 $params =~ s/^.*buildWithParameters\?([^"]*)".*$/$1/s;
313b01d @thepeopleseason updated to add refresh and params to fails
thepeopleseason authored
821
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
822 $params = join(' ',
823 map { my ($k, $v) = split(/=/,$_); "$bParams{$k}: $v" }
824 split(/\&amp;/, $params));
313b01d @thepeopleseason updated to add refresh and params to fails
thepeopleseason authored
825
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
826 $self->privmsg($channel,
827 "$entry->{title}: $entry->{link}->{href} $params\n")
828 unless ($entry->{title} =~ m/$skipfails/i)
829 }
fff8001 @thepeopleseason added help, fixed facts and added set/killdata
thepeopleseason authored
830 }
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
831 }
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
832 };
833 if ($@) {
834 print $@;
88ffc53 @thepeopleseason added hudson build failures
thepeopleseason authored
835 }
836 }
837
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
838 sub update_latest {
839 my @urls = qw(view/Developer%20View/rssLatest rssLatest);
840 my $dtf = DateTime::Format::W3CDTF->new;
841
842 for my $url (@urls) {
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
843 eval {
844 my $feed =
845 XMLin(
846 get(sprintf(
847 'http://vcs.ddtc.cmgdigital.com:9191/hudson/%s',
848 $url,
849 )));
850
851 for my $key (keys %{$feed->{entry}}) {
852 my $entry = $feed->{entry}->{$key};
853
854 my $latestkey = lc($entry->{title});
855 $latestkey =~ s/^(\S*)\s+.*/$1/;
856
857 my $dt = $dtf->parse_datetime($entry->{published})
858 ->set_time_zone('local');
859
860 $data->{latest}->{$latestkey} = sprintf('%s %s %s',
861 $dt->strftime('%F %T'),
862 $entry->{title},
863 $entry->{link}->{href},
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
864 );
eea7e66 @thepeopleseason updated to eval rss fetches
thepeopleseason authored
865 }
866 };
867 if ($@) {
868 print $@;
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
869 }
870 }
871 }
872
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
873 sub init_data {
874 my ($conn) = @_;
875
876 if (!-e $data->{jsonfile}) {
877 &update_bugs($conn, 1);
c4dc1c7 @thepeopleseason updated with resolves and other changes
thepeopleseason authored
878 &update_resolves($conn, 1);
216c159 @thepeopleseason added closed ticket tracking
thepeopleseason authored
879 &update_closed($conn, 1);
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
880 &update_fails($conn, 1);
feb4c30 @thepeopleseason updated to add latest build checker
thepeopleseason authored
881 &update_latest();
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
882 &update_horoscopes();
883
884 &write_data();
885 }
886
887 open(FILE,"<$data->{jsonfile}") || warn "Can't open $data->{jsonfile}: $!";
888 my $json = do { local $/; <FILE>; };
889 close(FILE);
890
891 $data = decode_json($json);
892 }
893
894 sub write_data {
895 my $json = encode_json($data);
44269eb @thepeopleseason updated
thepeopleseason authored
896
4d17276 @thepeopleseason added json data persistence and load
thepeopleseason authored
897 open(FILE,">$data->{jsonfile}") || warn "Can't open $data->{jsonfile}: $!";
898 print FILE $json;
899 close(FILE);
44269eb @thepeopleseason updated
thepeopleseason authored
900 }
Something went wrong with that request. Please try again.