54 lines
1.5 KiB
D
54 lines
1.5 KiB
D
module commands.mozhi;
|
|
|
|
// import api;
|
|
// import util;
|
|
// import commands.util;
|
|
// import api_data;
|
|
|
|
// import asdf;
|
|
|
|
// @Command("Translates text via Mozhi")
|
|
// auto tr(Arguments argz, EventWithoutRoomID* evt) {
|
|
// struct RqRsp {
|
|
// string engine;
|
|
// string detected;
|
|
// @serdeKeys("translated-text") string translatedText;
|
|
// string source_language;
|
|
// string target_language;
|
|
// }
|
|
|
|
// MSG msg;
|
|
// string text;
|
|
// auto ngn = argz.getArg("E");
|
|
// auto instance = argz.getArg("I");
|
|
// MSG origin = evt.content.raw.deserialize!MSG;
|
|
|
|
// if (argz.parsed.length == 2) {
|
|
// auto reply = event(origin.relates.reply.event_id, evt.room).body;
|
|
// foreach (chr; reply) {
|
|
// if (chr == ' ') text ~= '+';
|
|
// else text ~= chr;
|
|
// }
|
|
// } else for (short i = 2; i < argz.parsed.length; ++i)
|
|
// text ~= argz.parsed[i] ~ '+';
|
|
|
|
// auto rq = mkrqst (
|
|
// "https://" ~ (instance ? instance : "mozhi.gitro.xyz") ~ "/api/translate", "POST",
|
|
// "engine=" ~ (ngn ? ngn : "google")
|
|
// ~ "&from=" ~ argz.parsed[0]
|
|
// ~ "&to=" ~ argz.parsed[1]
|
|
// ~ "&text=" ~ text,
|
|
// false
|
|
// );
|
|
|
|
// if (rq.status != 200) return MSG(intToStr(rq.status));
|
|
// auto content = rq.body.deserialize!RqRsp;
|
|
|
|
// msg = MSG("ЙАЗЫКНЙЭВЫ|БРАН", content.translatedText);
|
|
// return msg;
|
|
// }
|
|
|
|
// @Command("Creates audio with text, using Mozhi")
|
|
// auto tts(Arguments argz, EventWithoutRoomID* evt) {
|
|
|
|
// }
|