]> git.donarmstrong.com Git - infobot.git/commitdiff
rot*
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 28 Feb 2005 02:53:55 +0000 (02:53 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 28 Feb 2005 02:53:55 +0000 (02:53 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1188 c11ca15a-4712-0410-83d8-924469b57eb5

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;