_______________________#!/usr/bin/perl use Net::IRC; use strict; # 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 || 'irc.whatever.net', Port => shift || '6667', Nick => 'Bot', Ircname => 'Bot', Username => 'Bot'); # We're going to add this to the conn hash so we know what channel we # want to operate in. $conn->{channel} = shift || '#mychannel'; 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; } 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!"); } sub on_part { # pretty much the same as above my ($conn, $event) = @_; my $nick = $event->{nick}; $conn->privmsg($conn->{channel}, "Goodbye, $nick!"); } sub on_public { my($conn, $event) = @_; my $text = $event->{args}[0]; if ($text eq "\U$text") { if (length $text > 6) { my $name_text = $event->{nick}; $conn->privmsg($event->{to}[0], "$name_text: No need to yell. Switch t +o lowercase and be happy. =)"); } } sub on_msg { my($conn, $event) = @_; $conn->privmsg($event->{nick}, "I, don't appreciate being /msg'd."); } # add event handlers for join and part events $conn->add_handler('join', \&on_join); $conn->add_handler('part', \&on_part); $conn->add_handler('public', \&on_public); $conn->add_handler('msg', \&on_msg); # The end of MOTD (message of the day), numbered 376 signifies we've c +onnect $conn->add_handler('376', \&on_connect); # start IRC $irc->start();
I entered irc.whatever.net for the server, because I've tried to connect it to multiple servers and it won't connect to any of them. I would think that this is simply a problem with my code, because it usually is =), but this same script was working before i rebooted my computer. Any help on this subject would be greatly appreciated, as I'm pulling my hair out over it. =)
Thanks a lotIn reply to Net::IRC problem by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |