Skip to content
Browse files

Merge remote-tracking branch 'origin/pr/1'

  • Loading branch information...
2 parents 554e102 + 97336bd commit c85f9a5f19109371dc5aa994c3fa3190e897e16c @typester committed
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/AnyEvent/Lingr.pm
View
14 lib/AnyEvent/Lingr.pm
@@ -265,14 +265,14 @@ sub _polling {
}
sub say {
- my ($self, $room, $msg) = @_;
+ my ($self, $room, $msg, $cb) = @_;
$self->post('room/say', { session => $self->session, room => $room, text => $msg }, sub {
my ($res, $hdr) = @_;
return unless $self;
if ($res and $res->{status} eq 'ok') {
- # ok
+ $cb->($res);
}
else {
$self->_on_error($res, $hdr);
@@ -409,12 +409,20 @@ For updating subscription list, you can use C<update_room_info> method:
Update joined room info, and fire on_room_info callback.
This method also update subscription rooms which is target room for on_event callback.
-=head2 say($room, $message)
+=head2 say($room, $message [, $cb ])
Say something to lingr room.
$lingr->say('perl_jp', 'hi!');
+If you want response data, you can speficy callback.
+The callback is invoked when the API call was successful.
+
+ $lingr->say('perl_jp', 'hi there!', sub {
+ my $res = shift;
+ warn $res->{message}->{id};
+ });
+
=head1 CALLBACKS
This module supports following three callbacks:

0 comments on commit c85f9a5

Please sign in to comment.
Something went wrong with that request. Please try again.