Skip to content

Commit

Permalink
Fixed translator
Browse files Browse the repository at this point in the history
  • Loading branch information
LaineZ committed Jan 25, 2025
1 parent 5b205e9 commit 2f50ba8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions fs24bot3/Commands/TranslateCommandsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public async Task Translate(Language lang, [Remainder] string text)
try
{
var translatedOutput = await Context.ServicesHelper.Translate(text, lang.From, lang.To);
if (translatedOutput.Tl != null)
if (translatedOutput.Tl != null && translatedOutput.Texts.Any())
{
await Context.SendMessage(Context.Channel, $"{translatedOutput.Text} ({lang})");
await Context.SendMessage(Context.Channel, $"{translatedOutput.Texts[0]} ({lang})");
}
else
{
await Context.SendMessage(Context.Channel, $"{translatedOutput.Text} ({lang})");
await Context.SendMessage(Context.Channel, $"{translatedOutput.Texts[0]} ({lang})");
}
}
catch (ArgumentException)
Expand Down Expand Up @@ -64,7 +64,7 @@ public async Task TranslatePpc2(Language lang, [Remainder] string text)
for (int i = 0; i < splitted.Length; i++)
{
var tr = await Context.ServicesHelper.Translate(splitted[i], lang.From, lang.To);
splitted[i] = tr.Text;
splitted[i] = tr.Texts[0];
}

await Context.SendMessage(Context.Channel, string.Join(' ', splitted).ToLower());
Expand Down
2 changes: 1 addition & 1 deletion fs24bot3/Helpers/DuckDuckGoGPTHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<string> SendMessage(string prompt)

if (!response.IsSuccessStatusCode)
{
return "Я не могу говорить в данный момент";
return $"Я не могу говорить в данный момент, походу память забилась.... попробуйте `{ConfigurationProvider.Config.Prefix}clear` чтобы заработало";
}

var value = await response.Content.ReadAsStringAsync();
Expand Down
6 changes: 2 additions & 4 deletions fs24bot3/Models/Translate.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace fs24bot3.Models;
Expand Down Expand Up @@ -29,7 +27,7 @@ public class Response
public int Code { get; set; }

[JsonProperty("texts")]
public string Text { get; set; }
public List<string> Texts { get; set; }

[JsonProperty("tl")]
public string Tl { get; set; }
Expand Down

0 comments on commit 2f50ba8

Please sign in to comment.