Skip to content

Commit

Permalink
test set_tea
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Jul 27, 2014
1 parent 194aa31 commit a88a6bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
- cpanm --quiet --notest --installdeps .

script:
- PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine prove -lrsv t
- TXMPP=0 PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine prove -lrsv t
- cover

after_success:
Expand Down
45 changes: 24 additions & 21 deletions lib/TeaTime.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,30 @@ sub send_message ($self, $message, $passed_j = undef) {
require AnyEvent;
require AnyEvent::XMPP::Client;

my $j;
$j = AnyEvent->condvar unless $passed_j;
my $cl = AnyEvent::XMPP::Client->new();
$cl->add_account(
config->{xmpp}{jid}, config->{xmpp}{password}, config->{xmpp}{server},
undef, { dont_retrieve_roster => 1 }
);
$cl->reg_cb (
session_ready => sub {
for ($self->contact_rs->enabled->get_column('jid')->all) {
$cl->send_message($message, $_)
if $self->config->{send_messages};
say "Sending $message to $_";
}
$cl->reg_cb(send_buffer_empty => sub { $cl->disconnect });
},
disconnect => sub { if ($passed_j) { $passed_j->send } else { $j->send } },
error => sub { say "ERROR: " . $_[2]->string },
);
$cl->start;
$j->recv unless $passed_j;
if ($self->config->{send_messages}) {
my $j;
$j = AnyEvent->condvar unless $passed_j;
my $cl = AnyEvent::XMPP::Client->new();
$cl->add_account(
config->{xmpp}{jid}, config->{xmpp}{password}, config->{xmpp}{server},
undef, { dont_retrieve_roster => 1 }
);
$cl->reg_cb (
session_ready => sub {
for ($self->contact_rs->enabled->get_column('jid')->all) {
$cl->send_message($message, $_);
say "Sending $message to $_";
}
$cl->reg_cb(send_buffer_empty => sub { $cl->disconnect });
},
disconnect => sub { if ($passed_j) { $passed_j->send } else { $j->send } },
error => sub { say "ERROR: " . $_[2]->string },
);
$cl->start;
$j->recv unless $passed_j;
} else {
$passed_j->send if $passed_j
}
}

sub _plugins {
Expand Down

0 comments on commit a88a6bd

Please sign in to comment.