Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
perl IRC bot
#1
A basic irc bot written by me brett7 in perl, this will connect to a server and channel of your choice then idle. There is some example commands you can use to make your own!

http://brett7.pastebin.com/f7232f0be

Code:
#!/usr/bin/perl -w
# Basic IRC Bot.
# Coded by brett7.

use strict;
use IO::Socket;
use Socket;
my $server = $ARGV[0];
my $port= '6667';
my $channel = $ARGV[1];
my $nick = $ARGV[2];
my $identify = "brett";
my $name = "brett";

if (@ARGV != 3){
print q{
#########################################################
#                    brett7's irc bot                   #
#Error: correct usage "irc.pl <server> <channel> <nick>"#
#########################################################
};
exit;
}
my $socket = new IO::Socket::INET(PeerAddr => $server, PeerPort => $port, Proto => "tcp") or die "Error connecting";
print " - brett7's irc bot\n\n";
print " - Connecting  To $server on channel $channel with nickname $nick!\n\n";
print $socket "NICK $nick\r\n";
print $socket "USER $identify 8 * :$name\r\n";
print $socket "JOIN $channel\r\n";
print " - Connected  To $server successfully!\n\n";
while (my $response = <$socket>)
{
  chop $response;
  if ($response =~ /^PING(.*)$/i) { print $socket "PONG $1\r\n"; }
  if ($response =~ /^.*!ver(.*)$/i) { print $socket ("PRIVMSG $channel brett7's bot\r\n"); }
  if ($response =~ /^.*!quit(.*)$/i) { print $socket ("QUIT\r\n"); }
}
Reply


Messages In This Thread
perl IRC bot - by brett7 - 10-09-2009, 03:32 PM
RE: perl IRC bot - by jolttz - 10-09-2009, 03:49 PM
RE: perl IRC bot - by nevets04 - 10-09-2009, 05:38 PM
RE: perl IRC bot - by dongblues - 10-09-2009, 06:07 PM
RE: perl IRC bot - by brett7 - 10-10-2009, 06:59 AM
RE: perl IRC bot - by C!RCU!T tr0jAn ☠ - 10-10-2009, 09:34 PM
RE: perl IRC bot - by flAmingw0rm - 10-26-2009, 01:22 PM
RE: perl IRC bot - by Socrates - 10-28-2009, 06:22 AM
RE: perl IRC bot - by wat - 12-05-2009, 09:41 PM
RE: perl IRC bot - by nextlive - 02-12-2010, 01:41 PM
RE: perl IRC bot - by JesusOfSuburbia - 05-03-2010, 02:10 AM
RE: perl IRC bot - by Julie - 05-09-2010, 03:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compile Error in Perl liveproject101 0 1,303 04-12-2013, 03:08 AM
Last Post: liveproject101
  [Perl] IRC Bot wchar_t 26 14,578 08-20-2012, 01:40 PM
Last Post: Trump
  Perl Ebook ven0m 2 1,826 05-04-2012, 08:14 AM
Last Post: ven0m
  Help with a program written in perl Rodman42866 1 1,686 03-09-2012, 03:16 AM
Last Post: AceInfinity
  HTML perl script AceInfinity 5 2,725 12-03-2011, 11:35 PM
Last Post: Closed Account

Forum Jump:


Users browsing this thread: 2 Guest(s)