cpan - Some Simple Errors With a IRC Bot Made With Perl -
i'm following tutorial called programming irc bots in perl make simple irc bot channel @ abjects server, problem i'm getting weird errors. take look:
nathan-camposs-macbook-pro:desktop nathan$ ./bot.pl
./bot.pl: line 1: use: command not found
./bot.pl: line 4: my: command not found
./bot.pl: line 8: syntax error near unexpected token('
my $conn = $irc->newconn('
./bot.pl: line 8:
nathan-camposs-macbook-pro:desktop nathan$
with code:
use net::irc; # create irc object $irc = new net::irc; # create connection object. can have more 1 "connection" per # irc object, we'll working one. $conn = $irc->newconn( server => shift || 'summer.abjects.net', # note: irc port 6667, firewall won't allow port => shift || '6667', nick => 'ibot', ircname => 'i\'ve bee built inathan!', username => 'ibot' ); # we're going add conn hash know channel # want operate in. $conn->{channel} = shift || '#mobilepassion'; sub on_connect { # shift in our connection object passed automatically $conn = shift; # when connect, join our channel , greet $conn->join($conn->{channel}); $conn->privmsg($conn->{channel}, 'hello everyone!'); $conn->{connected} = 1; } # end of motd (message of day), numbered 376 signifies we've connect $conn->add_handler('376', \&on_connect); sub on_join { # our connection object , event object, passed # event automatically ($conn, $event) = @_; # nick joined $nick = $event->{nick}; # hello nick in public $conn->privmsg($conn->{channel}, "hello, $nick!"); } $conn->add_handler('join', \&on_join); $irc->start();
what should correct this?
in addition, , i'm sure you've seen , heard before somewhere, favor , don't use net::irc
... it's been dead in water self advertised 7 years.
the new recommendation use poe::component::irc
or variant. while poe::component::irc
offers control, flexibility, , visibility functions of bot, easier approach bot::basicbot
.
hope helps.
Comments
Post a Comment