File: notify

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 (44 lines) | stat: -rwxr-xr-x 883 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env perl
use common::sense;
use AnyEvent;
use AnyEvent::IRC::Client;

my $c = AnyEvent->condvar;

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

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

      if (defined $err) {
         warn "Couldn't connect: $err\n";
         $c->send;
      } else {
         print "Connected!\n";
      }

      $con->register (qw/testbot testbot testbot/);
   },
   registered => sub {
      my ($con) = @_;
      print "I'm in!\n";

      $con->reg_cb (buffer_empty => sub {
         my ($con) = @_;
         $con->unreg_me;
         $con->disconnect ("Message delivered!");
      });
      $con->send_msg (
         PRIVMSG => 'elmex', "Hello there i'm the cool AnyEvent::IRC test script!"
      );
   },
   disconnect => sub {
      print "I'm out ($_[1])!\n";
      $c->send
   },
);

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

$c->recv;