mirror of https://github.com/bonobonet/botty
Translate
- Allows someone to now do `.tr:<lang> <text>` to translate text from some language (auto-detected) to another language (specified as `<lang>`)
This commit is contained in:
parent
85b6c65ccb
commit
c00d83d070
|
@ -32,11 +32,18 @@ public final class Translate : Mod
|
|||
{
|
||||
import std.string : indexOf, strip, split;
|
||||
|
||||
// TODO: Implement custom language (to) support
|
||||
|
||||
string[] splits = split(strip(messageBody), " ");
|
||||
|
||||
long textIdx = indexOf(messageBody, " ");
|
||||
|
||||
|
||||
|
||||
// Check for `.tr:<lang>`
|
||||
string toLang = "en";
|
||||
long toLangIdx = splits[0].indexOf(":");
|
||||
if(toLangIdx > -1)
|
||||
{
|
||||
toLang = splits[0].split(":")[1];
|
||||
}
|
||||
|
||||
if(textIdx > -1)
|
||||
{
|
||||
|
@ -50,7 +57,7 @@ public final class Translate : Mod
|
|||
|
||||
try
|
||||
{
|
||||
string translatedText = translate(textToTranslate);
|
||||
string translatedText = translate(textToTranslate, toLang);
|
||||
getBot().channelMessage(translatedText, channel);
|
||||
}
|
||||
// On network error
|
||||
|
|
Loading…
Reference in New Issue