github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

yannk / perl-net-appnotifications

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

perl5 interface to www.appnotifications.com: easily deliver push notifications to your iPhone — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Add Manifest 
yannk (author)
Wed Sep 16 13:19:41 -0700 2009
commit  ad2460627e440370c3975b97585452d6eea8ddb4
tree    0f5ad2d9d1bf0c4c65399b384972ea0f8ce395e4
parent  8080b0635f1146ce97f08da9bef971ba1223bc2e
perl-net-appnotifications / eg / irc_alert.pl eg/irc_alert.pl
100644 62 lines (52 sloc) 1.581 kb
edit raw blame history
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use strict;
use warnings;
use AnyEvent;
use AnyEvent::IRC::Client;
use Net::AppNotifications;
use Carp;
 
## A basic script that connects to irc and send notifications
## each time a message matching a regexp is send to the chan
 
## the regexp triggering a notification
my $re = qr/(appnotification|iphone|omg|alert|ddos|dos)/i;
my $nick = 'appnotifications';
 
my $key = shift or croak "usage: $0 <key> <irc server> <chan>";
my $server = shift || "localhost";
my $chan = shift || "#test";
 
unless ($chan =~ /^#/) {
    warn "Channel must have a #";
    $chan = "\#$chan";
}
 
my ($host, $port) = ($server =~ /^(.+):(\d+)$/);
$host ||= $server;
$port ||= 6667;
 
my $con = AnyEvent::IRC::Client->new;
my $c = AnyEvent->condvar;
my $timer;
 
my $notifier = Net::AppNotifications->new(key => $key);
 
$con->reg_cb(registered => sub { print "Hit ^C to interrupt\n"; });
$con->reg_cb(disconnect => sub { print "I'm out!\n"; $c->broadcast });
#use YAML;
#$con->reg_cb(read => sub { warn Dump $_[1] });
$con->reg_cb(
    publicmsg => sub {
        my $msg = $_[2]->{params}[1];
        return unless $msg;
        if ($msg =~ $re) {
            $notifier->send(
                message => "IRC $chan: $msg",
                on_success => sub { print "delivered\n" },
                on_error => sub { print "NOT delivered\n" },
            );
        }
    },
);
$con->send_srv("JOIN", $chan);
#$con->send_chan(
# $chan,
# "PRIVMSG",
# $chan,
# "Hi, i'm a bot sending iPhone notifications!",
#);
 
$con->connect($host, $port, { nick => $nick });
$c->wait;
$con->disconnect;
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server