mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
fix: fixed captcha cutting off
This commit is contained in:
@@ -162,7 +162,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
|
|
||||||
if (password is not null)
|
if (password is not null)
|
||||||
{
|
{
|
||||||
var img = GetPasswordImage(password);
|
var img = _captchaService.GetPasswordImage(password);
|
||||||
await using var stream = await img.ToStreamAsync();
|
await using var stream = await img.ToStreamAsync();
|
||||||
var toSend = Response()
|
var toSend = Response()
|
||||||
.File(stream, "timely.png");
|
.File(stream, "timely.png");
|
||||||
@@ -194,39 +194,6 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
await ClaimTimely();
|
await ClaimTimely();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image<Rgba32> GetPasswordImage(string password)
|
|
||||||
{
|
|
||||||
var img = new Image<Rgba32>(50, 24);
|
|
||||||
|
|
||||||
var font = _fonts.NotoSans.CreateFont(22);
|
|
||||||
var outlinePen = new SolidPen(Color.Black, 0.5f);
|
|
||||||
var strikeoutRun = new RichTextRun
|
|
||||||
{
|
|
||||||
Start = 0,
|
|
||||||
End = password.GetGraphemeCount(),
|
|
||||||
Font = font,
|
|
||||||
StrikeoutPen = new SolidPen(Color.White, 4),
|
|
||||||
TextDecorations = TextDecorations.Strikeout
|
|
||||||
};
|
|
||||||
// draw password on the image
|
|
||||||
img.Mutate(x =>
|
|
||||||
{
|
|
||||||
x.DrawText(new RichTextOptions(font)
|
|
||||||
{
|
|
||||||
HorizontalAlignment = HorizontalAlignment.Center,
|
|
||||||
VerticalAlignment = VerticalAlignment.Center,
|
|
||||||
FallbackFontFamilies = _fonts.FallBackFonts,
|
|
||||||
Origin = new(25, 12),
|
|
||||||
TextRuns = [strikeoutRun]
|
|
||||||
},
|
|
||||||
password,
|
|
||||||
Brushes.Solid(Color.White),
|
|
||||||
outlinePen);
|
|
||||||
});
|
|
||||||
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ClaimTimely()
|
private async Task ClaimTimely()
|
||||||
{
|
{
|
||||||
var period = Config.Timely.Cooldown;
|
var period = Config.Timely.Cooldown;
|
||||||
|
@@ -17,7 +17,7 @@ public sealed class CaptchaService(FontProvider fonts, IBotCache cache, IPatrona
|
|||||||
|
|
||||||
public Image<Rgba32> GetPasswordImage(string password)
|
public Image<Rgba32> GetPasswordImage(string password)
|
||||||
{
|
{
|
||||||
var img = new Image<Rgba32>(50, 24);
|
var img = new Image<Rgba32>(60, 34);
|
||||||
|
|
||||||
var font = fonts.NotoSans.CreateFont(22);
|
var font = fonts.NotoSans.CreateFont(22);
|
||||||
var outlinePen = new SolidPen(Color.Black, 0.5f);
|
var outlinePen = new SolidPen(Color.Black, 0.5f);
|
||||||
@@ -39,7 +39,7 @@ public sealed class CaptchaService(FontProvider fonts, IBotCache cache, IPatrona
|
|||||||
HorizontalAlignment = HorizontalAlignment.Center,
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
VerticalAlignment = VerticalAlignment.Center,
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
FallbackFontFamilies = fonts.FallBackFonts,
|
FallbackFontFamilies = fonts.FallBackFonts,
|
||||||
Origin = new(25, 12),
|
Origin = new(30, 15),
|
||||||
TextRuns = [strikeoutRun]
|
TextRuns = [strikeoutRun]
|
||||||
},
|
},
|
||||||
password,
|
password,
|
||||||
|
Reference in New Issue
Block a user