Abjects 서버에서 내 채널에 간단한 IRC 봇을 만들려면 Programming IRC Bots In Perl이라는 자습서를 따르고 있습니다. 문제는 이상한 오류가 발생한다는 것입니다.
./bot.pl 발견되지 명령 행 1 :Perl로 만든 IRC 봇의 몇 가지 간단한 오류
나단 Camposs - 맥북 프로 : 데스크탑 나단 $의 ./bot.pl
./bot.pl 사용 살펴 보자 : 라인 4 : 내 : 명령을 찾을 수 없습니다
./bot.pl : 행 8 : 예기치 않은 토큰('
내 $ CONN = $ irc-> newconn ('
./bot.pl: line 8:
나단 Camposs - 맥북 - 프로 근처의 구문 오류 : 데스크탑 나단 $
다음 코드 사용
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 –