use strict;
use vars qw($VERSION %IRSSI);

use Irssi;
$VERSION = '1.00';
%IRSSI = (
    authors     => 'Phil Tom',
    contact     => 'phil@asdf.com',
    name        => 'mime-url',
    description => 'irssi command to auto post a url using mimezine shortlink technology {tm}',
    license     => 'your soul for one day',
);

sub cmd_url {
  # data - contains the parameters for /HELLO 
  # server - the active server in window
  # witem - the active window item (eg. channel, query) 
  #         or undef if the window is empty
  my ($data, $server, $witem) = @_;

  if (!$server || !$server->{connected}) {
    Irssi::print("Not connected to server");
    return;
  } 
  
  if ($data &&
      $witem && $witem->{type} eq "CHANNEL") {
    $witem->command("MSG omnicron posturl ".$witem->{name}." ".$data);
  } else {
    Irssi::print("no active channel in window, or no url given.");
  }
} 

Irssi::command_bind('url', 'cmd_url');
