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

On-Join (bah!) stuff with infobot



A lot of people that go on #infobot ask how to to on-join stuff, for who
knows what reason.  Here I'll just explain a simple way to do it and
give a small example.  Of course, always make a backup of the original
file you're editing, no matter what you're changing.  The only thing you
really need to modify is src/Irc.pl (although you may want to make a
new.pl in conjunction with Irc.pl [just to be used as a subroutine] and
you may want to add some stuff in files/infobot.config.)  Using things
with the infobot.config is also very simple.  Let's say you add this
line in your infobot.config:
meterchan     #channel
Now, in any of the .pl files in your src/ dir, you can always refer to
that channel as $param{meterchan} since you won't always know what is in
that arguement.  The same goes for anything, just $param{whatever}.  Now
for onjoin's, you find THE FIRST
&status(">>> $nick ($user\@$host) has joined $chan");
Under this is where you can place everything.  Now as an examples, let's
say we want the infobot to nickometer everyone that joins the specified
chan, which we specified in files/infobot.config ($param{meterchan} if
you forgot already.)  Also you wouldn't want the bot to do this to
itself, because it will unless you tell it not to.  So under that line
(&status(blablabla)) here is how I added it:
###############
if ($param{meterchan}) { # to see if meterchan even exists, otherwise it
won't use this
unless ($nick eq $ident) { # $nick is the nick of the person that
joined, $ident is the bot's nick
$nomchan = $param{meterchan}; # using $param{meterchan} gets tiring.
if ($chan eq $nomchan) { # make sure it's the right chan to check
######## Here is the nickometer stuff, of course this is where you would
put the 'core' in #####
my $term = $nick; $term =~ s/\?+\s*//; my $percentage =
&nickometer($term); if ($percentage =~
/NaN/) {  $percentage = "off the scale"; } else { $percentage =
sprintf("%0.4f", $percentage); $percentage =~ s/\.?0+$//; $percentage .=
'%'; }
######## And finally it ends.... ########
&msg($nomch, "the 'lame nick-o-meter' reading for $term is
$percentage");  # messages the chan
#the nickometer stuff
return 'NOREPLY'; } } } # better end the stuff

That's about it, EXCEPT you have to add that two lines down where you
see the
} else { &status(blablabla);
So you could just make a subroutine in a src/.pl file and call that
subroutine from src/Irc.pl...that's all...that is all, please return to
your IRC clients.

-Sam (CommPort5)