pendify 0.1.6__tar.gz → 0.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pendify-0.1.6/src/pendify.egg-info → pendify-0.1.8}/PKG-INFO +3 -3
- {pendify-0.1.6 → pendify-0.1.8}/README.md +2 -2
- {pendify-0.1.6 → pendify-0.1.8}/pyproject.toml +1 -1
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/client.py +111 -1
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/page.py +19 -4
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/watcher.py +30 -11
- {pendify-0.1.6 → pendify-0.1.8/src/pendify.egg-info}/PKG-INFO +3 -3
- {pendify-0.1.6 → pendify-0.1.8}/LICENSE +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/MANIFEST.in +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/setup.cfg +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/__init__.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/__main__.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/alert.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/autostart.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/codes.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/config.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/icon.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/pairing.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/pendify.ico +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/plate_almena.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/qr.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/runfile.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/tray.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/update.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify/worker.py +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify.egg-info/SOURCES.txt +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify.egg-info/dependency_links.txt +0 -0
- {pendify-0.1.6 → pendify-0.1.8}/src/pendify.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pendify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Pairs this PC with a phone account by a QR on a loopback page and sends it two kinds of alerts.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/ElkinDev/PendiFy
|
|
@@ -73,7 +73,7 @@ El botón de arriba a la derecha cambia entre el tema claro y el oscuro, y el pr
|
|
|
73
73
|
|
|
74
74
|
### Qué envía y a quién
|
|
75
75
|
|
|
76
|
-
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía.
|
|
76
|
+
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía. Si el juego no da su reloj, lee en su lugar el registro propio del juego en este mismo PC, solo la hora de dos clases de línea, y no guarda ni envía nada de él.
|
|
77
77
|
|
|
78
78
|
### `--dry`
|
|
79
79
|
|
|
@@ -138,7 +138,7 @@ The button at the top right switches between the light and the dark theme, and t
|
|
|
138
138
|
|
|
139
139
|
### What it sends and to whom
|
|
140
140
|
|
|
141
|
-
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it.
|
|
141
|
+
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it. When the game gives no clock, it reads the game's own log on this same PC instead, only the time stamps of two kinds of line, and neither keeps nor sends any of it.
|
|
142
142
|
|
|
143
143
|
### `--dry`
|
|
144
144
|
|
|
@@ -57,7 +57,7 @@ El botón de arriba a la derecha cambia entre el tema claro y el oscuro, y el pr
|
|
|
57
57
|
|
|
58
58
|
### Qué envía y a quién
|
|
59
59
|
|
|
60
|
-
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía.
|
|
60
|
+
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía. Si el juego no da su reloj, lee en su lugar el registro propio del juego en este mismo PC, solo la hora de dos clases de línea, y no guarda ni envía nada de él.
|
|
61
61
|
|
|
62
62
|
### `--dry`
|
|
63
63
|
|
|
@@ -122,7 +122,7 @@ The button at the top right switches between the light and the dark theme, and t
|
|
|
122
122
|
|
|
123
123
|
### What it sends and to whom
|
|
124
124
|
|
|
125
|
-
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it.
|
|
125
|
+
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it. When the game gives no clock, it reads the game's own log on this same PC instead, only the time stamps of two kinds of line, and neither keeps nor sends any of it.
|
|
126
126
|
|
|
127
127
|
### `--dry`
|
|
128
128
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pendify"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.8"
|
|
8
8
|
description = "Pairs this PC with a phone account by a QR on a loopback page and sends it two kinds of alerts."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -5,11 +5,14 @@ the client process's command line through PowerShell takes the place of the scri
|
|
|
5
5
|
most once every 10 s. Every failure is no client, never an exception. Nothing here prints, logs or raises
|
|
6
6
|
the client's token, and Credentials hides it from repr. The client's phase says the loading screen opened;
|
|
7
7
|
the game's own loopback port is asked one number, its clock, to tell when the match itself starts. Nothing
|
|
8
|
-
else of the live data is read, kept, printed or sent.
|
|
8
|
+
else of the live data is read, kept, printed or sent. A game that serves no clock is read from its own log on this
|
|
9
|
+
PC instead: only the stamps of its join and start lines are parsed, and nothing of the log is kept.
|
|
9
10
|
"""
|
|
10
11
|
import base64
|
|
12
|
+
import calendar
|
|
11
13
|
import http.client
|
|
12
14
|
import json
|
|
15
|
+
import os
|
|
13
16
|
import re
|
|
14
17
|
import ssl
|
|
15
18
|
import subprocess
|
|
@@ -221,3 +224,110 @@ def game_clock(base, get=get):
|
|
|
221
224
|
return float(seconds)
|
|
222
225
|
except OverflowError: # an int no float holds
|
|
223
226
|
return None
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# The game's own log, for a game that serves no clock: where it is under LOCALAPPDATA, the two marks of the lines
|
|
230
|
+
# it writes when the match starts (as it leaves its loading widget), the mark of its join line (written when the
|
|
231
|
+
# game joins its match, earlier, and no start), the most one call reads and the size of each read.
|
|
232
|
+
GAME_LOG_PARTS = ("TFT", "Saved", "Logs", "TFT.log")
|
|
233
|
+
GAME_LOG_MARKS = (b"UTFTMusicPlayerSubsystem::LoadMusicData - Loaded music",
|
|
234
|
+
b"TFTEncounterSubsystem: Setting SetZoomOutExtension")
|
|
235
|
+
GAME_LOG_JOIN = b"LogNet: Welcomed by server"
|
|
236
|
+
GAME_LOG_MAX_BYTES = 16 * 1024 * 1024
|
|
237
|
+
GAME_LOG_CHUNK = 256 * 1024
|
|
238
|
+
_GAME_LOG_STAMP = "%Y.%m.%d-%H.%M.%S" # then :mmm, in UTC
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def real_game_log(environ=os.environ):
|
|
242
|
+
"""The game's own log in a real run, <LOCALAPPDATA>/TFT/Saved/Logs/TFT.log; None when LOCALAPPDATA is unset or
|
|
243
|
+
blank."""
|
|
244
|
+
base = environ.get("LOCALAPPDATA")
|
|
245
|
+
if base is None or not base.strip():
|
|
246
|
+
return None
|
|
247
|
+
return os.path.join(base, *GAME_LOG_PARTS)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _log_stamp(line):
|
|
251
|
+
"""The epoch of the stamp between a log line's first [ and the ] after it, YYYY.MM.DD-HH.MM.SS:mmm in UTC,
|
|
252
|
+
with its milliseconds; None when it does not parse."""
|
|
253
|
+
start = line.find(b"[")
|
|
254
|
+
end = line.find(b"]", start + 1) if start >= 0 else -1
|
|
255
|
+
if end < 0:
|
|
256
|
+
return None
|
|
257
|
+
try:
|
|
258
|
+
moment, millis = line[start + 1:end].decode("ascii").split(":")
|
|
259
|
+
if len(millis) != 3 or not millis.isdigit():
|
|
260
|
+
return None
|
|
261
|
+
return calendar.timegm(time.strptime(moment, _GAME_LOG_STAMP)) + int(millis) / 1000
|
|
262
|
+
except ValueError: # not ASCII, not one colon, or not the stamp's shape; UnicodeDecodeError is a ValueError
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _holds(lines, marks, since):
|
|
267
|
+
"""True when one of `lines`, whole lines each ending in a line feed, holds one of `marks` and is stamped at or
|
|
268
|
+
after `since`: a start line with GAME_LOG_MARKS, a join line with (GAME_LOG_JOIN,). A line older than `since`,
|
|
269
|
+
or whose stamp does not parse, is skipped and the search goes on."""
|
|
270
|
+
for mark in marks:
|
|
271
|
+
at = lines.find(mark)
|
|
272
|
+
while at >= 0:
|
|
273
|
+
start = lines.rfind(b"\n", 0, at) + 1
|
|
274
|
+
stamp = _log_stamp(lines[start:lines.find(b"\n", at)])
|
|
275
|
+
if stamp is not None and stamp >= since:
|
|
276
|
+
return True
|
|
277
|
+
at = lines.find(mark, at + len(mark))
|
|
278
|
+
return False
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class GameLogStart:
|
|
282
|
+
"""Whether the game's own log shows the match started: a start line stamped at or after a time.
|
|
283
|
+
|
|
284
|
+
The log is read in binary and on from where the last call stopped: the first call from byte 0, each later one
|
|
285
|
+
from the end of the last whole line read, at most GAME_LOG_MAX_BYTES a call in GAME_LOG_CHUNK reads; a partial
|
|
286
|
+
last line is read again next time, and a file shorter than the offset, a new one, is read from its start. Only
|
|
287
|
+
the stamps of start lines and join lines are parsed; the join line, written before the start, is no start line,
|
|
288
|
+
but one stamped at or after `since` sets `joined`, the game in its match and not started yet, False again only
|
|
289
|
+
when built and after reset(). No line or part of one is kept, returned, logged or printed: between calls the
|
|
290
|
+
object keeps the offset and that bool and nothing of the file. Every failure answers False, never an exception.
|
|
291
|
+
`path` answers the log's path or None; `opener` opens it as open() does."""
|
|
292
|
+
|
|
293
|
+
def __init__(self, path=real_game_log, opener=open):
|
|
294
|
+
self._path, self._opener = path, opener
|
|
295
|
+
self._offset = 0
|
|
296
|
+
self.joined = False
|
|
297
|
+
|
|
298
|
+
def reset(self):
|
|
299
|
+
"""Forget the offset and the join: the next call reads the file from its start."""
|
|
300
|
+
self._offset = 0
|
|
301
|
+
self.joined = False
|
|
302
|
+
|
|
303
|
+
def __call__(self, since):
|
|
304
|
+
"""True when the log holds a start line stamped at or after `since`, in epoch seconds; else False."""
|
|
305
|
+
path = self._path()
|
|
306
|
+
if path is None:
|
|
307
|
+
return False
|
|
308
|
+
try:
|
|
309
|
+
with self._opener(path, "rb") as handle:
|
|
310
|
+
if handle.seek(0, os.SEEK_END) < self._offset:
|
|
311
|
+
self._offset = 0
|
|
312
|
+
handle.seek(self._offset)
|
|
313
|
+
return self._read_on(handle, since)
|
|
314
|
+
except OSError: # no file, a folder, a refused open or a read that broke
|
|
315
|
+
return False
|
|
316
|
+
|
|
317
|
+
def _read_on(self, handle, since):
|
|
318
|
+
budget, partial = GAME_LOG_MAX_BYTES, b""
|
|
319
|
+
while budget > 0:
|
|
320
|
+
chunk = handle.read(min(GAME_LOG_CHUNK, budget))
|
|
321
|
+
if not chunk:
|
|
322
|
+
return False
|
|
323
|
+
budget -= len(chunk)
|
|
324
|
+
partial += chunk
|
|
325
|
+
end = partial.rfind(b"\n") + 1 # the whole lines read so far end there
|
|
326
|
+
if end:
|
|
327
|
+
lines, partial = partial[:end], partial[end:]
|
|
328
|
+
self._offset += end
|
|
329
|
+
if not self.joined and _holds(lines, (GAME_LOG_JOIN,), since):
|
|
330
|
+
self.joined = True
|
|
331
|
+
if _holds(lines, GAME_LOG_MARKS, since):
|
|
332
|
+
return True
|
|
333
|
+
return False
|
|
@@ -55,7 +55,6 @@ WORDS = {
|
|
|
55
55
|
"qr_press": "Pulsa Mostrar el código",
|
|
56
56
|
"show_code": "Mostrar el código",
|
|
57
57
|
"hide_code": "Ocultar el código",
|
|
58
|
-
"mask": "Clave oculta",
|
|
59
58
|
"fold": "Más opciones: escribir los valores del enlace u olvidar este PC",
|
|
60
59
|
"credit": "Creado por",
|
|
61
60
|
"sponsor_by": "Patrocinado por Pendiapp.com",
|
|
@@ -147,7 +146,6 @@ WORDS = {
|
|
|
147
146
|
"qr_press": "Press Show the code",
|
|
148
147
|
"show_code": "Show the code",
|
|
149
148
|
"hide_code": "Hide the code",
|
|
150
|
-
"mask": "Key hidden",
|
|
151
149
|
"fold": "More options: type the link values, or forget this PC",
|
|
152
150
|
"credit": "Created by",
|
|
153
151
|
"sponsor_by": "Sponsored by Pendiapp.com",
|
|
@@ -427,6 +425,8 @@ _STYLE += ("@media (min-width:880px){.page{max-width:max(1040px,85vw)}\n"
|
|
|
427
425
|
'.key[data-shown="true"] .mask{visibility:hidden}\n'
|
|
428
426
|
'.key-card:has(.key[data-shown="false"]) .modules{visibility:hidden}\n'
|
|
429
427
|
'.key-card:has(.key[data-shown="true"]) .qr-mask{visibility:hidden}\n'
|
|
428
|
+
# A press on either mask shows the code (OR-108).
|
|
429
|
+
".qr-mask,.mask{cursor:pointer}\n"
|
|
430
430
|
".qr-for{margin:0}\n"
|
|
431
431
|
# The label with impact (OR-105, the pfmask mockup): the #state linked block's recipe, stretched to the
|
|
432
432
|
# card, the owner's leading capitals as its lead line and the rest under it. The masks over the QR (OR-104,
|
|
@@ -576,6 +576,19 @@ _SCRIPT = ("const s=document.getElementById('state');const w=document.getElement
|
|
|
576
576
|
"function showKey(on){k.dataset.shown=String(on);r.textContent=on?r.dataset.hide:r.dataset.show;"
|
|
577
577
|
"clearTimeout(hide);if(on)hide=setTimeout(()=>showKey(false),60000);}"
|
|
578
578
|
"if(r)r.addEventListener('click',()=>showKey(k.dataset.shown!=='true'));"
|
|
579
|
+
# A key held after a mask press repeats on the reveal the focus moved to; its repeats would set it
|
|
580
|
+
# active or click it and hide the code again, so only a repeat Enter or Space loses its default there.
|
|
581
|
+
"if(r)r.addEventListener('keydown',e=>{if(e.repeat&&(e.key==='Enter'||e.key===' '))e.preventDefault();});"
|
|
582
|
+
# Both masks do what the reveal does (OR-108), and never hide the code. The QR's mask is an image in
|
|
583
|
+
# the svg that a click shows the code from; the keyboard and the screen reader have the reveal. The
|
|
584
|
+
# key's mask is a button: a click, Enter or Space shows the code, then focus moves to the reveal,
|
|
585
|
+
# since the mask turns visibility:hidden and would drop it to the body. Enter and Space both prevent
|
|
586
|
+
# their default: Space would scroll the page, and Enter's keypress would go to the reveal the focus
|
|
587
|
+
# moved to, which would toggle the code back to hidden.
|
|
588
|
+
"document.querySelectorAll('.qr-mask').forEach(m=>m.addEventListener('click',()=>showKey(true)));"
|
|
589
|
+
"document.querySelectorAll('.mask').forEach(m=>{const press=()=>{showKey(true);r.focus();};"
|
|
590
|
+
"m.addEventListener('click',press);m.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){"
|
|
591
|
+
"e.preventDefault();press();}});});"
|
|
579
592
|
# The theme button (pendiapp.com's assets/theme.js): the choice goes to data-theme and to localStorage,
|
|
580
593
|
# and it is posted to /theme, which keeps it in config.json: the page's port changes on every run, so
|
|
581
594
|
# its localStorage is a new origin each time. The server's value, served as data-theme, wins on the next
|
|
@@ -700,8 +713,10 @@ def _lead(sentence):
|
|
|
700
713
|
|
|
701
714
|
|
|
702
715
|
def _mask(words):
|
|
703
|
-
"""The mask over the key, three groups of the four heads, named
|
|
704
|
-
|
|
716
|
+
"""The mask over the key, three groups of the four heads, a control named by the press words, as the QR's
|
|
717
|
+
mask is: a press on either shows the code (lane pfpress). `words` are escaped."""
|
|
718
|
+
return (f'<span class="mask" role="button" tabindex="0" aria-label="{words["qr_press"]}">'
|
|
719
|
+
f'{_MASK_GROUP * 3}</span>')
|
|
705
720
|
|
|
706
721
|
|
|
707
722
|
def _sponsor_runs():
|
|
@@ -7,10 +7,12 @@ and answers the pause before the next; run() is the loop around it. The script's
|
|
|
7
7
|
check (S:778, S:793) is a hold on the injected clock, so a stop never waits for it. The arrival of
|
|
8
8
|
InProgress after a read of another phase is the loading screen: it beeps on the PC only, once per game, and
|
|
9
9
|
starts a watch that asks the game's own loopback port its clock at most once a second. The clock above zero
|
|
10
|
-
is the match's true start: a beep and match_started. A game
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
no
|
|
10
|
+
is the match's true start: a beep and match_started. A game with no clock port is read from its own log, a
|
|
11
|
+
start line stamped no earlier than 30 s before the loading screen. A game that never answers its clock is
|
|
12
|
+
announced after 120 s of the watch with InProgress read; a read of a boundary phase, or 120 s with no client,
|
|
13
|
+
ends the watch with no alert. While the game's log shows a join line and no start line, the game in its match and
|
|
14
|
+
not started yet, those 120 s are held, up to 300 s from the loading screen. A reconnect is the same game. The
|
|
15
|
+
console gets fixed lines only: no phase, no port, no clock, no token.
|
|
14
16
|
|
|
15
17
|
pause() and resume() come from the page's thread and only set or clear an event; the loop honors it on its own
|
|
16
18
|
thread. While paused run() makes no step, so nothing reads the client's files or process, its port or the game's
|
|
@@ -42,6 +44,8 @@ STEP_PAUSE = 0.3 # S:799
|
|
|
42
44
|
NO_CLIENT_PAUSE = 3.0 # S:739
|
|
43
45
|
LIVE_POLL_SECONDS = 1.0 # the game's clock is asked at most once a second during the watch
|
|
44
46
|
LIVE_FALLBACK_SECONDS = 120.0 # restarted by each clock not above zero, the wait announces a game giving no clock
|
|
47
|
+
LIVE_LOG_GRACE_SECONDS = 30.0 # a start line in the game's log counts from this long before the loading screen
|
|
48
|
+
LIVE_JOINED_CEILING_SECONDS = 300.0 # a game whose log shows its join holds the wait up to this long from the loading
|
|
45
49
|
QUEUE_FOUND, MATCH_STARTED = worker.KINDS
|
|
46
50
|
LOG_LINES = 50 # the events the log keeps, the newest
|
|
47
51
|
|
|
@@ -83,10 +87,12 @@ def _phase(raw):
|
|
|
83
87
|
class Watcher:
|
|
84
88
|
def __init__(self, credentials, alert, *, accept=True, addresses=client.real_addresses, get=client.get,
|
|
85
89
|
post=client.post, clock=time.monotonic, wall=time.time, sleep=None, delay=accept_delay,
|
|
86
|
-
log=None, stop=None, live=client.real_live_address, game_clock=client.game_clock):
|
|
90
|
+
log=None, stop=None, live=client.real_live_address, game_clock=client.game_clock, game_log=None):
|
|
87
91
|
self._credentials, self._alert, self._accept = credentials, alert, accept
|
|
88
92
|
self._addresses, self._get, self._post = addresses, get, post
|
|
89
93
|
self._live, self._game_clock = live, game_clock
|
|
94
|
+
# The game's own log, asked on the clock's turns when the clock gives no start; a callable with reset().
|
|
95
|
+
self._game_log = game_log if game_log is not None else client.GameLogStart()
|
|
90
96
|
self._clock, self._wall, self._delay = clock, wall, delay
|
|
91
97
|
self._stop = stop if stop is not None else threading.Event()
|
|
92
98
|
self._sleep = sleep if sleep is not None else self._stop.wait
|
|
@@ -100,6 +106,8 @@ class Watcher:
|
|
|
100
106
|
self._last_alert = None
|
|
101
107
|
self._watch_since = None # the injected clock when the loading screen opened; None with no watch on
|
|
102
108
|
self._next_live = None # the injected clock from which the game's clock may be asked again
|
|
109
|
+
self._watch_wall = None # the wall clock when the loading screen opened, the game's log read against it
|
|
110
|
+
self._watch_began = None # the injected clock when the loading screen opened, never moved by a clock restart
|
|
103
111
|
self._paused = threading.Event() # set and cleared by the page's thread, read by the loop
|
|
104
112
|
self._pauses = 0 # every pause counted by the page's thread, under the lock; the loop compares it
|
|
105
113
|
self._honored = 0 # the count of the last pause the loop has rested for; read and written by it only
|
|
@@ -283,12 +291,16 @@ class Watcher:
|
|
|
283
291
|
self._last_alert = (LOADING, self._wall())
|
|
284
292
|
self._log(LOADING_LINE)
|
|
285
293
|
self._note(LOADING)
|
|
286
|
-
self._watch_since = self._next_live = self._clock()
|
|
294
|
+
self._watch_since = self._next_live = self._watch_began = self._clock()
|
|
295
|
+
self._watch_wall = self._wall()
|
|
296
|
+
self._game_log.reset()
|
|
287
297
|
|
|
288
298
|
def _watch(self, phase):
|
|
289
299
|
"""One turn of the watch: the game's clock asked when due, its value above zero the start and any other
|
|
290
|
-
number a restart of the wait;
|
|
291
|
-
|
|
300
|
+
number a restart of the wait; with no start from the clock, the game's own log asked on that same turn, a
|
|
301
|
+
start line stamped no earlier than LIVE_LOG_GRACE_SECONDS before the loading screen the start; then the wait,
|
|
302
|
+
which fires on a step whose phase read was InProgress and ends with no alert with no client, held while the
|
|
303
|
+
game's log shows its join and no start, up to LIVE_JOINED_CEILING_SECONDS from the loading screen."""
|
|
292
304
|
if self._watch_since is None:
|
|
293
305
|
return
|
|
294
306
|
now = self._clock()
|
|
@@ -301,7 +313,13 @@ class Watcher:
|
|
|
301
313
|
return
|
|
302
314
|
if seconds is not None:
|
|
303
315
|
self._watch_since = now
|
|
316
|
+
if self._game_log(self._watch_wall - LIVE_LOG_GRACE_SECONDS):
|
|
317
|
+
self._watch_since = None
|
|
318
|
+
self._fire(MATCH_STARTED, STARTED_LINE)
|
|
319
|
+
return
|
|
304
320
|
if now >= self._watch_since + LIVE_FALLBACK_SECONDS:
|
|
321
|
+
if self._game_log.joined and now < self._watch_began + LIVE_JOINED_CEILING_SECONDS:
|
|
322
|
+
return # joined and not started yet: the watch goes on, the log still asked on each due turn
|
|
305
323
|
if phase == IN_PROGRESS:
|
|
306
324
|
self._watch_since = None
|
|
307
325
|
self._fire(MATCH_STARTED, STARTED_ON_WAIT_LINE)
|
|
@@ -333,11 +351,12 @@ class Watcher:
|
|
|
333
351
|
self._set_client(WAITING)
|
|
334
352
|
|
|
335
353
|
def _rest(self):
|
|
336
|
-
"""The first paused turn: the client, the watch, the hold and the start latch are dropped
|
|
337
|
-
after a resume is a fresh connection."""
|
|
354
|
+
"""The first paused turn: the client, the watch, the hold and the start latch are dropped and the reader of
|
|
355
|
+
the game's log reset, so the turn after a resume is a fresh connection."""
|
|
338
356
|
self._resting = True
|
|
339
357
|
self._forget()
|
|
340
|
-
self._watch_since = self._next_live = None
|
|
358
|
+
self._watch_since = self._next_live = self._watch_wall = self._watch_began = None
|
|
359
|
+
self._game_log.reset()
|
|
341
360
|
self._hold_until = None
|
|
342
361
|
self._start_alerted = False
|
|
343
362
|
self._log(PAUSED_LINE)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pendify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Pairs this PC with a phone account by a QR on a loopback page and sends it two kinds of alerts.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/ElkinDev/PendiFy
|
|
@@ -73,7 +73,7 @@ El botón de arriba a la derecha cambia entre el tema claro y el oscuro, y el pr
|
|
|
73
73
|
|
|
74
74
|
### Qué envía y a quién
|
|
75
75
|
|
|
76
|
-
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía.
|
|
76
|
+
Solo envía, al servicio de enlace de Pendi, el tipo de aviso (partida encontrada o partida empezada) junto con el identificador del enlace y el secreto de este PC, que viven en `%APPDATA%\pendify\config.json`. El servicio lo entrega a la cuenta que enlazaste. No envía tu nombre, tus partidas ni nada más del juego. Para saber cuándo empieza la partida lee el reloj del juego en este mismo PC, y no lo guarda ni lo envía. Si el juego no da su reloj, lee en su lugar el registro propio del juego en este mismo PC, solo la hora de dos clases de línea, y no guarda ni envía nada de él.
|
|
77
77
|
|
|
78
78
|
### `--dry`
|
|
79
79
|
|
|
@@ -138,7 +138,7 @@ The button at the top right switches between the light and the dark theme, and t
|
|
|
138
138
|
|
|
139
139
|
### What it sends and to whom
|
|
140
140
|
|
|
141
|
-
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it.
|
|
141
|
+
It only sends, to Pendi's link service, the alert kind (match found or match started) together with the link id and this PC's secret, which live in `%APPDATA%\pendify\config.json`. The service delivers it to the account you linked. It sends no name, no match history and nothing else from the game. To tell when the match starts it reads the game's clock on this same PC, and neither keeps nor sends it. When the game gives no clock, it reads the game's own log on this same PC instead, only the time stamps of two kinds of line, and neither keeps nor sends any of it.
|
|
142
142
|
|
|
143
143
|
### `--dry`
|
|
144
144
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|