mirror of https://github.com/bonobonet/botty
Implement rot13
This commit is contained in:
parent
4f7cec3660
commit
c562103b84
|
@ -21,9 +21,20 @@ public final class Rot13 : Mod
|
|||
|
||||
public override void react(Message fullMessage, string channel, string messageBody)
|
||||
{
|
||||
import std.string : split, strip;
|
||||
string[] splits = split(strip(messageBody), " ");
|
||||
import std.string : indexOf, strip;
|
||||
import std.algorithm;
|
||||
|
||||
// TODO: Implement me @rany2
|
||||
long idx = indexOf(messageBody, commandStr);
|
||||
string toBeSecretified = messageBody[idx+commandStr.length..$];
|
||||
|
||||
getBot().channelMessage(
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue