[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rev it up



Hello there, here are just some code snippits to add to your infobot's
source programs.  Nothing too big but just add a little features that
can help you and some people like.  Make sure to make backups of all the
source programs you change before changing them if for some reason they
don't work right.
First off, cycling the log file to the day it was made instead of one
huge log file.  This code will make new logs daily by date looking
something like: 16Jan2000-infobot.log
You just add this code but change the directory from
/usr/infobot/logs/$date to /wherever/you/store/logs/$date
You will need to change this in src/Misc.pl so here it is:

(line 5 after use Socket;): use POSIX qw(strftime);
Remove lines 124-146 ( sub log_line --- }) and put this in instead:
############
sub log_line {
my($line) = @_;
my($logwrite) = 0;
my $s = time();
if ($param{'logfile'} ne '') {
$line =~ s/\n*$/\n/;
open(TRACK, ">>$param{logfile}");
$loglines++;
$total_loglines++;
print TRACK "$s $line";
close(TRACK);           #  if (TRACK);
}
}
################
Next is to get your infobot connecting to random servers instead of just
one.  This is good if a server dies while you're not around so your bot
would automaticly connect to a different server instead of the same one,
although it will only connect if you have more than one server specified
in your files/infobot.config which you shouldn't have by default.  Once
you add this code in your files/infobot.config just seperate the servers
with commas (and a space after each one) like so:
servers   irc.infobot.org, irc.cs.cmu.edu
You will need to change src/Irc.pl so here it is:

Remove lines 344-352 (while ($connected) { ---  rawout("USER, blah, blah
,blah) and put this in instead:
####################
while ($connected) {
@serv = split(/, /,$param{server});
$servr = "$serv[int(rand(@serv))]";
srvConnect($servr, $param{port});
if ($param{server_pass}) { # ksiero++
rawout("PASS $param{server_pass}");
}
rawout("NICK $param{wantNick}");
rawout("USER $param{ircuser} $param{ident} $servr :$param{realname}");
####################
Next off, random quit messages (only for you people who's infobots like
to quit a lot for some reason), this will just quit with a different
quit message (of course you specify them) every time unless you just
want one, you leave your configuration alone just like the random
servers but if you want random quits just add commas (and a space after
each one) again like so:
quitMsg    Infobot - Smarter than the average Eggdrop, I was told to die

So open up your src/IrcExtras.pl and change like so:

Remove lines 32-37 (sub killed { --- }) and put this in:
#####################
sub killed {
@qt = split(/, /,$param{'quitMsg'});
$quit = "$qt[int(rand(@qt))]";
&quit($quit);
&closeDBM("is", "are");
exit(1);
}
######################

That is all for now.  Please return to your IRC client.
-Sam (CommPort5)