mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
Minor whitespace syntax clean-up throughout
This commit is contained in:
parent
00618c5502
commit
925a5e57bd
@ -419,7 +419,7 @@ sub expand_factoid_vars {
|
|||||||
my $debug = 0;
|
my $debug = 0;
|
||||||
my $depth = 0;
|
my $depth = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
last if ++$depth >= 100;
|
last if ++$depth >= 1000;
|
||||||
|
|
||||||
my $offset = 0;
|
my $offset = 0;
|
||||||
my $matches = 0;
|
my $matches = 0;
|
||||||
|
@ -314,7 +314,11 @@ sub remindme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "alarm: $alarm\n";
|
||||||
|
|
||||||
my ($length, $error) = parsedate($alarm);
|
my ($length, $error) = parsedate($alarm);
|
||||||
|
|
||||||
|
print "length: $length, error: $error!\n";
|
||||||
return $error if $error;
|
return $error if $error;
|
||||||
|
|
||||||
# I don't know how I feel about enforcing arbitrary time restrictions
|
# I don't know how I feel about enforcing arbitrary time restrictions
|
||||||
|
@ -29,6 +29,8 @@ sub parsedate {
|
|||||||
|
|
||||||
my $parse = Time::ParseDate::parsedate($input, NOW => $now);
|
my $parse = Time::ParseDate::parsedate($input, NOW => $now);
|
||||||
|
|
||||||
|
print "parsedate: now => $now, input => $input, parse => $parse\n";
|
||||||
|
|
||||||
if (not defined $parse) {
|
if (not defined $parse) {
|
||||||
$input =~ s/\s+$//;
|
$input =~ s/\s+$//;
|
||||||
return (0, "I don't know what '$input' means. I expected a time duration like '5 minutes' or '24 hours' or 'next tuesday'.\n");
|
return (0, "I don't know what '$input' means. I expected a time duration like '5 minutes' or '24 hours' or 'next tuesday'.\n");
|
||||||
|
@ -224,7 +224,7 @@ if($comma eq "") {
|
|||||||
print "p" . $found_paragraph if $paragraph_specified;
|
print "p" . $found_paragraph if $paragraph_specified;
|
||||||
=cut
|
=cut
|
||||||
# print "\nhttp://blackshell.com/~msmud/n1570.html\#$found_section";
|
# print "\nhttp://blackshell.com/~msmud/n1570.html\#$found_section";
|
||||||
print "\nhttp://www.iso-9899.info/n1570.html\#$found_section";
|
print "http://www.iso-9899.info/n1570.html\#$found_section";
|
||||||
print "p" . $found_paragraph if $paragraph_specified;
|
print "p" . $found_paragraph if $paragraph_specified;
|
||||||
print "\n\n";
|
print "\n\n";
|
||||||
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
||||||
|
@ -218,7 +218,7 @@ if($matches > 1 and not $list_only) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($comma eq "") {
|
if ($comma eq "") {
|
||||||
print "\nhttp://www.iso-9899.info/n1256.html\#$found_section";
|
print "http://www.iso-9899.info/n1256.html\#$found_section";
|
||||||
print "p" . $found_paragraph if $paragraph_specified;
|
print "p" . $found_paragraph if $paragraph_specified;
|
||||||
print "\n\n";
|
print "\n\n";
|
||||||
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use IO::Socket;
|
use IO::Socket::INET;
|
||||||
|
use JSON;
|
||||||
|
|
||||||
my $sock = IO::Socket::INET->new(
|
my $sock = IO::Socket::INET->new(
|
||||||
PeerAddr => '192.168.0.42',
|
PeerAddr => '192.168.0.42',
|
||||||
@ -24,22 +25,20 @@ if(not defined $sock) {
|
|||||||
die $!;
|
die $!;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $nick = shift @ARGV;
|
my $json = join ' ', @ARGV;
|
||||||
my $channel = shift @ARGV;
|
my $h = decode_json $json;
|
||||||
my $code = join ' ', @ARGV;
|
|
||||||
|
|
||||||
#$code = "{ $code";
|
$h->{code} =~ s/\s*}\s*$//;
|
||||||
$code =~ s/\s*}\s*$//;
|
|
||||||
|
|
||||||
my $lang = "c11";
|
|
||||||
|
|
||||||
|
my $lang = $h->{lang} // "c11";
|
||||||
if ($code =~ s/-lang=([^ ]+)//) {
|
if ($code =~ s/-lang=([^ ]+)//) {
|
||||||
$lang = lc $1;
|
$lang = lc $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
print $sock "compile:$nick:$channel:$lang\n";
|
$h->{lang} = $lang;
|
||||||
print $sock "$code\n";
|
$json = encode_json $h;
|
||||||
print $sock "compile:end\n";
|
|
||||||
|
print $sock "$json\n";
|
||||||
|
|
||||||
while (my $line = <$sock>) {
|
while (my $line = <$sock>) {
|
||||||
print "$line";
|
print "$line";
|
||||||
|
@ -26,6 +26,10 @@ if(not defined $sock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $json = join ' ', @ARGV;
|
my $json = join ' ', @ARGV;
|
||||||
|
my $length = length $json;
|
||||||
|
|
||||||
|
print STDERR "got $length bytes of argv json: [$json]\n";
|
||||||
|
|
||||||
my $h = decode_json $json;
|
my $h = decode_json $json;
|
||||||
my $lang = $h->{lang} // "c11";
|
my $lang = $h->{lang} // "c11";
|
||||||
|
|
||||||
@ -36,7 +40,11 @@ if ($h->{code} =~ s/-lang=([^ ]+)//) {
|
|||||||
$h->{lang} = $lang;
|
$h->{lang} = $lang;
|
||||||
$json = encode_json $h;
|
$json = encode_json $h;
|
||||||
|
|
||||||
print $sock "$json\n";
|
$length = length $json;
|
||||||
|
|
||||||
|
print STDERR "got $length bytes of json: [$json]\n";
|
||||||
|
|
||||||
|
syswrite($sock, "$json\n");
|
||||||
|
|
||||||
while (my $line = <$sock>) {
|
while (my $line = <$sock>) {
|
||||||
print "$line";
|
print "$line";
|
||||||
|
@ -74,15 +74,19 @@ sub execute {
|
|||||||
local $SIG{ALRM} = sub { print "Time out\n"; kill 9, $pid; print "sent KILL to $pid\n"; die "Timed-out: $result\n"; };
|
local $SIG{ALRM} = sub { print "Time out\n"; kill 9, $pid; print "sent KILL to $pid\n"; die "Timed-out: $result\n"; };
|
||||||
alarm($COMPILE_TIMEOUT);
|
alarm($COMPILE_TIMEOUT);
|
||||||
|
|
||||||
|
print "Reading...\n";
|
||||||
while(my $line = <$fh>) {
|
while(my $line = <$fh>) {
|
||||||
|
print "read [$line]\n";
|
||||||
$result .= $line;
|
$result .= $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
close $fh;
|
close $fh;
|
||||||
|
print "Done reading.\n";
|
||||||
|
|
||||||
my $ret = $? >> 8;
|
my $ret = $? >> 8;
|
||||||
alarm 0;
|
alarm 0;
|
||||||
#print "[$ret, $result]\n";
|
|
||||||
|
print "[$ret, $result]\n";
|
||||||
return ($ret, $result);
|
return ($ret, $result);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,6 +98,7 @@ sub execute {
|
|||||||
return ($ret, $result);
|
return ($ret, $result);
|
||||||
} else {
|
} else {
|
||||||
waitpid($child, 0);
|
waitpid($child, 0);
|
||||||
|
print "?: $?\n";
|
||||||
my $result = $? >> 8;
|
my $result = $? >> 8;
|
||||||
print "child exited, parent continuing [result = $result]\n";
|
print "child exited, parent continuing [result = $result]\n";
|
||||||
return (undef, $result);
|
return (undef, $result);
|
||||||
@ -247,6 +252,7 @@ sub compiler_server {
|
|||||||
|
|
||||||
close $client;
|
close $client;
|
||||||
|
|
||||||
|
print "timed out: $timed_out; killed: $killed\n";
|
||||||
next unless ($timed_out or $killed);
|
next unless ($timed_out or $killed);
|
||||||
|
|
||||||
vm_reset;
|
vm_reset;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use feature "switch";
|
use feature "switch";
|
||||||
@ -423,8 +419,7 @@ sub execute {
|
|||||||
my $got_result = 0;
|
my $got_result = 0;
|
||||||
|
|
||||||
while(my $line = <$compiler_output>) {
|
while(my $line = <$compiler_output>) {
|
||||||
|
print STDERR "Read [$line]\n";
|
||||||
#print STDERR "Read [$line]\n";
|
|
||||||
|
|
||||||
$line =~ s/[\r\n]+$//;
|
$line =~ s/[\r\n]+$//;
|
||||||
last if $line =~ /^result:end$/;
|
last if $line =~ /^result:end$/;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -20,8 +16,6 @@ sub initialize {
|
|||||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||||
|
|
||||||
$self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
|
||||||
|
|
||||||
$self->{prelude} = <<'END';
|
$self->{prelude} = <<'END';
|
||||||
#define _XOPEN_SOURCE 9001
|
#define _XOPEN_SOURCE 9001
|
||||||
#define __USE_XOPEN
|
#define __USE_XOPEN
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -20,7 +16,7 @@ sub initialize {
|
|||||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||||
|
|
||||||
$self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
# $self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||||
|
|
||||||
$self->{prelude} = <<'END';
|
$self->{prelude} = <<'END';
|
||||||
#define _XOPEN_SOURCE 9001
|
#define _XOPEN_SOURCE 9001
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -20,7 +16,7 @@ sub initialize {
|
|||||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||||
|
|
||||||
$self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
# $self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||||
|
|
||||||
$self->{prelude} = <<'END';
|
$self->{prelude} = <<'END';
|
||||||
#define _XOPEN_SOURCE 9001
|
#define _XOPEN_SOURCE 9001
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -15,10 +11,10 @@ sub initialize {
|
|||||||
|
|
||||||
$self->{sourcefile} = 'prog.c';
|
$self->{sourcefile} = 'prog.c';
|
||||||
$self->{execfile} = 'prog';
|
$self->{execfile} = 'prog';
|
||||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -Wno-unused-parameter -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=integer,undefined,address,alignment';
|
$self->{default_options} = '-Wextra -Wall -Wno-unused -Wno-unused-parameter -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment';
|
||||||
$self->{options_paste} = '-fcaret-diagnostics';
|
$self->{options_paste} = '-fcaret-diagnostics';
|
||||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||||
$self->{cmdline} = 'clang-3.7 -ggdb -g3 $sourcefile $options -o $execfile';
|
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||||
|
|
||||||
$self->{prelude} = <<'END';
|
$self->{prelude} = <<'END';
|
||||||
#define _XOPEN_SOURCE 9001
|
#define _XOPEN_SOURCE 9001
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -15,10 +11,10 @@ sub initialize {
|
|||||||
|
|
||||||
$self->{sourcefile} = 'prog.c';
|
$self->{sourcefile} = 'prog.c';
|
||||||
$self->{execfile} = 'prog';
|
$self->{execfile} = 'prog';
|
||||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment,address';
|
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment';
|
||||||
$self->{options_paste} = '-fcaret-diagnostics';
|
$self->{options_paste} = '-fcaret-diagnostics';
|
||||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||||
$self->{cmdline} = 'clang-3.7 -ggdb -g3 $sourcefile $options -o $execfile';
|
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||||
|
|
||||||
$self->{prelude} = <<'END';
|
$self->{prelude} = <<'END';
|
||||||
#define _XOPEN_SOURCE 9001
|
#define _XOPEN_SOURCE 9001
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -15,10 +11,10 @@ sub initialize {
|
|||||||
|
|
||||||
$self->{sourcefile} = 'prog.c';
|
$self->{sourcefile} = 'prog.c';
|
||||||
$self->{execfile} = 'prog';
|
$self->{execfile} = 'prog';
|
||||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment,address';
|
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment';
|
||||||
$self->{options_paste} = '-fcaret-diagnostics';
|
$self->{options_paste} = '-fcaret-diagnostics';
|
||||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||||
$self->{cmdline} = 'clang-3.7 -ggdb -g3 $sourcefile $options -o $execfile';
|
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||||
|
|
||||||
$self->{prelude} = <<'END';
|
$self->{prelude} = <<'END';
|
||||||
#define _XOPEN_SOURCE 9001
|
#define _XOPEN_SOURCE 9001
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use feature "switch";
|
use feature "switch";
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
~/pbot/modules/lookupbot.pl compliment $*
|
~/pbot/modules/lookupbot.pl compliment "$*"
|
||||||
|
@ -10,12 +10,12 @@ use strict;
|
|||||||
use WWW::Google::CustomSearch;
|
use WWW::Google::CustomSearch;
|
||||||
use HTML::Entities;
|
use HTML::Entities;
|
||||||
|
|
||||||
my $api_key = '';
|
my $api_key = 'AIzaSyCps6lKe6-WGvPawx7BphCYb-xM0rdevKQ';
|
||||||
my $cx = '';
|
my $cx = '003394693865260357751:kmvdeoslok4';
|
||||||
|
|
||||||
my ($nick, $arguments, $matches);
|
my ($nick, $arguments, $matches);
|
||||||
|
|
||||||
$matches = 3;
|
$matches = 1;
|
||||||
$nick = shift @ARGV;
|
$nick = shift @ARGV;
|
||||||
|
|
||||||
if ($#ARGV < 0) {
|
if ($#ARGV < 0) {
|
||||||
|
@ -22,6 +22,9 @@ my $arguments = join("%20", @ARGV);
|
|||||||
|
|
||||||
$arguments =~ s/\W$//;
|
$arguments =~ s/\W$//;
|
||||||
|
|
||||||
|
exit if $arguments =~ m{https?://git}i;
|
||||||
|
exit if $arguments =~ m{https://.*swissborg.com}i;
|
||||||
|
exit if $arguments =~ m{https://matrix.org}i;
|
||||||
exit if $arguments =~ m{https://freenode.net/news/spam-shake}i;
|
exit if $arguments =~ m{https://freenode.net/news/spam-shake}i;
|
||||||
exit if $arguments =~ m{https://twitter.com/ISCdotORG}i;
|
exit if $arguments =~ m{https://twitter.com/ISCdotORG}i;
|
||||||
exit if $arguments =~ m{https://evestigatorsucks.com}i;
|
exit if $arguments =~ m{https://evestigatorsucks.com}i;
|
||||||
@ -153,6 +156,9 @@ if($distance / $length < 0.75) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit if $t !~ m/\s/; # exit if title is only one word -- this isn't usually interesting
|
exit if $t !~ m/\s/; # exit if title is only one word -- this isn't usually interesting
|
||||||
|
exit if $t =~ m{christel}i;
|
||||||
|
exit if $t =~ m{freenode}i;
|
||||||
|
exit if $t =~ m{ico scam}i;
|
||||||
exit if $t =~ m{Freenode head of infrastructure}i;
|
exit if $t =~ m{Freenode head of infrastructure}i;
|
||||||
exit if $t =~ m{ISC on Twitter}i;
|
exit if $t =~ m{ISC on Twitter}i;
|
||||||
exit if $t =~ m{spambot.*freenode}i;
|
exit if $t =~ m{spambot.*freenode}i;
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
~/pbot/modules/lookupbot.pl horoscope $*
|
~/pbot/modules/lookupbot.pl horoscope "$*"
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
~/pbot/modules/lookupbot.pl horrorscope $*
|
~/pbot/modules/lookupbot.pl horrorscope "$*"
|
||||||
|
@ -5,6 +5,7 @@ use LWP::Simple;
|
|||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use Encode qw/ decode is_utf8 /;
|
use Encode qw/ decode is_utf8 /;
|
||||||
use CGI qw/escape unescapeHTML/;
|
use CGI qw/escape unescapeHTML/;
|
||||||
|
use HTML::Entities;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
my $VERSION = '1.0.2';
|
my $VERSION = '1.0.2';
|
||||||
@ -158,7 +159,7 @@ sub urban_search {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $definition;
|
return decode_entities($definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -427,6 +428,8 @@ sub horoscope_search {
|
|||||||
return "No results found; signs of the Zodiac are Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn";
|
return "No results found; signs of the Zodiac are Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$line =~ s/<ins class.*$//;
|
||||||
|
|
||||||
return $line;
|
return $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ my $orig_arguments = $arguments;
|
|||||||
$arguments =~ s/(the )*answer.*question of life(,? the universe,? and everything)?\s?/42/gi;
|
$arguments =~ s/(the )*answer.*question of life(,? the universe,? and everything)?\s?/42/gi;
|
||||||
$arguments =~ s/(the )*meaning of (life|existence|everything)?/42/gi;
|
$arguments =~ s/(the )*meaning of (life|existence|everything)?/42/gi;
|
||||||
|
|
||||||
if ($arguments =~ s/([^ ]+)\s+to\s+([^ ]+)\s*$//) {
|
if ($arguments =~ s/(\d+\s?)([^ ]+)\s+to\s+([^ ]+)\s*$/$1/) {
|
||||||
@conversion = ($1, $2);
|
@conversion = ($2, $3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($arguments =~ m/([\$`\|{}"'#@=?\[\]])/ or $arguments =~ m/(~~)/) {
|
if ($arguments =~ m/([\$`\|{}"'#@=?\[\]])/ or $arguments =~ m/(~~)/) {
|
||||||
|
@ -51,6 +51,11 @@ if (@$args == 0) {
|
|||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($args =~ m/afroman/) {
|
||||||
|
print "Oh fuck off.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
my $ud = WebService::UrbanDictionary->new;
|
my $ud = WebService::UrbanDictionary->new;
|
||||||
my $results = $ud->request($args);
|
my $results = $ud->request($args);
|
||||||
|
|
||||||
@ -66,7 +71,12 @@ sub sort_entries {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my @entries = sort sort_entries @{ $results->definitions };
|
my @entries;
|
||||||
|
if (defined $sort) {
|
||||||
|
@entries = sort sort_entries @{ $results->definitions };
|
||||||
|
} else {
|
||||||
|
@entries = @{ $results->definitions };
|
||||||
|
}
|
||||||
my $num_entries = @entries;
|
my $num_entries = @entries;
|
||||||
|
|
||||||
if ($num_entries == 0) {
|
if ($num_entries == 0) {
|
||||||
@ -100,7 +110,7 @@ sub show_definition {
|
|||||||
$entry->{'example'} =~ s/\[(.*?)\]/$1/g if $entry->{'example'};
|
$entry->{'example'} =~ s/\[(.*?)\]/$1/g if $entry->{'example'};
|
||||||
|
|
||||||
print "(+$entry->{'thumbs_up'}/-$entry->{'thumbs_down'}) $entry->{'definition'}\n";
|
print "(+$entry->{'thumbs_up'}/-$entry->{'thumbs_down'}) $entry->{'definition'}\n";
|
||||||
print "$entry->{'example'}\n" if $entry->{'example'};
|
print "«$entry->{'example'}»\n" if $entry->{'example'};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $show_all or defined $match) {
|
if (defined $show_all or defined $match) {
|
||||||
@ -110,7 +120,8 @@ if (defined $show_all or defined $match) {
|
|||||||
for my $each (@entries) {
|
for my $each (@entries) {
|
||||||
$n++;
|
$n++;
|
||||||
if (defined $match) {
|
if (defined $match) {
|
||||||
my $def = $each->{'definition'} . "\n" . $each->{'example'};
|
my $def = $each->{'definition'} . "\n";
|
||||||
|
$def .= "«$each->{'example'}»" if $each->{'example'};
|
||||||
next if $def !~ m/$match/im;
|
next if $def !~ m/$match/im;
|
||||||
}
|
}
|
||||||
show_definition($each, $n);
|
show_definition($each, $n);
|
||||||
|
@ -6,11 +6,8 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use WWW::Wikipedia;
|
use WWW::Wikipedia;
|
||||||
use Text::Autoformat;
|
use HTML::Parse;
|
||||||
use Getopt::Std;
|
use HTML::FormatText;
|
||||||
|
|
||||||
my %options;
|
|
||||||
getopts( 'l:', \%options );
|
|
||||||
|
|
||||||
my $term = join(' ', @ARGV);
|
my $term = join(' ', @ARGV);
|
||||||
|
|
||||||
@ -19,47 +16,27 @@ if(not $term) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# upper-case first letter and lowercase remainder of each word
|
my $wiki = WWW::Wikipedia->new(language => 'en');
|
||||||
# $term =~ s/(.)(\w*)(\s?)/\u$1\l$2$3/g;
|
|
||||||
|
|
||||||
my $wiki = WWW::Wikipedia->new( language => $options{ l } || 'en' );
|
|
||||||
my $entry = $wiki->search($term);
|
my $entry = $wiki->search($term);
|
||||||
|
|
||||||
if ($entry) {
|
if ($entry) {
|
||||||
my $text = $entry->text();
|
my $text = $entry->text();
|
||||||
|
|
||||||
if ($text) {
|
if ($text) {
|
||||||
$text =~ s/[\n\r]/ /msg;
|
$text =~ s/{{.*?}}//msg;
|
||||||
$text =~ s/\[otheruses.*?\]//gsi;
|
$text =~ s/\[\[//g;
|
||||||
$text =~ s/\[fixbunching.*?\]//gsi;
|
$text =~ s/\]\]//g;
|
||||||
$text =~ s/\[wiktionary.*?\]//gsi;
|
$text =~ s/<ref>.*?<\/ref>//g;
|
||||||
$text =~ s/\[TOC.*?\]//gsi;
|
$text =~ s/__[A-Z]+__//g;
|
||||||
$text =~ s/\[.*?sidebar\]//gsi;
|
$text =~ s/\s+\(\)//msg;
|
||||||
$text =~ s/\[pp.*?\]//gsi;
|
$text = HTML::FormatText->new->format(parse_html($text));
|
||||||
$text =~ s/'''//gs;
|
|
||||||
|
|
||||||
1 while $text =~ s/{{[^{}]*}}//gs;
|
|
||||||
1 while $text =~ s/\[quote[^\]]*\]//gsi;
|
|
||||||
1 while $text =~ s/\[\[Image:[^\[\]]*\]\]//gsi;
|
|
||||||
1 while $text =~ s/\[\[(File:)?([^\[\]]*)\]\]//gsi;
|
|
||||||
|
|
||||||
$text =~ s/\[\[.*?\|(.*?)\]\]/$1/gs;
|
|
||||||
$text =~ s/\[\[(.*?)\]\]/$1/gs;
|
|
||||||
$text =~ s/<!--.*?--\s?>//gs;
|
|
||||||
$text =~ s/\s+/ /gs;
|
|
||||||
$text =~ s/^\s+//;
|
|
||||||
$text =~ s/\<.*?\>.*?\<\/.*?\>//gs;
|
|
||||||
$text =~ s/\<.*?\/\>//gs;
|
|
||||||
|
|
||||||
$text =~ s/–/-/;
|
|
||||||
|
|
||||||
print $text;
|
print $text;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
print "Specific entry not found, see also: ";
|
print "Specific entry not found, see also: ";
|
||||||
my $semi = "";
|
my $semi = "";
|
||||||
foreach ( $entry->related() ) { print "$_$semi"; $semi = "; "; }
|
foreach ($entry->related()) { print "$semi$_"; $semi = "; "; }
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
print qq("$term" not found in Wikipedia\n)
|
||||||
}
|
}
|
||||||
else { print qq("$term" not found in wikipedia\n) }
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user