summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
abaf18c)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1047
c11ca15a-4712-0410-83d8-
924469b57eb5
#v1: blootbot -- blootbot -- written Wed Oct 30 03:12:44 2002
#debian-bots
#v1: blootbot -- blootbot -- written Wed Oct 30 03:12:44 2002
#debian-bots
- +allowTelling
- +autojoin
- +babelfish
factoidDeleteDelay 7
ircTextCounters heh hah :) ? hi lol
+joinfloodCheck
factoidDeleteDelay 7
ircTextCounters heh hah :) ? hi lol
+joinfloodCheck
newsDefaultExpire 7
+newsKeepRead
+newsNotifyAll
newsDefaultExpire 7
+newsKeepRead
+newsNotifyAll
rootWarnMode aggressive
#botpark
+autojoin
_default
rootWarnMode aggressive
#botpark
+autojoin
_default
+ +allowTelling
+ +babelfish
+allowConv
+allowDNS
+BZFlag
+allowConv
+allowDNS
+BZFlag
+quote
randomFactoidInterval 60
randomQuoteInterval 60
+quote
randomFactoidInterval 60
randomQuoteInterval 60
+search
+seen
seenFlushInterval 60
+search
+seen
seenFlushInterval 60
# [str] anything which requires LWP + http proxy.
###set httpProxy http://HOSTNAME:PORT/
# [str] anything which requires LWP + http proxy.
###set httpProxy http://HOSTNAME:PORT/
-# [0/1] babelfish translator. jdf++.
-set babelfish true
-
# [0/1] offer free factoid cookies
set cookie true
# [0/1] offer free factoid cookies
set cookie true
set useStrict 1
# debugging...
set useStrict 1
# debugging...
###set dumpvarsAtExit 1
# log to specific file or global log file.
###set dumpvarsLogFile dumpvars.log
###set dumpvarsAtExit 1
# log to specific file or global log file.
###set dumpvarsLogFile dumpvars.log
# use strict;
use vars qw($who $msgType $conn $chan $message $ident $talkchannel
# use strict;
use vars qw($who $msgType $conn $chan $message $ident $talkchannel
- $bot_version $babel_lang_regex $bot_data_dir);
+ $bot_version $bot_data_dir);
use vars qw(@vernick @vernicktodo);
use vars qw(%channels %cache %mask %userstats %myModules %cmdstats
%hooks_extra %lang %ver);
# FIX THE FOLLOWING:
use vars qw($total $x $type $i $good);
use vars qw(@vernick @vernicktodo);
use vars qw(%channels %cache %mask %userstats %myModules %cmdstats
%hooks_extra %lang %ver);
# FIX THE FOLLOWING:
use vars qw($total $x $type $i $good);
-$babel_lang_regex = "de|ge|gr|el|sp|es|en|fr|it|ja|jp|ko|kr|nl|po|pt|ru|zh|zt";
$w3search_regex = "google";
### COMMAND HOOK IMPLEMENTATION.
$w3search_regex = "google";
### COMMAND HOOK IMPLEMENTATION.
&addCmdHook("extra", 'page', ('CODEREF' => 'pager::page',
'Identifier' => 'pager', 'Cmdstats' => 'pager',
'Forker' => 1, 'Help' => 'page') );
&addCmdHook("extra", 'page', ('CODEREF' => 'pager::page',
'Identifier' => 'pager', 'Cmdstats' => 'pager',
'Forker' => 1, 'Help' => 'page') );
+&addCmdHook("extra", '?:babel(?:fish)?|x|xlate|translate', ('CODEREF' => 'babelfish::babelfish',
+ 'Identifier' => 'babelfish', 'Cmdstats' => 'babelfish',
+ 'Forker' => 1, 'Help' => 'babelfish') );
###
### END OF ADDING HOOKS.
###
###
### END OF ADDING HOOKS.
###
- # babelfish bot: Jonathan Feinberg++
- if ($message =~ m{
- ^\s*
- (?:babel(?:fish)?|x|xlate|translate)
- \s+
- ($babel_lang_regex)\w* # from language?
- \s+
- ($babel_lang_regex)\w* # to language?
- \s*
- (.+) # The phrase to be translated
- }xoi) {
- return unless (&hasParam("babelfish"));
-
- &Forker("babelfish", sub { &babelfish::babelfish(lc $1, lc $2, $3); } );
-
- $cmdstats{'BabelFish'}++;
- return;
- }
-
my $debiancmd = 'conflicts?|depends?|desc|file|(?:d)?info|provides?';
$debiancmd .= '|recommends?|suggests?|maint|maintainer';
my $debiancmd = 'conflicts?|depends?|desc|file|(?:d)?info|provides?';
$debiancmd .= '|recommends?|suggests?|maint|maintainer';
/^learn / and last; # teach. damn morons.
/^tell (\S+) about / and last; # tell.
/\=\~/ and last; # substituition.
/^learn / and last; # teach. damn morons.
/^tell (\S+) about / and last; # tell.
/\=\~/ and last; # substituition.
- /^\S+ to \S+ \S+/ and last; # babelfish.
/^\=/ and last; # botnick = heh is.
/wants you to know/ and last;
/^\=/ and last; # botnick = heh is.
/wants you to know/ and last;
# NOTE: Ripped from ActivePerl "asp sample" example.
#
# NOTE: Ripped from ActivePerl "asp sample" example.
#
# dump variables.
if ($message =~ /^dumpvars$/i) {
return unless (&hasFlag("o"));
# dump variables.
if ($message =~ /^dumpvars$/i) {
return unless (&hasFlag("o"));
- return unless (&IsParam("dumpvars"));
+ return unless (&IsParam("DumpVars"));
&status("Dumping all variables...");
&dumpallvars();
&status("Dumping all variables...");
&dumpallvars();
$lang_regex = join '|', keys %lang_code;
}
$lang_regex = join '|', keys %lang_code;
}
return '' if $no_babelfish;
my ($from, $to, $phrase) = @_;
&main::DEBUG("babelfish($from, $to, $phrase)");
return '' if $no_babelfish;
my ($from, $to, $phrase) = @_;
&main::DEBUG("babelfish($from, $to, $phrase)");
my $translated;
if ($res->is_success) {
my $translated;
if ($res->is_success) {
- my $html = $res->content;
- # This method subject to change with the whims of Altavista's design
- # staff.
- ($translated) = $html;
+ my $html = $res->content;
+ # This method subject to change with the whims of Altavista's design
+ # staff.
+ ($translated) = $html;
- $translated =~ s/<[^>]*>//sg;
- $translated =~ s/ / /sg;
- $translated =~ s/\s+/ /sg;
- #&main::DEBUG("$translated\n===remove <attributes>\n");
+ $translated =~ s/<[^>]*>//sg;
+ $translated =~ s/ / /sg;
+ $translated =~ s/\s+/ /sg;
+ #&main::DEBUG("$translated\n===remove <attributes>\n");
- $translated =~ s/\s*Translate again.*//i;
- &main::DEBUG("$translated\n===remove after 'Translate again'\n");
+ $translated =~ s/\s*Translate again.*//i;
+ &main::DEBUG("$translated\n===remove after 'Translate again'\n");
- $translated =~ s/[^:]*?:\s*(Help\s*)?//s;
- &main::DEBUG("len=" . length($translated) . " $translated\n===remove to first ':', optional Help\n");
+ $translated =~ s/[^:]*?:\s*(Help\s*)?//s;
+ &main::DEBUG("len=" . length($translated) . " $translated\n===remove to first ':', optional Help\n");
- $translated =~ s/\n/ /g;
- # FIXME: should we do unicode->iso (no. use utf8!)
+ $translated =~ s/\n/ /g;
+ # FIXME: should we do unicode->iso (no. use utf8!)
- $translated = ":("; # failure
+ $translated = ":("; # failure
}
$translated = "babelfish.pl: result too long, probably an error" if (length($translated) > 700);
}
$translated = "babelfish.pl: result too long, probably an error" if (length($translated) > 700);
- &main::pSReply($translated);
+ return $translated
+}
+
+sub babelfish {
+ my ($message) = @_;
+ my $babel_lang_regex = "de|ge|gr|el|sp|es|en|fr|it|ja|jp|ko|kr|nl|po|pt|ru|zh|zt";
+ if ($message =~ m{
+ ($babel_lang_regex)\w* # from language?
+ \s+
+ ($babel_lang_regex)\w* # to language?
+ \s*
+ (.+) # The phrase to be translated
+ }xoi) {
+ &::performStrictReply(&babelfishParam(lc $1, lc $2, lc $3));
+ }
+ return;
}
if (0) {
if (-t STDIN) {
}
if (0) {
if (-t STDIN) {
- #my $result = babelfish::babelfish('en','sp','hello world');
- #my $result = babelfish::babelfish('en','sp','The cheese is old and moldy, where is the bathroom?');
- my $result = babelfish::babelfish('en','gr','doesn\'t seem to translate things longer than 40 characters');
+ #my $result = babelfish::babelfish('en sp hello world');
+ #my $result = babelfish::babelfish('en sp The cheese is old and moldy, where is the bathroom?');
+ my $result = babelfish::babelfish('en gr doesn\'t seem to translate things longer than 40 characters');
$result =~ s/; /\n/g;
print "Babelfish says: \"$result\"\n";
}
$result =~ s/; /\n/g;
print "Babelfish says: \"$result\"\n";
}
&uptimeWriteFile() if (&IsChanConf("uptime"));
&sqlCloseDB();
&closeSHM($shm);
&uptimeWriteFile() if (&IsChanConf("uptime"));
&sqlCloseDB();
&closeSHM($shm);
- &dumpallvars() if (&IsParam("dumpvarsAtExit"));
+
+ if (&IsParam("dumpvarsAtExit")) {
+ &loadMyModule('DumpVars');
+ &dumpallvars();
+ }
&symdumpAll() if (&IsParam("symdumpAtExit"));
&closeLog();
&closeSQLDebug() if (&IsParam("SQLDebug"));
&symdumpAll() if (&IsParam("symdumpAtExit"));
&closeLog();
&closeSQLDebug() if (&IsParam("SQLDebug"));
"debian" => "Debian.pl",
"debianExtra" => "DebianExtra.pl",
"Dict" => "Dict.pl",
"debian" => "Debian.pl",
"debianExtra" => "DebianExtra.pl",
"Dict" => "Dict.pl",
- "dumpvars" => "DumpVars.pl",
+ "DumpVars" => "DumpVars.pl",
"exchange" => "Exchange.pl",
"factoids" => "Factoids.pl",
"HTTPDtype" => "HTTPDtype.pl",
"exchange" => "Exchange.pl",
"factoids" => "Factoids.pl",
"HTTPDtype" => "HTTPDtype.pl",