fixed captcha cutting off
This commit is contained in:
parent
34ba6e782b
commit
491e9b5a6f
2 changed files with 3 additions and 36 deletions
|
@ -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;
|
||||||
|
|
|
@ -16,7 +16,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);
|
||||||
|
@ -38,7 +38,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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue