Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (37 sloc) 1.076 kb
use strict;
use warnings;
use Tatsumaki::Error;
use Tatsumaki::Application;
use Tatsumaki::HTTPClient;
use JSON;
package XMPPHandler;
use base qw(Tatsumaki::Handler::XMPP);
use JSON;
use URI;
sub post {
my $self = shift;
my $message = $self->xmpp_message;
my $uri = URI->new("");
$uri->query_form(v => "1.0", langpair => "en|ja", q => $message->body);
my $client = Tatsumaki::HTTPClient->new;
$client->get($uri, $self->async_cb(sub { $self->on_response($message, @_) }));
sub on_response {
my($self, $message, $res) = @_;
my $result = JSON::decode_json($res->content);
my $text = $result->{responseData}{translatedText};
package main;
use Tatsumaki::Service::XMPP;
my $svc = Tatsumaki::Service::XMPP->new(
my $app = Tatsumaki::Application->new([
'/_services/xmpp/chat' => 'XMPPHandler',
Jump to Line
Something went wrong with that request. Please try again.