use strict; use Encode qw(encode decode); use Irssi qw(signal_add); sub linkify { my ($text) = @_; $text =~ s/ /_/gm; $text =~ s/\[\[|\]\]|\{\{|\}\}//gm; return $text; } sub wikilink { my ($server, $message, $nick, $address, $target) = @_; $_ = decode('utf-8',$message); # recognize umlauts while (/\[\[(\w|\s|!|#|\/|\.|-|\(|\)|\\|{|}|_|^,|`|\/|;|'|\:|\[|\])*?\]\]/i) { # is linky there? return if $server->channel_find($target)->nick_find_mask("*linky"); my $wplink = linkify($&); my $retval = "http://de.wikipedia.org/wiki/" . encode('latin1',$wplink); $server->command("MSG $target $retval"); } while (/\{\{(\w|\s|!|#|\/|\.|-|\(|\)|\\|{|}|_|^,|\`|\/|;|'|\:|\[|\])*?\}\}/i) { # is linky there? return if $server->channel_find($target)->nick_find_mask("*linky"); my $wplink = linkify($&); my $retval = "http://de.wikipedia.org/wiki/Vorlage:" . encode('latin1',$wplink); $server->command("MSG $target $retval"); } return 0; } signal_add("message public","wikilink");