Jump to content

User:Aphrael Runestar/textrep.pl

From Wikipedia, the free encyclopedia

For a nickcolor.pl-compatible version (replacement, actually), see colourtextrep.pl

#
# link replacement script for irssi.
#
# May end up being downloadable from http://wikipedia.org.
#

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

$VERSION = 0.1;
%IRSSI = (
  authors     => "Kiyoshi \"Aphrael Runestar\" Aman",
  contact     => "childgoddess\@gmail.com",
  name        => "linkrep",
  description => "link replacement script for irssi; replaces page with 
                   http://en.wikipedia.org/wiki/page",
  license     => "Creative Commons",
  changed     => "20040912"
);

Irssi::signal_add "event privmsg" => sub {
  my ($server, $data, $nick, $address) = @_;
  my ($target, $text) = split / :/,$data,2;
  
  return unless ($target eq "#wikipedia");
  
  $text =~ s/\[\[/http:\/\/en.wikipedia.org\/wiki\//g; $text =~ s/\]\]//g;
  $server->print($target,"<$nick> $text",MSGLEVEL_PUBLIC);
  Irssi::signal_stop();
}