Merge branch 'master' of github.com:bonobonet/botty

This commit is contained in:
Tristan B. Velloza Kildaire 2023-06-17 22:36:19 +02:00
commit 264b059e24
1 changed files with 4 additions and 2 deletions

View File

@ -22,18 +22,20 @@ public final class Rot13 : Mod
public override void react(Message fullMessage, string channel, string messageBody)
{
import std.string : indexOf, strip;
import std.algorithm : map;
import std.conv : to;
long idx = indexOf(messageBody, commandStr);
string toBeSecretified = messageBody[idx+commandStr.length..$];
getBot().channelMessage(
toBeSecretified.map!((ch) {
to!(string)(toBeSecretified.map!((ch) {
if (ch >= 'a' && ch <= 'z')
ch = (ch - 'a' + 13) % 26 + 'a';
if (ch >= 'A' && ch <= 'Z')
ch = (ch - 'A' + 13) % 26 + 'A';
return ch.to!char;
}), channel
})), channel
);
}
}