]> git.donarmstrong.com Git - infobot.git/blobdiff - src/UserExtra.pl
rot*
[infobot.git] / src / UserExtra.pl
index 7112f97a7d314ad2fee479a4d6f307cc2505672f..cb0dc29ce0456785756e195a3e38fd99dcac0a00 100644 (file)
@@ -585,15 +585,20 @@ sub userCommands {
     }
 
     # rot13 it.
-    if ($message =~ /^rot13(\s+(.*))?/i) {
-       my $reply = $2;
+    if ($message =~ /^rot([0-9]*)(\s+(.*))?/i) {
+       my $reply = $3;
 
        if (!defined $reply) {
            &help("rot13");
            return;
        }
+       my $num = $1 % 26;
+       my $upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+       my $lower="abcdefghijklmnopqrstuvwxyz";
+       my $to=substr($upper,$num).substr($upper,0,$num).substr($lower,$num).substr($lower,0,$num);
+       eval "\$reply =~ tr/$upper$lower/$to/;";
 
-       $reply =~ y/A-Za-z/N-ZA-Mn-za-m/;
+       #$reply =~ y/A-Za-z/N-ZA-Mn-za-m/;
        &performStrictReply($reply);
 
        return;