File: test_connect

package info (click to toggle)
libanyevent-irc-perl 0.96-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 284 kB
  • sloc: perl: 1,588; makefile: 2
file content (25 lines) | stat: -rwxr-xr-x 503 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env perl
use AnyEvent;
use AnyEvent::IRC::Connection;

my $c = AnyEvent->condvar;

my $con = new AnyEvent::IRC::Connection;

$con->connect ("localhost", 6667);

$con->reg_cb (
   connect => sub {
      my ($con) = @_;

      $con->send_msg (NICK => "testbot");
      $con->send_msg (USER => "testbot", '*', '0', 'testbot');
   },
   irc_001 => sub {
      my ($con, $msg) = @_;
      print "$msg->{prefix} says i'm in the IRC: $msg->{params}->[-1]!\n";
      $c->broadcast
   }
);

$c->wait;