Skip to content

Commit

Permalink
added uri template support
Browse files Browse the repository at this point in the history
  • Loading branch information
typester committed Nov 21, 2008
1 parent 35bf71e commit c1fcb09
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions outputz.pl
Expand Up @@ -8,6 +8,7 @@
Component::Client::HTTPDeferred
/;

use URI::Template;
use HTTP::Request::Common;

our %IRSSI = (
Expand All @@ -16,7 +17,7 @@
);

Irssi::settings_add_str('outputz', 'outputz_key', '');
Irssi::settings_add_str('outputz', 'outputz_uri', '');
Irssi::settings_add_str('outputz', 'outputz_uri', 'irc://{server}:{port}/{channel}');

POE::Session::Irssi->create(
irssi_signals => {
Expand All @@ -29,7 +30,14 @@
my $uri = Irssi::settings_get_str('outputz_uri');
return unless $key and $uri;

$uri = sprintf($uri, $target) if $uri =~ /%s/;
my $template = URI::Template->new($uri);
$uri = $template->process(
channel => $target,
server => $server->{address},
port => $server->{port},
nick => $server->{nick},
server_tag => $server->{tag},
);

my $ua = POE::Component::Client::HTTPDeferred->new;
my $d = $ua->request(
Expand Down

0 comments on commit c1fcb09

Please sign in to comment.