From 256fe08963895cf1078f4f57c1c2673529fa25cd Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 14 Mar 2015 00:09:21 +0000 Subject: [PATCH] uncommited WIP from MWC --- contrib/vertobot/bot.pl | 9 ++++----- contrib/vertobot/bridge.pl | 18 +++++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/contrib/vertobot/bot.pl b/contrib/vertobot/bot.pl index 828fc4878..0430a38aa 100755 --- a/contrib/vertobot/bot.pl +++ b/contrib/vertobot/bot.pl @@ -175,13 +175,12 @@ sub on_room_message my $verto_connecting = $loop->new_future; $bot_verto->connect( %{ $CONFIG{"verto-bot"} }, - on_connected => sub { - warn("[Verto] connected to websocket"); - $verto_connecting->done($bot_verto) if not $verto_connecting->is_done; - }, on_connect_error => sub { die "Cannot connect to verto - $_[-1]" }, on_resolve_error => sub { die "Cannot resolve to verto - $_[-1]" }, -); +)->then( sub { + warn("[Verto] connected to websocket"); + $verto_connecting->done($bot_verto) if not $verto_connecting->is_done; +}); Future->needs_all( $bot_matrix->login( %{ $CONFIG{"matrix-bot"} } )->then( sub { diff --git a/contrib/vertobot/bridge.pl b/contrib/vertobot/bridge.pl index e1a07f665..a551850f4 100755 --- a/contrib/vertobot/bridge.pl +++ b/contrib/vertobot/bridge.pl @@ -86,7 +86,7 @@ sub create_virtual_user "user": "$localpart" } EOT - )->get; + )->get; warn $response->as_string if ($response->code != 200); } @@ -266,17 +266,21 @@ my $as_url = $CONFIG{"matrix-bot"}->{as_url}; Future->needs_all( $http->do_request( - method => "POST", - uri => URI->new( $CONFIG{"matrix"}->{server}."/_matrix/appservice/v1/register" ), - content_type => "application/json", - content => < "POST", + uri => URI->new( $CONFIG{"matrix"}->{server}."/_matrix/appservice/v1/register" ), + content_type => "application/json", + content => <then( sub{ + my ($response) = (@_); + warn $response->as_string if ($response->code != 200); + return Future->done; + }), $verto_connecting, )->get;