Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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;
Add Comment
Please, Sign In to add comment