App-Tacochan
view release on metacpan or search on metacpan
bin/tacochan view on Meta::CPAN
[
'Content-Type' => 'text/plain; charset=utf-8',
'Content-Length' => length $message,
],
[$message]
);
}
sub res_404 { $_[0]->render_text(404, 'Not Found') }
sub guess_chat {
my ($self, $stuff) = @_;
if ($stuff =~ /^#/) {
# from chatname
return $skype->chat($stuff);
} elsif ($stuff =~ /^skype:/) {
# from "/get uri"
my %query = URI->new($stuff)->query_form();
my $command = $skype->api->send_command("CHAT FINDUSINGBLOB $query{blob}");
my @reply = $command->split_reply();
return $skype->chat($reply[1]);
bin/tacochan view on Meta::CPAN
};
post qr!^/(?:leave|part)$! => sub {
my ($c) = @_;
unless ($skype->api->is_running) {
return $c->render_text(500, 'Skype is not running')
}
my $chat = $c->req->param('chat');
my $chat_obj = $c->guess_chat($chat);
eval {
$chat_obj->alter('leave');
};
if ($@) {
return $c->render_text(403, "leave failure chat: $chat");
}
return $c->render_text(200, "leave success chat: $chat");
};
post qr!^/(?:send|notice|privmsg)$! => sub {
my ($c) = @_;
unless ($skype->api->is_running) {
return $c->render_text(500, 'Skype is not running')
}
my $chat = $c->req->param('chat');
my $message = $c->req->param('message');
my $chat_obj = $c->guess_chat($chat);
eval {
$chat_obj->send_message($message);
};
if ($@) {
return $c->render_text(403, "message sent failure chat: $chat $message");
}
return $c->render_text(200, "message sent chat: $chat_obj->{id} $message");
};
get '/chat_id' => sub {
my ($c) = @_;
unless ($skype->api->is_running) {
return $c->render_text(500, 'Skype is not running');
}
my $chat = $c->req->param('chat');
my $chat_obj = $c->guess_chat($chat);
return $c->render_text(200, "$chat_obj->{id}");
};
__PACKAGE__->load_plugin('Web::JSON');
my $parser = Getopt::Long::Parser->new(
config => ['no_ignore_case', 'pass_through'],
);
my %options;
( run in 0.331 second using v1.01-cache-2.11-cpan-94b05bcf43c )