Alice
view release on metacpan or search on metacpan
# extlib present
if (-e "$bin/../extlib") {
eval "use lib '$bin/../extlib/lib/perl5'";
eval "use local::lib '$bin/../extlib'";
}
}
require Alice::Standalone;
}
$0 = "aliced\0";
binmode(STDERR, ":utf8");
binmode(STDOUT, ":utf8");
Alice::Standalone->new->run;
lib/Alice.pm view on Meta::CPAN
sub _build_window_buffer {
my ($self, $id) = @_;
Alice::MessageBuffer->new(
id => $id,
store => $self->message_store,
);
}
sub _build_window_id {
my ($self, $title, $network) = @_;
md5_hex(encode_utf8(lc $self->user."-$title-$network"));
}
sub find_or_create_window {
my ($self, $title, $irc) = @_;
return $self->info_window if $title eq "info";
if (my $window = $self->find_window($title, $irc)) {
return $window;
}
lib/Alice/HTTP/Request.pm view on Meta::CPAN
}
sub new_response {
my $self = shift;
Alice::HTTP::Response->new($self->{cb}, @_);
}
sub param {
my $self = shift;
if (wantarray) {
return map {decode("utf8", $_)} $self->SUPER::param(@_);
}
else {
return decode("utf8", $self->SUPER::param(@_));
}
}
1;
lib/Alice/HTTP/Response.pm view on Meta::CPAN
$self->status($rc) if defined $rc;
$self->headers($headers) if defined $headers;
$self->body($content) if defined $content;
$self;
}
sub send {
my $self = shift;
my $res = $self->SUPER::finalize;
$res->[2] = [map encode("utf8", $_), @{$res->[2]}];
return $self->{cb}->($res);
}
sub notfound {
my $self = shift;
return $self->{cb}->([404, ["Content-Type", "text/plain", "Content-Length", 9], ['not found']]);
}
sub ok {
my $self = shift;
lib/Alice/HTTP/Server.pm view on Meta::CPAN
}
push @queue, sub {
my $html = $app->render('index_footer', $options, @windows);
$app->config->first_run(0);
$app->config->write;
return $html;
};
my $idle_w; $idle_w = AE::idle sub {
if (my $cb = shift @queue) {
my $content = encode "utf8", $cb->();
$writer->write($content);
} else {
$writer->close;
undef $idle_w;
}
};
}
sub merged_options {
my ($self, $req) = @_;
lib/Alice/HTTP/Server.pm view on Meta::CPAN
sub render {
my $self = shift;
return $self->app->render(@_);
}
sub export_config {
my ($self, $req, $res) = @_;
$res->content_type("text/plain; charset=utf-8");
{
$res->body(to_json($self->app->config->serialized,
{utf8 => 1, pretty => 1}));
}
$res->send;
}
__PACKAGE__->meta->make_immutable;
1;
lib/Alice/HTTP/Stream/WebSocket.pm view on Meta::CPAN
$self->send([{type => "identify", id => $self->id}]);
}
sub send {
my ($self, $messages) = @_;
$messages = [$messages] unless ref $messages eq "ARRAY";
my $line = to_json(
{queue => $messages},
{utf8 => 1, shrink => 1}
);
$self->send_raw($line);
}
sub send_raw {
my ($self, $string) = @_;
$self->handle->push_write(
'AnyEvent::Handle::Message::WebSocket',
$string
lib/Alice/HTTP/Stream/XHR.pm view on Meta::CPAN
$self->clear_queue;
$self->last_send(time);
}
sub to_string {
my $self = shift;
return to_json({
queue => $self->queue,
time => time - $self->offset,
}, {utf8 => 1, shrink => 1});
}
__PACKAGE__->meta->make_immutable;
1;
lib/Alice/IRC.pm view on Meta::CPAN
my $email_re = qr/([^<\s]+@[^\s>]+\.[^\s>]+)/;
my $image_re = qr/(https?:\/\/\S+(?:jpe?g|png|gif))/i;
{
no warnings;
# YUCK!!!
*AnyEvent::IRC::Connection::_feed_irc_data = sub {
my ($self, $line) = @_;
my $m = parse_irc_msg (decode ("utf8", $line));
$self->event (read => $m);
$self->event ('irc_*' => $m);
$self->event ('irc_' . (lc $m->{command}), $m);
};
*AnyEvent::IRC::Connection::mk_msg = \&mk_msg;
*AnyEvent::IRC::Client::mk_msg = \&mk_msg;
}
has 'cl' => (is => 'rw');
lib/Alice/IRC.pm view on Meta::CPAN
# split up the multiple lines in the message:
my @lines = split /\n/, $msg;
@lines = map split_unicode_string ("utf-8", $_, $line_len), @lines;
$self->cl->send_srv($cmd => @params, $_) for @lines;
}
sub send_raw {
my $self = shift;
$self->cl->send_raw(encode "utf8", $_[0]);
}
sub is_connected {
my $self = shift;
$self->cl ? $self->cl->is_connected : 0;
}
sub is_disconnected {
my $self = shift;
return !($self->is_connected or $self->is_connecting);
lib/Alice/IRC.pm view on Meta::CPAN
$cur_out .= $word;
$word = '';
}
}
push @lines, $cur_out if length ($cur_out);
return @lines;
}
sub mk_msg {
encode "utf8", AnyEvent::IRC::Util::mk_msg(@_);
}
__PACKAGE__->meta->make_immutable;
1;
lib/Alice/Window.pm view on Meta::CPAN
package Alice::Window;
use Encode;
use utf8;
use Alice::MessageBuffer;
use Text::MicroTemplate qw/encoded_string/;
use IRC::Formatting::HTML qw/irc_to_html/;
use Any::Moose;
use AnyEvent;
my $url_regex = qr/\b(https?:\/\/(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»ââââ]))/i;
has buffer => (
is => 'rw',
( run in 1.391 second using v1.01-cache-2.11-cpan-49f99fa48dc )