now working again

Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
Omar Sánchez Pizarro
2025-12-02 09:49:01 +01:00
parent 5929be384a
commit c052439de3
2 changed files with 47 additions and 22 deletions

View File

@@ -9,19 +9,7 @@ from app import arg_parser, config_parser, telegram_bot, google_calendar, utils
args = arg_parser.ArgParser().parse()
config = config_parser.ConfigParser().loadConfig()
tnv_string = "Tn-V"
tnd_string = "Tn-D"
conditional_response = [{
"text": "fichado",
"text2": "fichar",
"emoji": "🕐🏢🏃‍♂️🏡"
},{
"text": "desfichado",
"text2": "desfichar",
"emoji": "🏡🏃‍♂️🏢🕐"
}]
from app import strings
class timenetManager:
telegram = None
@@ -45,9 +33,9 @@ class timenetManager:
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
tnv_string: "wcp_8.0.0.2",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
"Tn-U": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
strings.tnv_string: "wcp_8.0.0.2",
"User-Agent": strings.user_agent,
"Tn-U": strings.tn_u
}
self.login()
@@ -91,11 +79,11 @@ class timenetManager:
def updateTime(self):
now = datetime.now().astimezone(pytz.UTC)
self.headers[tnd_string] = "\"" + now.strftime("%Y-%m-%dT%H:%M:%SZ") + "\""
self.headers[strings.tnd_string] = "\"" + now.strftime("%Y-%m-%dT%H:%M:%SZ") + "\""
self.headers["dStr"] = "\"" + now.strftime("%d/%m/%Y %H:%M:%S") + "\""
def updateVersion(self):
self.headers[tnv_string] = self.getVersion()
self.headers[strings.tnv_string] = self.getVersion()
def getVersion(self):
self.updateTime()
@@ -113,7 +101,7 @@ class timenetManager:
today_checks = json.loads(response.text)
if today_checks['C'] and today_checks['C'][0]['C'][-1]['T'] == typ:
if today_checks['C'] and today_checks['C'][0] and today_checks['C'][0]['C'] and today_checks['C'][0]['C'][-1] and today_checks['C'][0]['C'][-1]['T'] == typ:
self.addMessage("Ya se ha realizado este marcaje antes a las %s" % today_checks['C'][0]['C'][-1]['H'])
self.sendReport()
return True
@@ -156,13 +144,13 @@ class timenetManager:
if not args.debug:
self.addMessage("####HACIENDO CHECK####")
rand = utils.numero_aleatorio_con_probabilidad(230, 0.5)
self.addMessage("Esperando %s segundos para %s en un minuto aleatorio" % (rand,conditional_response[int(typ)]["text2"]))
self.addMessage("Esperando %s segundos para %s en un minuto aleatorio" % (rand,strings.conditional_response[int(typ)]["text2"]))
self.sendReport()
sleep(rand)
self.updateTime()
data = {
"typ": typ,
"date": self.headers[tnd_string],
"date": self.headers[strings.tnd_string],
"geoLatitude": config['geo']['latitude'],
"geoLongitude": config['geo']['longitude'],
"geoError": "",
@@ -193,7 +181,7 @@ class timenetManager:
self.addMessage("🕐 Ya se ha realizado este marcaje antes a las %s" % time)
else:
time = datetime.now().astimezone(pytz.timezone("Europe/Madrid")).strftime("%H:%M")
self.addMessage('%s Has %s correctamente a las %s' % (conditional_response[int(typ)]['emoji'], conditional_response[int(typ)]['text'], time))
self.addMessage('%s Has %s correctamente a las %s' % (strings.conditional_response[int(typ)]['emoji'], strings.conditional_response[int(typ)]['text'], time))
else:
self.addMessage("🟥🕐 No se ha podido fichar, la web no ha devuelto 200 OK")