cho45 (owner)

Revisions

gist: 170295 Download_button fork
public
Public Clone URL: git://gist.github.com/170295.git
Embed All Files: show embed
improxy.pl #
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/perl
 
use strict;
use warnings;
 
use Perl6::Say;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Connection;
use Config::Pit;
 
my $config = pit_get("gtalk", require => {
username => "username",
password => "password"
});
 
my $j = AnyEvent->condvar;
 
my $client = AnyEvent::XMPP::Client->new( debug => 0 );
$client->add_account($config->{username}, $config->{password}, 'talk.google.com', 5222);
$client->start;
 
$client->reg_cb(
connected => sub {
# $client->send_message( 'test', 'cho45@lowreal.net' );
say "Connected";
},
 
message => sub {
my ($client, $account, $msg) = @_;
# google サーバに決め打ちしたければそうすればよい? 親アカウントが gmail アカウントなのでなんもしなくても届くっぽい
# my $connection = AnyEvent::XMPP::Connection->new(username => 'cho45', domain => 'lowreal.net', host => 'xmpp-server.l.google.com', port => 5269);
# $msg->send($connection);
 
use Data::Dumper;
warn Dumper $msg->from;
if ($msg->from =~ /api\@im\.kayac\.com/) {
$client->send_message("Notice: " . $msg->body, 'cho45@lowreal.net');
}
}
);
 
$j->wait;