r1ch.net forums
* Home Help Search Login Register
r1ch.net  |  r1ch.net stuff  |  Bitchbot  |  Topic: works fine but...
Pages: [1]
Print
Author Topic: works fine but...  (Read 12490 times)
nef
Member

Posts: 6


« on: April 05, 2007, 12:50:20 am »

works really well, it logs onto irc easliy and everything, but
1. how do you connect to mult. channels
2. how do you make it say stuff without having to say [botnamename], x or x??
« Last Edit: April 05, 2007, 06:36:41 pm by nef » Logged
nef
Member

Posts: 6


« Reply #1 on: April 05, 2007, 07:05:23 pm »

like just whenever someone says "nef", the bot says "nef is god", or whatever

anyone?


i looked in the perl and i'm pretty sure it's this:

#######################
# CHECK FOR COMMAND?? #
#######################
if ($noqq == 0 && substr($mtext,-2,2) eq "??") {
  if ($mtext =~ /^\Q$botname\E($botanswer)/i) {
    sndtxt("Use either \002$botname, command\002 or \002command??\002, not both.");
    next;
  }
  $mtext = "$botname, " . substr($mtext,0,length($mtext)-2);
  $silent = 1;
}

if (lc($ffirstword) eq "seen") {
  if ($silent == 0) {
    $mtext = lc($botname) . ", " . $mtext;
  }
}

so if anyone is really good w/ perl and could help me out... thnx
Logged
marla singer
Guest
« Reply #2 on: April 29, 2007, 07:17:28 am »

You still suck, nef, and should have your azz molested.   -marla
Logged
Savvy
Guest
« Reply #3 on: August 06, 2007, 06:05:12 pm »

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:
Code:
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.
Code:
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.
Logged
Savvy
Guest
« Reply #4 on: August 06, 2007, 06:06:35 pm »

Also i don't come to this forum often, so chances of asking me more are almost nothing unless you come to EdgeIRC while i still play the quake2 mod Gloom. I go by Savvy and savvy only really.
Logged
Pages: [1]
Print
r1ch.net  |  r1ch.net stuff  |  Bitchbot  |  Topic: works fine but...
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines