uncommited WIP from MWC

This commit is contained in:
Matthew Hodgson 2015-03-14 00:09:21 +00:00
parent e731d30d90
commit 256fe08963
2 changed files with 15 additions and 12 deletions

View File

@ -175,13 +175,12 @@ sub on_room_message
my $verto_connecting = $loop->new_future; my $verto_connecting = $loop->new_future;
$bot_verto->connect( $bot_verto->connect(
%{ $CONFIG{"verto-bot"} }, %{ $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_connect_error => sub { die "Cannot connect to verto - $_[-1]" },
on_resolve_error => sub { die "Cannot resolve 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( Future->needs_all(
$bot_matrix->login( %{ $CONFIG{"matrix-bot"} } )->then( sub { $bot_matrix->login( %{ $CONFIG{"matrix-bot"} } )->then( sub {

View File

@ -86,7 +86,7 @@ sub create_virtual_user
"user": "$localpart" "user": "$localpart"
} }
EOT EOT
)->get; )->get;
warn $response->as_string if ($response->code != 200); warn $response->as_string if ($response->code != 200);
} }
@ -266,17 +266,21 @@ my $as_url = $CONFIG{"matrix-bot"}->{as_url};
Future->needs_all( Future->needs_all(
$http->do_request( $http->do_request(
method => "POST", method => "POST",
uri => URI->new( $CONFIG{"matrix"}->{server}."/_matrix/appservice/v1/register" ), uri => URI->new( $CONFIG{"matrix"}->{server}."/_matrix/appservice/v1/register" ),
content_type => "application/json", content_type => "application/json",
content => <<EOT content => <<EOT
{ {
"as_token": "$as_token", "as_token": "$as_token",
"url": "$as_url", "url": "$as_url",
"namespaces": { "users": ["\@\\\\+.*"] } "namespaces": { "users": [ { "regex": "\@\\\\+.*", "exclusive": false } ] }
} }
EOT EOT
), )->then( sub{
my ($response) = (@_);
warn $response->as_string if ($response->code != 200);
return Future->done;
}),
$verto_connecting, $verto_connecting,
)->get; )->get;