Nef, you did find the corrent part, it is used to validate commands etc. I once edited bitchbot for my own, but I am past that. If you want something made specifically for you, you should learn a little Perl. Look up the Net::IRC module, it's old, but event driven. For example:
use Net::IRC;
use strict;
my @nicknames = ('bot','bot2','bot3','bot4','bot5','bo','b');
my @channels = ('#temp:');
my $defaultquitmsg = 'exiting';
my $irc = new Net::IRC;
my $conn = $irc->newconn(
Server => 'irc.planetgloom.com',
Port => '6667',
Nick => $nicknames[0],
Ircname => 'somebot',
Username => 'bot'
);
my $nickstaken = 0;
sub on_init() {
my ($self, $event) = @_;
my (@args) = ($event->args);
shift(@args);
printf("*** @args\n");
}
sub on_connect() {
my $conn = shift;
foreach my $value (@channels) {
my @raw = split(/[':']/,$value);
$conn->join($raw[0],$raw[1]) or printf("Couldn't join $raw[0]\n");
}
}
sub on_nick_taken() {
my ($self) = @_;
if ($nickstaken < scalar(@nicknames)) {
$nickstaken++;
my $newnick = $nicknames[$nickstaken];
if ($self->nick($newnick)) {
$conn->Nick = $newnick;
}
else {
printf("Couldn't change nickname to $newnick\n");
}
}
}
sub on_names () {
my ($conn,$event) = @_;
my @raw = $event->args;
my ($chan,@nicks);
@nicks = splice(@raw,2);
$chan = splice(@nicks,0,1);
printf("Nicks on $chan: @nicks\n");
}
sub on_join() {
my ($conn, $event) = @_;
my $nick = $event->{nick};
my $chan = $event->{channel};
if ($nick eq $conn->{Nick}) {
printf(" * joined $chan");
}
else {
printf(" * $nick joined $chan\n");
}
}
sub on_part() {
my ($conn, $event) = @_;
my $nick = $event->{nick};
my $chan = $event->{channel};
if ($nick eq $conn->{Nick}) {
printf(" * left ".$chan);
}
else {
printf(" * $nick left $chan\n");
}
}
sub on_chanmsg() {
my ($conn,$event) = @_;
my $nick = $event->{nick};
my $chan = $event->{channel};
my $user = $event->{user};
my $host = $event->{host};
my $fullhost = "$nick!$user\@$host";
my $text = $event->{args}[0];
my $mynick = $conn->{Nick};
my @param = split(m/["\ "]/,$text);
printf("$fullhost>$chan : $text\n");
if ($param[0] eq '!slap') {
$conn->privmsg($chan,"i slap ya!");
}
}
sub on_quit() {
my ($conn,$event) = @_;
my $nick = $event->{nick};
my $chan = $event->{channel};
my $user = $event->{user};
my $host = $event->{host};
my $fullhost = "$nick!$user\@$host";
my $text = $event->{args}[0];
printf(" * $nick has quit IRC ($text)\n");
}
sub on_privmsg() {
my ($conn,$event) = @_;
my $nick = $event->{nick};
my $user = $event->{user};
my $host = $event->{host};
my $fullhost = "$nick!$user\@$host";
my $text = $event->{args}[0];
my @param = split(m/["\ "]/,$text);
printf("pm $fullhost: $text\n");
if ($param[0] eq '.quit') {
$conn->quit($defaultquitmsg);
}
}
sub exitprog() {
my $type = $_[0];
printf("Exited! (type $type)\n");
sleep 3;
exit();
}
sub on_disconnect() {
my ($conn) = @_;
printf("Connection Lost! Exiting IRC!\n");
&exitprog('forced');
}
sub on_leaving() {
my ($conn) = @_;
printf("Leaving IRC.\n");
&exitprog('willfull');
}
sub on_kill() {
my ($conn) = @_;
printf("An IRC Operator just kicked your sorry ass offline!\n");
&exitprog('kill');
}
$conn->add_handler('join', \&on_join);
$conn->add_handler('part', \&on_part);
$conn->add_handler('public', \&on_chanmsg);
$conn->add_handler('msg', \&on_privmsg);
$conn->add_handler('kill', \&on_kill);
$conn->add_global_handler([ 251,252,253,254,302,255 ], \&on_init);
$conn->add_global_handler('disconnect', \&on_disconnect);
$conn->add_global_handler('leaving', \&on_leaving);
$conn->add_global_handler(376, \&on_connect);
$conn->add_global_handler(433, \&on_nick_taken);
$conn->add_global_handler(353, \&on_names);
printf("Connecting...\n");
$irc->start();
printf("error!\n");
Commands for this simple bot:
inside a private message type .quit to make it quit with the $quitmsg variable.
inside a channel, do !slap to have it slap you
Issues:
i had some problems using $conn->me()
instead of $conn->ctcp('action') etc
seems as if it blew up on me, i might not have my module set up correctly, might work well for you though. Just remember to compare hostmasks if you want some real admin, eg.
if ($fullhost eq $adminhost) {
#continue...
}
else {
$conn->privmsg($chan,"You do not have permission to do that $nick !");
}
I have made several bots in this way. SavBot, SavServ (an IRC NickServ and ChanServ in one). Also LogBot, FileBot, and a few others, these names aren't very original and i am sure they are all over the place, however mine are not distributed on the net, so you won't find mine if searching. I might make an all-perpose one like SavBot again, or improve upon the project.
As for multiple channels, bitchbot was made for only 1. For custom commands like that, same thing, very hard.