Ricerca dei profili con suggerimenti e foto (#37)
«Aggiungi account» ha una sola casella: mentre Alberto scrive compaiono subito i suggerimenti locali, poi i profili di Instagram con la foto, come chiesto in #37. Il browser di Febe scrive nella casella «Cerca» di Instagram con tasti veri da una mappa chiusa (mai Invio, Tab o Esc), controlla prima il fuoco, legge la risposta della pagina e non clicca mai un risultato. La ricerca ha una categoria propria nel Governatore, con tetti larghi che non consumano quelli della raccolta, e si dà il turno con il motore sull'unica pagina; a fine sessione la pagina torna comunque al riposo. Le foto passano dal CDN con un permesso ciascuna e restano solo in memoria. Le risposte di Alberto del 15 novembre (controllo del fuoco, turni, evento requestWillBeSent, niente foto dei seguiti per ora) sono in §6.1 e in docs/decisioni.md. Su Instagram vero la ricerca parte quando i bersagli search-open e search-box saranno raccolti dal vivo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e417c666d
commit
9941a2fa1f
98 files changed
+8021
-229
No files matched your search
@@ -239,6 +239,84 @@ public sealed class HumanGestures
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Presses one key with a human hold time, through <c>Input.dispatchKeyEvent</c>; with a real Shift key down and
|
||||
/// up around it when the stroke needs Shift. Throws <see cref="GestureInterruptedException"/> while Alberto drives.
|
||||
/// </summary>
|
||||
public async Task PressKeyAsync(KeyStroke key, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(key);
|
||||
EnsureUserNotDriving();
|
||||
var shift = (key.Modifiers & KeyModifiers.Shift) != 0;
|
||||
var shiftKey = new KeyStroke("Shift", "ShiftLeft", 16, KeyModifiers.Shift, null);
|
||||
var shiftDown = false;
|
||||
var keyDown = false;
|
||||
try
|
||||
{
|
||||
if (shift)
|
||||
{
|
||||
shiftDown = true;
|
||||
await Keyboard.KeyDownAsync(_cdp, shiftKey, ct).ConfigureAwait(false);
|
||||
await _clock.Delay(TimeSpan.FromMilliseconds(Draw(new Interval(30, 90))), ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
keyDown = true;
|
||||
await Keyboard.KeyDownAsync(_cdp, key, ct).ConfigureAwait(false);
|
||||
await _clock.Delay(TimeSpan.FromMilliseconds(Draw(Settings.KeyHoldMs)), ct).ConfigureAwait(false);
|
||||
await Keyboard.KeyUpAsync(_cdp, key, ct).ConfigureAwait(false);
|
||||
keyDown = false;
|
||||
if (shift)
|
||||
{
|
||||
await _clock.Delay(TimeSpan.FromMilliseconds(Draw(new Interval(20, 70))), ct).ConfigureAwait(false);
|
||||
await Keyboard.KeyUpAsync(_cdp, shiftKey with { Modifiers = KeyModifiers.None }, ct).ConfigureAwait(false);
|
||||
shiftDown = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// A cancelled step never leaves a key or Shift down in the page, which goes to the engine or to Alberto next.
|
||||
if (keyDown || shiftDown)
|
||||
{
|
||||
await ReleaseQuietlyAsync(keyDown ? key : null, shiftDown ? shiftKey with { Modifiers = KeyModifiers.None } : null).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ReleaseQuietlyAsync(KeyStroke? key, KeyStroke? shiftKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (key is not null)
|
||||
{
|
||||
await Keyboard.KeyUpAsync(_cdp, key, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (shiftKey is not null)
|
||||
{
|
||||
await Keyboard.KeyUpAsync(_cdp, shiftKey, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
// The browser is gone or restarting: no key stays down in a page that no longer exists.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gap before the next key while typing: 60–250 ms (median 110) times mood and pace, now and then a short
|
||||
/// hesitation.
|
||||
/// </summary>
|
||||
public async Task TypingGapAsync(CancellationToken ct = default)
|
||||
{
|
||||
var gap = Draw(Settings.KeyGapMs);
|
||||
if (_random.Chance(Settings.TypingHesitationProbability))
|
||||
{
|
||||
gap += Draw(Settings.TypingHesitationMs);
|
||||
}
|
||||
|
||||
await _clock.Delay(TimeSpan.FromMilliseconds(gap * Multiplier), ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>Waits a drawn time from <paramref name="interval"/> (milliseconds), multiplied by mood and pace.</summary>
|
||||
public async Task<TimeSpan> WaitAsync(Interval interval, CancellationToken ct = default)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user