3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-22 18:52:40 +01:00

todo! add support for admin management - needs support for adding/removing/saving!

todo! multi-channel support pathetic (note 12/08/09, fixed multi-channel for anti-flood and for ignore)
todo! most of this crap needs to be refactored (note 11/23/09, refactored execute_module)

0.4.1 (12/08/09): improved anti-flood system to be significantly more accurate and per-channel
                  added per-nick-per-channel message history using %flood_watch
                  add per-channel support to ignore system
                  automatically remove message history for nicks that haven't spoken in one day (run once per hour)
                  do not ignore !login command
0.3.16(11/23/09): refactored module execution to execute_module() subroutine
                  added trigger to execute get_title.pl module when URL is
                  detected in regular untriggered chat
0.3.15(11/20/09): replace 'me' with '$nick' in arguments
This commit is contained in:
Pragmatic Software 2009-12-09 01:08:12 +00:00
parent 9ecc4103e7
commit 73b793295b
27 changed files with 1917 additions and 526 deletions

View File

@ -1 +1,3 @@
##c 0 0
##c 1 1 0
#pbot2 1 1 0
##philosophy 1 0 0

1080
commands

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# quick and dirty by :pragma
use strict;
use LWP::UserAgent;
my ($result, $acro, $entries, $text);
@ -46,7 +45,7 @@ $acro="";
while($text =~ m/<td width=.*?>(.*?)<\/td>/gsi)
{
$acro = "$acro$1, ";
$acro = "$acro$1; ";
}
$acro =~ s/\s+\[slang\]//gi;
@ -54,6 +53,5 @@ $acro =~ s/\s+\[joke\]//gi;
$acro =~ s/\s+/ /g;
$acro =~ s/<.*?>//g;
$acro =~ s/&nbsp;//g;
$acro =~ s/, , $//;
$acro = substr($acro, 0, 300);
$acro =~ s/; ; $//;
print "$acro\n";

34
modules/cdecl.pl Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/perl -w
# quick and dirty by :pragma
if ($#ARGV < 0) {
print "For help with cdecl, see http://linux.die.net/man/1/cdecl\n";
die;
}
my $command = join(' ', @ARGV);
$command =~ s/-[^ ]+//g;
$command =~ s/\\//g;
$command =~ s/;/\\;/g;
$command =~ s/\(/\\(/g;
$command =~ s/\)/\\)/g;
$command =~ s/\$/\\\$/g;
$command =~ s/\[/\\[/g;
$command =~ s/\]/\\]/g;
$command =~ s/\|/\\|/g;
$command =~ s/'/\\'/g;
$command =~ s/`/\\`/g;
$command =~ s/,/\\,/g;
$command =~ s/\*/\\*/g;
$command =~ s/\?/\\?/g;
#print "[$command]\n";
my $result = `/usr/bin/cdecl -c $command`;
chomp $result;
$result =~ s/\n/, /g;
print $result;

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl -w
use strict;
my $file;
my $match = 1;

2
modules/compliment Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
/home/msmud/pbot2/modules/lookupbot.pl compliment $*

View File

