From 5b560e84a43c665e0d8566799ab5699c4e47da64 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Fri, 4 Jan 2019 09:13:58 +0000 Subject: [PATCH 1/1] Add earliest available revision This is the earliest version I still have; initial work was not tracked in git in any fashion. --- unicode-expand.pl | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 unicode-expand.pl diff --git a/unicode-expand.pl b/unicode-expand.pl new file mode 100644 index 0000000..d7ae931 --- /dev/null +++ b/unicode-expand.pl @@ -0,0 +1,68 @@ +use strict; +use warnings; + +use utf8; +use Encode qw(decode_utf8 encode_utf8); +use charnames (); + +use Irssi; +our $VERSION = '1.30'; +our %IRSSI = ( + authors => 'Jonathan McDowell', + contact => 'noodles@earth.li', + name => 'unicode-expand', + description => 'Expands Unicode characters to include their names', + license => 'Public Domain', + changed => "Fri Dec 8 13:39:00 UTC 2017", + url => 'https://the.earth.li/~noodles/unicode-expand.pl', +); + +sub expand_message_public { + my ($server, $data, $nick, $mask, $target) = @_; + Irssi::signal_continue($server, expand($data), $nick, $mask, $target); +} + +sub expand_message_private { + my ($server, $data, $nick, $mask) = @_; + Irssi::signal_continue($server, expand($data), $nick, $mask); +} + +sub expand_part { + my ($server, $channel, $nick, $mask, $reason) = @_; + Irssi::signal_continue($server, $channel, $nick, $mask, expand($reason)); +} + +sub expand_quit { + my ($server, $nick, $mask, $reason) = @_; + Irssi::signal_continue($server, $nick, $mask, expand($reason)); +} + +sub expand_kick { + my ($server, $channel, $nick, $kicker, $mask, $reason) = @_; + Irssi::signal_continue($server, $channel, $nick, $kicker, $mask, expand($reason)); +} + +sub expand_topic { + my ($server, $channel, $topic, $nick, $mask) = @_; + Irssi::signal_continue($server, $channel, expand($topic), $nick, $mask); +} + +sub expand { + my ($data) = @_; + + $data = decode_utf8($data); + $data =~ s{([^[:ascii:]\p{Letter}\p{Punctuation}\p{Control}\p{Space}\p{Currency_Symbol}])}{ + "${1}[".charnames::viacode(ord $1)."]" + }ge; + + return $data; +} + +Irssi::signal_add('message public', \&expand_message_public); +Irssi::signal_add('message private', \&expand_message_private); +Irssi::signal_add('message part', \&expand_part); +Irssi::signal_add('message quit', \&expand_quit); +Irssi::signal_add('message kick', \&expand_kick); +Irssi::signal_add('message topic', \&expand_topic); +Irssi::signal_add('message irc action', \&expand_message_public); +Irssi::signal_add('message irc notice', \&expand_message_public); -- 2.39.5