From 03929dac2a29664878d2c971648a4fe1fb698462 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:19:02 +0200 Subject: Adding upstream version 20231031. Signed-off-by: Daniel Baumann --- scripts/rot13.pl | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 scripts/rot13.pl (limited to 'scripts/rot13.pl') diff --git a/scripts/rot13.pl b/scripts/rot13.pl new file mode 100644 index 0000000..2b74fd7 --- /dev/null +++ b/scripts/rot13.pl @@ -0,0 +1,77 @@ +# rot13.pl +# Mariusz "Craig" Cieśla +# ROT13-encodes and decodes messages on the channel :) + +use strict; + +use vars qw($VERSION %IRSSI); + +$VERSION = "2003121202"; + +%IRSSI = ( + authors => "Mariusz 'Craig' Ciesla", + contact => "craig\@fish.mac.edu.pl", + name => "rot13", + description => "ROT13 encoding and reverse :)", + license => "GPLv2", + changed => "$VERSION", + commands => "rot13 unrot13" +); + +use Irssi 20020324; + +sub text2rot ($) +{ + my ($text) = @_; + + $text =~ y/N-ZA-Mn-za-m/A-Za-z/; + + return $text."  "; +} + +sub rot2text ($) +{ + my ($text) = @_; + + $text =~ y/A-Za-z/N-ZA-Mn-za-m/; + + return $text; +} + +sub rot13_decode ($$$) +{ + my ($server, $target, $text) = @_; + + return unless ($text =~ /(^|.*?)  /g); + my $witem = $server->window_item_find($target); + + return unless ($witem); + $witem->print("%B[ROT13]>>%n ".rot2text($1), MSGLEVEL_CLIENTCRAP); +} + +sub cmd_rot13 ($$$) +{ + my ($arg, $server, $witem) = @_; + + if ($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY')) + { + $witem->command('MSG '.$witem->{name}.' '.text2rot($arg)); + } else { + print CLIENTCRAP "%B>>%n ".text2rot($arg); + } +} + +sub cmd_unrot13 ($$$) +{ + my ($arg, $server, $witem) = @_; + + print CLIENTCRAP "%B>>%n ".rot2text($arg); +} + +Irssi::command_bind('rot13',\&cmd_rot13); +Irssi::command_bind('unrot13',\&cmd_unrot13); + +Irssi::signal_add('message public',sub {rot13_decode($_[0], $_[4], $_[1]);} ); +Irssi::signal_add('message own_public',sub {rot13_decode($_[0], $_[2], $_[1]);}); + +print "%B>>%n ".$IRSSI{name}." ".$VERSION." loaded"; -- cgit v1.2.3