@ -1,8 +1,7 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# quick and dirty by :pragma
use strict;
use LWP::Simple;
my ($defint, $phrase, $text, $entry, $entries, $i);
@ -27,7 +26,7 @@ $text = get("http://dictionary.reference.com/search?q=$phrase");
$phrase =~ s/\%20/ /g;
if($text =~ m/No results found/i)
if($text =~ m/because there was not a match on/i)
{
print "No entry found for '$phrase'. ";
@ -36,7 +35,7 @@ if($text =~ m/No results found/i)
{
print "Suggestions: ";
$i = 30;
$i = 90;
while($text =~ m/<a href="\/search\?r=2&amp;q=.*?>(.*?)<\/a>/g && $i > 0)
{
print "$1, ";
@ -61,7 +60,7 @@ if($text =~ m/No results found/i)
exit 0;
}
if($text =~ m/<h1>(.*?) results for:/g)
if($text =~ m/- (.*?) dictionary result/g)
{
$entries = $1;
}
@ -70,40 +69,50 @@ $entries = 1 if(not defined $entries);
if($entry > $entries)
{
print "But there are only $entries entries for $phrase.\n";
print "No entry found for $phrase.\n";
exit 0;
}
print "$phrase ($entry of $entries entries): ";
print "$phrase: ";
$i = 1;
$i = $entry;
while($i <= $entry)
{
if($text =~ m/<td valign="top">(.*?)<\/td>/gs)
{
$defint = $1;
}
$i++;
}
# and now for some fugly beautifying regexps...
$defint = "";
my $quote = chr(226) . chr(128) . chr(156);
my $quote2 = chr(226) . chr(128) . chr(157);
my $dash = chr(226) . chr(128) . chr(147);
$defint =~ s/$quote/"/g;
$defint =~ s/$quote2/"/g;
$defint =~ s/$dash/-/g;
$defint =~ s/<b>Pronun.*?<BR>//gsi;
$defint =~ s/<.*?>//gsi;
$defint =~ s/\&nbsp\;/ /gi;
$defint =~ s/\&.*?\;//g;
$defint =~ s/\r\n//gs;
$defint =~ s/\( P \)//gs;
$defint =~ s/\s+/ /gs;
while($i <= $entries)
{
if($text =~ m/<td>(.*?)<\/td>/gs)
{
$defint = $1;
}
$defint = substr($defint, 0, 300);
# and now for some fugly beautifying regexps...
print "$defint\n";
$defint =~ s/$quote/"/g;
$defint =~ s/$quote2/"/g;
$defint =~ s/$dash/-/g;
$defint =~ s/<b>Pronun.*?<BR>//gsi;
$defint =~ s/<.*?>//gsi;
$defint =~ s/\&nbsp\;/ /gi;
$defint =~ s/\&.*?\;//g;
$defint =~ s/\r\n//gs;
$defint =~ s/\( P \)//gs;
$defint =~ s/\s+/ /gs;
if($defint =~ /interfaceflash/) {
$i++;
next;
}
$i++ and next if $defint eq " ";
print "$i) $defint ";
$i++;
}
print "\n";

5
modules/excuse.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
host=bofh.jeffballard.us
port=666
grep excuse < /dev/tcp/$host/$port | sed 's/Your excuse is: //'

45
modules/funnyish_quote.pl Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# Quick and dirty by :pragma
use LWP::UserAgent;
my ($text, $t);
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0");
my %post = ( 'number' => '4', 'collection[]' => '20thcent' );
my $response = $ua->post("http://www.quotationspage.com/random.php3", \%post);
if (not $response->is_success)
{
print "Couldn't get quote information.\n";
die;
}
$text = $response->content;
$text =~ m/<dt class="quote"><a.*?>(.*?)<\/a>.*?<dd class="author"><div.*?><a.*?>.*?<b>(.*?)<\/b>/g;
$t = "\"$1\" -- $2.";
my $quote = chr(226) . chr(128) . chr(156);
my $quote2 = chr(226) . chr(128) . chr(157);
my $dash = chr(226) . chr(128) . chr(147);
$t =~ s/<[^>]+>//g;
$t =~ s/<\/[^>]+>//g;
$t =~ s/$quote/"/g;
$t =~ s/$quote2/"/g;
$t =~ s/$dash/-/g;
$t =~ s/&quot;/"/g;
$t =~ s/&amp;/&/g;
$t =~ s/&nsb;/ /g;
$t =~ s/&#39;/'/g;
$t =~ s/&lt;/</g;
$t =~ s/&gt;/>/g;
$t =~ s/<em>//g;
$t =~ s/<\/em>//g;
print "$t Discuss!\n";

85
modules/gdefine.pl Executable file
View File

@ -0,0 +1,85 @@
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# quick and dirty by :pragma
use strict;
use LWP::UserAgent;
my ($defint, $phrase, $text, $entry, $entries, $i);
my @defs;
if ($#ARGV < 0)
{
print "What phrase would you like to define?\n";
die;
}
$phrase = join("+", @ARGV);
$entry = 1;
if($phrase =~ m/([0-9]+)\+(.*)/)
{
$entry = $1;
$phrase = $2;
}
my $ua = LWP::UserAgent->new;
$ua->agent("howdy");
my $response = $ua->get("http://www.google.com/search?q=define:$phrase");
$phrase =~ s/\+/ /g;
if (not $response->is_success) {
exit(1);
}
$text = $response->content;
if($text =~ m/No definitions were found/i)
{
print "No entry found for '$phrase'. ";
print "\n";
exit 1;
}
print "$phrase: ";
$i = $entry;
while($i <= $entry + 5)
{
if($text =~ m/<li>(.*?)<br>/gs)
{
push @defs, $1;
}
$i++;
}
my %uniq = map { $_ => 1 } @defs;
@defs = keys %uniq;
my $comma = "";
for($i = 1; $i <= $#defs + 1; $i++) {
# and now for some fugly beautifying regexps...
my $quote = chr(226) . chr(128) . chr(156);
my $quote2 = chr(226) . chr(128) . chr(157);
my $dash = chr(226) . chr(128) . chr(147);
$_ = $defs[$i-1];
s/$quote/"/g;
s/$quote2/"/g;
s/$dash/-/g;
s/<b>Pronun.*?<BR>//gsi;
s/<.*?>//gsi;
s/\&nbsp\;/ /gi;
s/\&.*?\;//g;
s/\r\n//gs;
s/\( P \)//gs;
s/\s+/ /gs;
print "$i) $_$comma";
$comma = ", ";
}

77
modules/get_title.pl Executable file
View File

@ -0,0 +1,77 @@
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# Quick and dirty by :pragma
use LWP::UserAgent;
my ($text);
if ($#ARGV <= 0)
{
print "Usage: !title nick URL\n";
die;
}
my $nick = shift(@ARGV);
$arguments = join("%20", @ARGV);
die if($arguments =~ m/imagebin/i);
die if($arguments =~ m/\/wiki\//i);
die if($arguments =~ m/wikipedia.org/i);
die if($arguments =~ m/everfall.com/i);
die if($arguments =~ m/pastie.org/i);
die if($arguments =~ m/codepad/i);
die if($arguments =~ m/paste.*\.(?:com|org|net|ca|uk)/i);
die if($arguments =~ m/pasting.*\.(?:com|org|net|ca|uk)/i);
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0");
$ua->max_size(200 * 1024);
my $response = $ua->get("$arguments");
if (not $response->is_success)
{
#print "Couldn't get link.\n";
die;
}
$text = $response->content;
if($text =~ m/<title>(.*?)<\/title>/msi)
{
$t = $1;
} else {
#print "No title for link.\n";
die;
}
my $quote = chr(226) . chr(128) . chr(156);
my $quote2 = chr(226) . chr(128) . chr(157);
my $dash = chr(226) . chr(128) . chr(147);
$t =~ s/\s+/ /g;
$t =~ s/^\s+//g;
$t =~ s/\s+$//g;
$t =~ s/<[^>]+>//g;
$t =~ s/<\/[^>]+>//g;
$t =~ s/$quote/"/g;
$t =~ s/$quote2/"/g;
$t =~ s/$dash/-/g;
$t =~ s/&quot;/"/g;
$t =~ s/&amp;/&/g;
$t =~ s/&nsb;/ /g;
$t =~ s/&#39;/'/g;
$t =~ s/&lt;/</g;
$t =~ s/&gt;/>/g;
$t =~ s/<em>//g;
$t =~ s/<\/em>//g;
if(length $t > 150) {
$t = substr($t, 0, 150);
$t = "$t [...]";
}
# $nick =~ s/^(.)(.*)/$1|$2/;
print "Title of $nick\'s link: $t\n";

View File

@ -1,8 +1,7 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# Quick and dirty by :pragma
use strict;
use LWP::UserAgent;
my ($text, $arguments, $header, $footer, $t, $matches);
@ -86,7 +85,7 @@ my $quote = chr(226) . chr(128) . chr(156);
my $quote2 = chr(226) . chr(128) . chr(157);
my $dash = chr(226) . chr(128) . chr(147);
while($text =~ m/<div class=g><h2 class=r><a href=\"(.*?)\".*?>(.*?)<\/a>/g && $i < $matches)
while($text =~ m/<li class=g><h3 class=r><a href=\"(.*?)\".*?>(.*?)<\/a>/g && $i < $matches)
{
if($i > 0)
{
@ -96,14 +95,19 @@ while($text =~ m/<div class=g><h2 class=r><a href=\"(.*?)\".*?>(.*?)<\/a>/g && $
{
$t = "$2: [$1]";
}
$t =~ s/<b>//g;
$t =~ s/<\/b>//g;
$t =~ s/<[^>]+>//g;
$t =~ s/<\/[^>]+>//g;
$t =~ s/$quote/"/g;
$t =~ s/$quote2/"/g;
$t =~ s/$dash/-/g;
$t =~ s/&quot;/"/g;
$t =~ s/&amp;/&/g;
$t =~ s/&nsb;/ /g;
$t =~ s/&#39;/'/g;
$t =~ s/&lt;/</g;
$t =~ s/&gt;/>/g;
$t =~ s/<em>//g;
$t =~ s/<\/em>//g;
print $t;
$i++;

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
use strict;
use LWP::Simple;
my $html;

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
use strict;
use LWP::Simple;
my $html;

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
use strict;
use LWP::Simple;
my $html;

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
use strict;
use XML::RSS;
use LWP::Simple;

2
modules/horoscope Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
/home/msmud/pbot2/modules/lookupbot.pl horoscope $*

13
modules/insult.pl Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
#
use strict;
use LWP::Simple;
$_ = get("http://www.randominsults.net/");
if (/<strong><i>(.*?)<\/i><\/strong>/) {
print @ARGV,': ' if @ARGV;
print $1;
}
else {
print "yo momma!";
}

View File

@ -1,8 +1,6 @@
#!/usr/bin/perl -w
#!/usr/bin/perl -w -I /home/msmud/libwww-perl-5.808/lib
# quick and dirty by :pragma
use strict;
use LWP::Simple;
my ($result, $manpage, $section, $text, $name, $includes, $prototype, $conforms, $description);
@ -12,43 +10,43 @@ if ($#ARGV < 0) {
die;
}
#$manpage = join(" ", @ARGV);
$manpage = join("+", @ARGV);
$section = 8;
my $loop = 1;
$section = "3";
#if($manpage =~ m/([0-9]+)\s+(.*)/) {
if($manpage =~ m/([0-9]+)\+(.*)/) {
# $section = "$1 ";
$section = $1;
$manpage = $2;
$loop = 0;
}
if(!($section == 2 || $section == 3))
{
print "I'm only interested in displaying information from section 2 or 3.\n";
exit 0;
}
$manpage =~ s/\+.*$//;
#my $page = `man $section$manpage -w 2>&1`;
#if($page =~ m/No.*?entry\sfor(.*)/i) {
# print "No entry for$1\n";
# exit 0;
#}
my $get_text;
do {
# $text = get("http://www.freebsd.org/cgi/man.cgi?query=$manpage&sektion=$section&apropos=0&manpath=FreeBSD+6.2-RELEASE&format=ascii");
$get_text = get("http://www.freebsd.org/cgi/man.cgi?query=$manpage&sektion=$section&apropos=0&manpath=SuSE+Linux%2Fi386+8.2&format=ascii");
#$text = `groff -t -e -mandoc -Tascii $page`;
#$text =~ s/\e.*?m//g;
#$text = get("http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=$manpage&cgi_section=$section&cgi_keyword=m");
$text = substr($get_text, 0, 5000);
# print '['.length($text).']'."\n";
if($text =~ m/Sorry, no data found/)
{
$section--;
$text =
get("http://www.freebsd.org/cgi/man.cgi?query=$manpage&sektion=$section&apropos=0&manpath=FreeBSD+6.2-RELEASE&format=ascii");
if($text =~ m/Sorry, no data found/)
{
print "No information found for $manpage in section $section.\n";
exit 0;
}
if($section == 0 || $loop == 0) {
$section++;
if($section == 1 && $loop == 1) {
print "No information found for $manpage in any of the sections.\n";
} else {
print "No information found for $manpage in section $section.\n";
}
exit 0;
}
} else { $loop = 0; }
} while($loop);
$text =~ m/^\s+NAME/gsm;
if($text =~ m/(.*?)SYNOPSIS/gsi) {
@ -57,25 +55,37 @@ if($text =~ m/(.*?)SYNOPSIS/gsi) {
my $i = 0;
while ($text =~ m/#include <(.*?)>/gsi) {
$includes .= ", " if($i > 0);
$includes .= "$1";
$i++;
if(not $includes =~ /$1/) {
$includes .= ", " if($i > 0);
$includes .= "$1";
$i++;
}
}
$prototype = "$1 $2$manpage($3);"
if($text =~ m/SYNOPSIS.*^\s+(.*?)\s+(\*?)$manpage\s*\((.*?)\)\;?\n.*DESC/ms);
if($text =~ m/DESCRIPTION.*?$manpage(.*?)\./si) {
$description = "$manpage $1";
if($text =~ m/DESCRIPTION(.*?)$manpage(.*?)\./si) {
my $foo = $1;
my $bar = $2;
$foo =~ s/\r//g;
$foo =~ s/\n//g;
$foo =~ s/\s+/ /g;
$foo =~ s/^\s+//;
if($foo =~ /^NOTE/) {
$description = "$foo$manpage $bar";
} else {
$description = "$manpage $bar";
}
$description =~ s/\-\s+//g;
}
if ($text =~ m/^CONFORMING TO.*?^\s+The\s$manpage\s.*conforms to\s(.*?)$/ms) {
if ($get_text =~ m/^CONFORMING TO.*?^\s+The\s$manpage\s.*conforms to\s(.*?)$/ms) {
$conforms = $1;
} elsif ($text =~ m/^CONFORMING TO.*?^\s+The\s+$manpage\s+.*?is\s+compatible\s+with\s+(.*?)$/ms) {
} elsif ($get_text =~ m/^CONFORMING TO.*?^\s+The\s+$manpage\s+.*?is\s+compatible\s+with\s+(.*?)$/ms) {
$conforms = "$1 ...";
} elsif ($text =~ m/^CONFORMING TO.*?^\s+(.*?)\.\s/ms or
$text =~ m/^CONFORMING TO.*?^\s+(.*?)$/ms) {
} elsif ($get_text =~ m/^CONFORMING TO.*?^\s+(.*?)\.\s/ms or
$get_text =~ m/^CONFORMING TO.*?^\s+(.*?)$/ms) {
$conforms = $1;
}
@ -83,16 +93,27 @@ $result = "";
$result .= "$name - " if (not defined $includes);
$result .= "Includes: $includes - " if (defined $includes);
$result .= "$prototype - " if (defined $prototype);
$result .= "$conforms - " if (defined $conforms);
$result .= $description;
if($section == 3) {
$result .= " - http://www.iso-9899.info/man?$manpage";
} else {
$result .= " - http://www.freebsd.org/cgi/man.cgi?sektion=$section&query=$manpage";
}
$result .= " - $conforms" if (defined $conforms);
$result =~ s/^\s+//g;
$result =~ s/\s+/ /g;
$result =~ s/ANSI - C/ANSI C/g;
$result =~ s/\(these.*?appeared in .*?\)//g;
$result =~ s/(\w)- /$1/g;
$result =~ s/\n//g;
$result =~ s/\r//g;
$result =~ s/\<A HREF.*?>//g;
$result =~ s/\<\/A>//g;
$result =~ s/&quot;//g;
print "$result - http://www.iso-9899.info/man?$manpage";
print "$result\n";

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl
use strict;
use LWP::Simple;
my ($text, $buffer, $location);

View File

@ -2,7 +2,6 @@
# Quick and dirty by :pragma
use strict;
my ($arguments, $response);

124
modules/random_quote.pl Executable file
View File

@ -0,0 +1,124 @@
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0 -I /home/msmud/lib/perl5/
# Quick and dirty by :pragma
use LWP::UserAgent::WithCache;
my ($text, $t);
my %cache_opt = (
'namespace' => 'lwp-cache',
'cache_root' => File::Spec->catfile(File::HomeDir->my_home, '.lwpcache'),
'default_expires_in' => 600 * 6 * 24 );
my $ua = LWP::UserAgent::WithCache->new(\%cache_opt);
$ua->agent("Mozilla/5.0");
my $response;
my $page = 1;
my $pages = undef;
my @quotes;
#print "$#ARGV\n";
#print "$#quotes\n";
while(1) {
if($#ARGV < 0) {
my %post = ( 'number' => '4', 'collection[]' => 'mgm', 'collection[]' => 'motivate' );
$response = $ua->post("http://www.quotationspage.com/random.php3", \%post);
} else {
my $arguments = join('+', @ARGV);
my $author = "";
$arguments =~ s/\$nick/me/gi;
$arguments =~ s/\s/+/g;
if($arguments =~ m/\-\-author[\s\+]+(.*)/i) {
$author = $1;
$arguments =~ s/\-\-author[\s\+]+(.*)//i;
}
# print "search: [$arguments]; author: [$author]\n";
if((length $arguments < 4) && ($author eq "")) {
print "Quote search parameter too small.\n";
die;
}
if((length $author > 0) && (length $author < 3)) {
print "Quote author parameter too small.\n";
die;
}
$arguments =~ s/\++$//;
$author =~ s/\++$//;
# print "http://www.quotationspage.com/search.php3?Search=$arguments&startsearch=Search&Author=$author&C=mgm&C=motivate&C=classic&C=coles&C=poorc&C=lindsly&C=net&C=devils&C=contrib&page=$page\n";
$response = $ua->get("http://www.quotationspage.com/search.php3?Search=$arguments&startsearch=Search&Author=$author&C=mgm&C=motivate&C=classic&C=coles&C=poorc&C=lindsly&C=net&C=devils&C=contrib&page=$page");
}
if (not $response->is_success)
{
print "Couldn't get quote information.\n";
die;
}
$text = $response->content;
while($text =~ m/<dt class="quote"><a.*?>(.*?)<\/a>.*?<dd class="author"><div.*?><a.*?>.*?<b>(.*?)<\/b>/g) {
$t = "\"$1\" -- $2.";
push @quotes, $t;
#print "Added '$t'\n";
#print "$#quotes\n";
last if($#ARGV < 0);
}
if($text =~ m/Page \d+ of (\d+)/) {
$pages = $1;
$page++;
last if $page > $pages;
# print "Pages: $pages; fetching page $page\n";
} else {
last;
}
if($#quotes < 0) {
print "No results found.\n";
die;
}
last if($#ARGV < 0);
}
# print "Total quotes: ", $#quotes + 1, "\n";
if($#quotes < 0) {
print "No results found.\n";
die;
}
$t = $quotes[int rand($#quotes + 1)];
if($#ARGV > -1) {
$t = "" . ($#quotes + 1) . " matching quote" . (($#quotes + 1) != 1 ? "s" : "") . " found. $t";
}
my $quote = chr(226) . chr(128) . chr(156);
my $quote2 = chr(226) . chr(128) . chr(157);
my $dash = chr(226) . chr(128) . chr(147);
$t =~ s/<[^>]+>//g;
$t =~ s/<\/[^>]+>//g;
$t =~ s/$quote/"/g;
$t =~ s/$quote2/"/g;
$t =~ s/$dash/-/g;
$t =~ s/&quot;/"/g;
$t =~ s/&amp;/&/g;
$t =~ s/&nsb;/ /g;
$t =~ s/&#39;/'/g;
$t =~ s/&lt;/</g;
$t =~ s/&gt;/>/g;
$t =~ s/<em>//g;
$t =~ s/<\/em>//g;
print "$t Discuss!\n";

2
modules/urban Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
/home/msmud/pbot2/modules/lookupbot.pl urban $*

View File

@ -1,6 +1,5 @@
#!/usr/bin/perl
#!/usr/bin/perl -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
use strict;
use LWP::Simple;
my ($text, $weather, $location, $date, $i, $day, @days);

61
modules/wikipedia.pl Executable file
View File

@ -0,0 +1,61 @@
#!/usr/bin/perl -I /home/msmud/lib/perl5
use strict;
use WWW::Wikipedia;
use Text::Autoformat;
use Getopt::Std;
my %options;
getopts( 'l:', \%options );
my $term = join(' ', @ARGV);
if(not $term) {
print "Usage: !wikipedia <term>\n";
exit;
}
# upper-case first letter and lowercase remainder of each word
# $term =~ s/(.)(\w*)(\s?)/\u$1\l$2$3/g;
my $wiki = WWW::Wikipedia->new( language => $options{ l } || 'en' );
my $entry = $wiki->search( $term );
if ( $entry ) {
my $text = $entry->text();
if ( $text ) {
$text =~ s/[\n\r]/ /msg;
$text =~ s/\[otheruses.*?\]//gsi;
$text =~ s/\[fixbunching.*?\]//gsi;
$text =~ s/\[wiktionary.*?\]//gsi;
$text =~ s/\[TOC.*?\]//gsi;
$text =~ s/\[.*?sidebar\]//gsi;
$text =~ s/\[pp.*?\]//gsi;
$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/&ndash;/-/;
print $text;
}
else {
print "Specific entry not found, see also: ";
my $semi = "";
foreach ( $entry->related() ) { print "$_$semi"; $semi = "; "; }
}
}
else { print qq("$term" not found in wikipedia\n) }

2
pb
View File

@ -1 +1 @@
nohup perl -I /home/msmud/Net-IRC-0.75 pbot2.pl >> log 2>&1
nohup perl -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/i686-linux/ -I /home/msmud/libwww-perl-5.808/lib/LWP -I /home/msmud/Net-IRC-0.75 pbot2.pl >> log 2>&1

697
pbot2.pl

File diff suppressed because it is too large Load Diff