私はProgramming IRC Bots In Perlというチュートリアルに従い、Abjectsサーバで自分のチャンネル用の簡単なIRCボットを作成していますが、問題は奇妙なエラーが発生していることです。
./bot.plコマンドが見つかりません:行1:Perlで作成されたIRCボットでの単純なエラー
ネイサン・Camposs-のMacBook Proの-:デスクトップネイサンの$ ./bot.pl
./bot.pl使用を見てみましょう: 4行目:私の:コマンドが見つからない
./bot.pl:8行目:予期しないトークン('
私の$でCONN = $ irc-> newconn(」
./bot.pl: line 8:
ネイサン・Camposs-のMacBook Proの-の近くに構文エラー:デスクトップネイサン$
このコードの場合:
use Net::IRC;
# create the IRC object
my $irc = new Net::IRC;
# Create a connection object. You can have more than one "connection" per
# IRC object, but we'll just be working with one.
my $conn = $irc->newconn(
Server => shift || 'summer.abjects.net',
# Note: IRC port is normally 6667, but my firewall won't allow it
Port => shift || '6667',
Nick => 'iBot',
Ircname => 'I\'ve bee built by iNathan!',
Username => 'iBot'
);
# We're going to add this to the conn hash so we know what channel we
# want to operate in.
$conn->{channel} = shift || '#MobilePassion';
sub on_connect {
# shift in our connection object that is passed automatically
my $conn = shift;
# when we connect, join our channel and greet it
$conn->join($conn->{channel});
$conn->privmsg($conn->{channel}, 'Hello everyone!');
$conn->{connected} = 1;
}
# The end of MOTD (message of the day), numbered 376 signifies we've connect
$conn->add_handler('376', \&on_connect);
sub on_join {
# get our connection object and the event object, which is passed
# with this event automatically
my ($conn, $event) = @_;
# this is the nick that just joined
my $nick = $event->{nick};
# say hello to the nick in public
$conn->privmsg($conn->{channel}, "Hello, $nick!");
}
$conn->add_handler('join', \&on_join);
$irc->start();
これを修正するにはどうすればよいですか?
しかし、 'POE :: Component :: IRC'で動作するように私のコードをどのように変更できますか? –
いくつかの 'POE :: Component :: IRC' IRCボットチュートリアルがありますが、私はあなたが実際にこのモジュール用ではないものを見つけたことに驚いています。幸運なことに、既存の例ではコードがあまり多くなく、移植もあまり難しくありません。特定のIRC関連イベントへのフックの登録と、それらのフック/イベントを処理する関数の作成にも同じ原則が適用されます。 –
同様に、サンプルPOE :: Component :: IRCボットはhttp://www.supportforums.net/showthread.php?tid=10989、http://search.cpan.org/~のドキュメントにあります。 hinrik/POE-Component-IRC-6.52/lib/POE/Component/IRC.pm –